most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown

Dependencies:   mbed MODSERIAL FATFileSystem

Committer:
joel_ssc
Date:
Mon May 13 19:25:26 2019 +0000
Revision:
92:52a91656458a
Parent:
9:d5fcdcb3c89d
version for first flight test, timeouts not yet set correctly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mkelly10 9:d5fcdcb3c89d 1 /**
mkelly10 9:d5fcdcb3c89d 2 * Configuration file interface class (Version 0.0.1)
mkelly10 9:d5fcdcb3c89d 3 *
mkelly10 9:d5fcdcb3c89d 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
mkelly10 9:d5fcdcb3c89d 5 * http://shinta.main.jp/
mkelly10 9:d5fcdcb3c89d 6 */
mkelly10 9:d5fcdcb3c89d 7 #include "mbed.h"
mkelly10 9:d5fcdcb3c89d 8
mkelly10 9:d5fcdcb3c89d 9 #ifndef _CONFIG_FILE_H_
mkelly10 9:d5fcdcb3c89d 10 #define _CONFIG_FILE_H_
mkelly10 9:d5fcdcb3c89d 11
mkelly10 9:d5fcdcb3c89d 12 /**
mkelly10 9:d5fcdcb3c89d 13 * Configuration File class.
mkelly10 9:d5fcdcb3c89d 14 */
mkelly10 9:d5fcdcb3c89d 15 class ConfigFile {
mkelly10 9:d5fcdcb3c89d 16 public:
mkelly10 9:d5fcdcb3c89d 17
mkelly10 9:d5fcdcb3c89d 18 /**
mkelly10 9:d5fcdcb3c89d 19 * Create a configuration file class.
mkelly10 9:d5fcdcb3c89d 20 */
mkelly10 9:d5fcdcb3c89d 21 ConfigFile();
mkelly10 9:d5fcdcb3c89d 22
mkelly10 9:d5fcdcb3c89d 23 /**
mkelly10 9:d5fcdcb3c89d 24 * Destroy a configuration file class.
mkelly10 9:d5fcdcb3c89d 25 */
mkelly10 9:d5fcdcb3c89d 26 ~ConfigFile();
mkelly10 9:d5fcdcb3c89d 27
mkelly10 9:d5fcdcb3c89d 28 /**
mkelly10 9:d5fcdcb3c89d 29 * Get a value for a key.
mkelly10 9:d5fcdcb3c89d 30 *
mkelly10 9:d5fcdcb3c89d 31 * @param key A target key name.
mkelly10 9:d5fcdcb3c89d 32 * @param value A pointer to a value storage.
mkelly10 9:d5fcdcb3c89d 33 * @param siz A size of a value storage.
mkelly10 9:d5fcdcb3c89d 34 * @return A value or NULL.
mkelly10 9:d5fcdcb3c89d 35 */
mkelly10 9:d5fcdcb3c89d 36 bool getValue(char *key, char *value, size_t siz);
mkelly10 9:d5fcdcb3c89d 37
mkelly10 9:d5fcdcb3c89d 38 /**
mkelly10 9:d5fcdcb3c89d 39 * Set a set of a key and value.
mkelly10 9:d5fcdcb3c89d 40 *
mkelly10 9:d5fcdcb3c89d 41 * @param key A key.
mkelly10 9:d5fcdcb3c89d 42 * @param value A value.
mkelly10 9:d5fcdcb3c89d 43 *
mkelly10 9:d5fcdcb3c89d 44 * @return True if it succeed.
mkelly10 9:d5fcdcb3c89d 45 */
mkelly10 9:d5fcdcb3c89d 46 bool setValue(char *key, char *value);
mkelly10 9:d5fcdcb3c89d 47
mkelly10 9:d5fcdcb3c89d 48 /**
mkelly10 9:d5fcdcb3c89d 49 * Remove a config.
mkelly10 9:d5fcdcb3c89d 50 *
mkelly10 9:d5fcdcb3c89d 51 * @param key A key.
mkelly10 9:d5fcdcb3c89d 52 *
mkelly10 9:d5fcdcb3c89d 53 * @return True if it succeed.
mkelly10 9:d5fcdcb3c89d 54 */
mkelly10 9:d5fcdcb3c89d 55 bool remove(char *key);
mkelly10 9:d5fcdcb3c89d 56
mkelly10 9:d5fcdcb3c89d 57 /**
mkelly10 9:d5fcdcb3c89d 58 * Remove all config.
mkelly10 9:d5fcdcb3c89d 59 *
mkelly10 9:d5fcdcb3c89d 60 * @return True if it succeed.
mkelly10 9:d5fcdcb3c89d 61 */
mkelly10 9:d5fcdcb3c89d 62 bool removeAll(void);
mkelly10 9:d5fcdcb3c89d 63
mkelly10 9:d5fcdcb3c89d 64 /**
mkelly10 9:d5fcdcb3c89d 65 * Get a number of configuration sets.
mkelly10 9:d5fcdcb3c89d 66 *
mkelly10 9:d5fcdcb3c89d 67 * @return number of configuration sets.
mkelly10 9:d5fcdcb3c89d 68 */
mkelly10 9:d5fcdcb3c89d 69 int getCount();
mkelly10 9:d5fcdcb3c89d 70
mkelly10 9:d5fcdcb3c89d 71 /**
mkelly10 9:d5fcdcb3c89d 72 * Get a key and a value.
mkelly10 9:d5fcdcb3c89d 73 *
mkelly10 9:d5fcdcb3c89d 74 * @param index Index number of this list.
mkelly10 9:d5fcdcb3c89d 75 * @param key A pointer to a buffer for key.
mkelly10 9:d5fcdcb3c89d 76 * @param keybufsiz A size of the key buffer.
mkelly10 9:d5fcdcb3c89d 77 * @param value A pointer to a buffer for value.
mkelly10 9:d5fcdcb3c89d 78 * @param valuebufsiz A size of the value buffer.
mkelly10 9:d5fcdcb3c89d 79 *
mkelly10 9:d5fcdcb3c89d 80 * @return true if it succeed.
mkelly10 9:d5fcdcb3c89d 81 */
mkelly10 9:d5fcdcb3c89d 82 bool getKeyAndValue(int index, char *key, size_t keybufsiz, char *value, size_t valuebufsiz);
mkelly10 9:d5fcdcb3c89d 83
mkelly10 9:d5fcdcb3c89d 84 /**
mkelly10 9:d5fcdcb3c89d 85 * Read from the target file.
mkelly10 9:d5fcdcb3c89d 86 *
mkelly10 9:d5fcdcb3c89d 87 * @param file A target file name.
mkelly10 9:d5fcdcb3c89d 88 */
mkelly10 9:d5fcdcb3c89d 89 bool read(char *file);
mkelly10 9:d5fcdcb3c89d 90
mkelly10 9:d5fcdcb3c89d 91 typedef enum {
mkelly10 9:d5fcdcb3c89d 92 UNIX,
mkelly10 9:d5fcdcb3c89d 93 MAC,
mkelly10 9:d5fcdcb3c89d 94 DOS
mkelly10 9:d5fcdcb3c89d 95 } FileFormat;
mkelly10 9:d5fcdcb3c89d 96
mkelly10 9:d5fcdcb3c89d 97 /**
mkelly10 9:d5fcdcb3c89d 98 * Write from the target file.
mkelly10 9:d5fcdcb3c89d 99 *
mkelly10 9:d5fcdcb3c89d 100 * @param file A pointer to a file name.
mkelly10 9:d5fcdcb3c89d 101 * @param header A pointer to a header.
mkelly10 9:d5fcdcb3c89d 102 * @param ff File format.
mkelly10 9:d5fcdcb3c89d 103 */
mkelly10 9:d5fcdcb3c89d 104 bool write(char *file, char *header = NULL, FileFormat ff = UNIX);
mkelly10 9:d5fcdcb3c89d 105
mkelly10 9:d5fcdcb3c89d 106 private:
mkelly10 9:d5fcdcb3c89d 107 typedef struct {
mkelly10 9:d5fcdcb3c89d 108 char *key;
mkelly10 9:d5fcdcb3c89d 109 char *value;
mkelly10 9:d5fcdcb3c89d 110 } config_t;
mkelly10 9:d5fcdcb3c89d 111 config_t **configlist;
mkelly10 9:d5fcdcb3c89d 112 static const int MAXCONFIG = 64;
mkelly10 9:d5fcdcb3c89d 113 static const int MAXLEN_KEY = 64;
mkelly10 9:d5fcdcb3c89d 114 static const int MAXLEN_VALUE = 128;
mkelly10 9:d5fcdcb3c89d 115 static const char SEPARATOR = '=';
mkelly10 9:d5fcdcb3c89d 116
mkelly10 9:d5fcdcb3c89d 117 config_t *search(char *key);
mkelly10 9:d5fcdcb3c89d 118 bool add(config_t *cfg);
mkelly10 9:d5fcdcb3c89d 119 };
mkelly10 9:d5fcdcb3c89d 120
mkelly10 9:d5fcdcb3c89d 121 #endif