From 373ea323ce2d37b45d438cbe7299365b32240f04 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Sat, 25 Feb 2017 23:53:33 -0500 Subject: some progress on json file writing --- src/survive_config.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index 24762cd..3e62ec8 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -10,7 +10,8 @@ typedef enum { CONFIG_UNKNOWN = 0, CONFIG_FLOAT = 1, CONFIG_UINT32 = 2, - CONFIG_STRING = 3 + CONFIG_STRING = 3, + CONFIG_FLOAT_ARRAY = 4, } cval_type; /* typedef union { @@ -25,13 +26,15 @@ typedef struct { uint32_t i; FLT f; } numeric; - char *str; + char *data; + uint32_t elements; } config_val; - +void config_init(); void config_open(const char* path, const char* mode); void config_close(); void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); +void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx); void config_save(const char* path); const FLT config_set_float(const char *tag, const FLT value); -- cgit v1.2.3 From e8d696e03128242be33eb0734addee645e894635 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Mon, 27 Feb 2017 20:52:26 -0500 Subject: basic config can be written to file --- src/survive_config.h | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index 3e62ec8..14e2fc6 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -13,12 +13,8 @@ typedef enum { CONFIG_STRING = 3, CONFIG_FLOAT_ARRAY = 4, } cval_type; -/* -typedef union { - uint32_t i; - FLT f; - } Numeric; -*/ + + typedef struct { char *tag; cval_type type; @@ -28,21 +24,31 @@ typedef struct { } numeric; char *data; uint32_t elements; -} config_val; +} config_entry; + +typedef struct { + config_entry *config_entries; + uint16_t used_entries; + uint16_t max_entries; +} config_group; + +extern config_group global_config_values; +extern config_group lh_config[2]; //lighthouse configs + void config_init(); void config_open(const char* path, const char* mode); void config_close(); -void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); +//void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx); void config_save(const char* path); -const FLT config_set_float(const char *tag, const FLT value); -const uint32_t config_set_uint32(const char *tag, const uint32_t value); -const char* config_set_str(const char *tag, const char* value); -FLT config_read_float(const char *tag, const FLT value, const FLT def); +const FLT config_set_float(config_group *cg, const char *tag, const FLT value); +const uint32_t config_set_uint32(config_group *cg, const char *tag, const uint32_t value); +const char* config_set_str(config_group *cg, const char *tag, const char* value); -uint32_t config_read_uint32(const char *tag, const uint32_t value, const uint32_t def); -const char* config_read_str(const char *tag, const char *value, const char *def_str); +FLT config_read_float(config_group *cg, const char *tag, const FLT def); +uint32_t config_read_uint32(config_group *cg, const char *tag, const uint32_t def); +const char* config_read_str(config_group *cg, const char *tag, const char *def); #endif \ No newline at end of file -- cgit v1.2.3 From 0ebe84be5824202aecfd87ac58005afa76b36be9 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Mon, 6 Mar 2017 22:05:02 -0500 Subject: Load strings from config files. I need to finish the loading of numeric values and arrays. --- src/survive_config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index 14e2fc6..2610e2e 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -37,7 +37,8 @@ extern config_group lh_config[2]; //lighthouse configs void config_init(); -void config_open(const char* path, const char* mode); +//void config_open(const char* path, const char* mode); +void config_read(const char* path); void config_close(); //void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx); -- cgit v1.2.3 From a7b423ba1f0b28d0e6f3f375475cf93d66b922c9 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Mon, 6 Mar 2017 22:21:15 -0500 Subject: remove unused function --- src/survive_config.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index 2610e2e..b14f928 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -39,7 +39,6 @@ extern config_group lh_config[2]; //lighthouse configs void config_init(); //void config_open(const char* path, const char* mode); void config_read(const char* path); -void config_close(); //void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx); -- cgit v1.2.3 From 90ed96e7b59e60a39f1e1f33223c6ffb0ee833f7 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Tue, 7 Mar 2017 20:33:19 -0500 Subject: parse out integers and floats --- src/survive_config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index b14f928..234db68 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -48,6 +48,7 @@ const uint32_t config_set_uint32(config_group *cg, const char *tag, const uint32 const char* config_set_str(config_group *cg, const char *tag, const char* value); FLT config_read_float(config_group *cg, const char *tag, const FLT def); +uint16_t config_read_float_array(config_group *cg, const char *tag, FLT** values, const FLT* def, uint16_t count); uint32_t config_read_uint32(config_group *cg, const char *tag, const uint32_t def); const char* config_read_str(config_group *cg, const char *tag, const char *def); -- cgit v1.2.3 From 394cbc465e776137834eea830038b43ea98f6268 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Wed, 8 Mar 2017 00:30:48 -0500 Subject: Switch types over to avoiding extra struct keyword. Switch poses to "SurvivePose" type. --- src/survive_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/survive_config.h') diff --git a/src/survive_config.h b/src/survive_config.h index 234db68..cd16c76 100644 --- a/src/survive_config.h +++ b/src/survive_config.h @@ -40,7 +40,7 @@ void config_init(); //void config_open(const char* path, const char* mode); void config_read(const char* path); //void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); -void config_set_lighthouse(struct BaseStationData* bsd, uint8_t idx); +void config_set_lighthouse(BaseStationData* bsd, uint8_t idx); void config_save(const char* path); const FLT config_set_float(config_group *cg, const char *tag, const FLT value); @@ -52,4 +52,4 @@ uint16_t config_read_float_array(config_group *cg, const char *tag, FLT** values uint32_t config_read_uint32(config_group *cg, const char *tag, const uint32_t def); const char* config_read_str(config_group *cg, const char *tag, const char *def); -#endif \ No newline at end of file +#endif -- cgit v1.2.3