From 4ee58045e1376227755cca35b5078ebbc47b2464 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 21 Oct 2021 15:08:00 +0200 Subject: [PATCH] Improved mixer source (de-)serialization --- radio/src/datastructs.h | 13 +- radio/src/simu.cpp | 2 +- .../yaml/yaml_datastructs_funcs.cpp | 74 +++++++++ .../yaml/yaml_datastructs_nv14.cpp | 2 +- .../conversions/yaml/yaml_datastructs_t12.cpp | 10 +- .../conversions/yaml/yaml_datastructs_t8.cpp | 10 +- .../yaml/yaml_datastructs_tlite.cpp | 10 +- .../yaml/yaml_datastructs_tx12.cpp | 10 +- .../conversions/yaml/yaml_datastructs_x10.cpp | 2 +- .../yaml/yaml_datastructs_x12s.cpp | 2 +- .../conversions/yaml/yaml_datastructs_x7.cpp | 10 +- .../conversions/yaml/yaml_datastructs_x9d.cpp | 10 +- .../conversions/yaml/yaml_datastructs_x9e.cpp | 10 +- .../yaml/yaml_datastructs_x9lite.cpp | 10 +- .../yaml/yaml_datastructs_x9lites.cpp | 10 +- .../yaml/yaml_datastructs_xlite.cpp | 10 +- .../yaml/yaml_datastructs_xlites.cpp | 10 +- radio/src/storage/yaml/yaml_bits.cpp | 40 +++-- radio/src/storage/yaml/yaml_bits.h | 3 + .../storage/yaml/yaml_datastructs_funcs.cpp | 156 ++++++++++++++++++ .../storage/yaml/yaml_datastructs_nv14.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_t12.cpp | 10 +- .../src/storage/yaml/yaml_datastructs_t8.cpp | 10 +- .../storage/yaml/yaml_datastructs_tlite.cpp | 10 +- .../storage/yaml/yaml_datastructs_tx12.cpp | 10 +- .../src/storage/yaml/yaml_datastructs_x10.cpp | 2 +- .../storage/yaml/yaml_datastructs_x12s.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_x7.cpp | 10 +- .../src/storage/yaml/yaml_datastructs_x9d.cpp | 10 +- .../src/storage/yaml/yaml_datastructs_x9e.cpp | 10 +- .../storage/yaml/yaml_datastructs_x9lite.cpp | 10 +- .../storage/yaml/yaml_datastructs_x9lites.cpp | 10 +- .../storage/yaml/yaml_datastructs_xlite.cpp | 10 +- .../storage/yaml/yaml_datastructs_xlites.cpp | 10 +- radio/src/storage/yaml/yaml_tree_walker.cpp | 5 + 35 files changed, 394 insertions(+), 131 deletions(-) diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index c8e8bd3b3..7840fe94f 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -257,7 +257,7 @@ PACK(struct SwashRingData { #if MAX_SCRIPTS > 0 union ScriptDataInput { int16_t value; - source_t source; + source_t source CUST(r_mixSrcRaw,w_mixSrcRaw); } FUNC(select_script_input); PACK(struct ScriptData { @@ -288,14 +288,23 @@ typedef int16_t ls_telemetry_value_t; #if !defined(COLORLCD) PACK(struct FrSkyBarData { - source_t source; + source_t source CUST(r_mixSrcRaw,w_mixSrcRaw); ls_telemetry_value_t barMin; // minimum for bar display ls_telemetry_value_t barMax; // ditto for max display (would usually = ratio) }); +#if defined(YAML_GENERATOR) +PACK(struct LineDataSource { + source_t val CUST(r_mixSrcRaw,w_mixSrcRaw); +}); +PACK(struct FrSkyLineData { + LineDataSource sources[NUM_LINE_ITEMS]; +}); +#else PACK(struct FrSkyLineData { source_t sources[NUM_LINE_ITEMS]; }); +#endif #if defined(PCBTARANIS) PACK(struct TelemetryScriptData { diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 95dcb95a2..dcff7f081 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -634,7 +634,7 @@ int main(int argc, char ** argv) startEepromThread(argc >= 2 ? argv[1] : "eeprom.bin"); #endif startAudioThread(); - simuStart(false, argc >= 3 ? argv[2] : 0, argc >= 4 ? argv[3] : 0); + simuStart(true/*false*/, argc >= 3 ? argv[2] : 0, argc >= 4 ? argv[3] : 0); return application.run(); } diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp index e3fd62bfc..f4c688383 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp @@ -49,6 +49,17 @@ extern const struct YamlIdStr enum_MixSources[]; #define r_mixSrcRaw nullptr +static constexpr char closing_parenthesis[] = ")"; + +static bool output_source_1_param(const char* src_prefix, size_t src_len, uint32_t n, + yaml_writer_func wf, void* opaque) +{ + if (!wf(opaque, src_prefix, src_len)) return false; + const char* str = yaml_unsigned2str(n); + if (!wf(opaque, str, strlen(str))) return false; + return true; +} + static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) { const char* str = nullptr; @@ -61,6 +72,69 @@ static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf, str = yaml_unsigned2str(val - MIXSRC_FIRST_INPUT); } +#if defined(LUA_INPUTS) + else if (val >= MIXSRC_FIRST_LUA + && val <= MIXSRC_LAST_LUA) { + + if (!wf(opaque, "lua(", 4)) return false; + + val -= MIXSRC_FIRST_LUA; + uint32_t script = val / MAX_SCRIPT_OUTPUTS; + + if (!output_source_1_param("lua(", 4, script, wf, opaque)) return false; + if (!wf(opaque, ",", 1)) return false; + + val = val % MAX_SCRIPT_OUTPUTS; + str = yaml_unsigned2str(val); + + if (!wf(opaque, str, strlen(str))) return false; + str = closing_parenthesis; + } +#endif + else if (val >= MIXSRC_FIRST_LOGICAL_SWITCH + && val <= MIXSRC_LAST_LOGICAL_SWITCH) { + + val -= MIXSRC_FIRST_LOGICAL_SWITCH; + if (!output_source_1_param("ls(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_TRAINER + && val <= MIXSRC_LAST_TRAINER) { + + val -= MIXSRC_FIRST_TRAINER; + if (!output_source_1_param("tr(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_CH + && val <= MIXSRC_LAST_CH) { + + val -= MIXSRC_FIRST_CH; + if (!output_source_1_param("ch(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_GVAR + && val <= MIXSRC_LAST_GVAR) { + + val -= MIXSRC_FIRST_GVAR; + if (!output_source_1_param("gv(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_TELEM + && val <= MIXSRC_LAST_TELEM) { + + val -= MIXSRC_FIRST_TELEM; + uint8_t sign = val % 3; + val = val / 3; + if (!wf(opaque, "tele(", 5)) return false; + if (sign == 1) { + if (!wf(opaque, "-", 1)) return false; + } else if (sign == 2) { + if (!wf(opaque, "+", 1)) return false; + } + str = yaml_unsigned2str(val); + if (!wf(opaque, str, strlen(str))) return false; + str = closing_parenthesis; + } else { str = yaml_output_enum(val, enum_MixSources); } diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_nv14.cpp index cf510201a..0fb96eb81 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_nv14.cpp @@ -666,7 +666,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 8 ), + YAML_UNSIGNED_CUST( "source", 8, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_t12.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_t12.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_t12.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_t12.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_t8.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_t8.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_t8.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_t8.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_tlite.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_tlite.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_tlite.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_tlite.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_tx12.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_tx12.cpp index 4e08a3b50..2de1f226e 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_tx12.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_tx12.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x10.cpp index 45482c63f..1e768a088 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x10.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x12s.cpp index 027e6d428..3f43f5438 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x12s.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x7.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x7.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x7.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x7.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x9d.cpp index 1897417c3..6b4323b74 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x9d.cpp @@ -644,7 +644,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -736,19 +736,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 3, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 3, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x9e.cpp index 2ab5a5992..e7d09858a 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x9e.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -775,19 +775,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 3, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 3, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x9lite.cpp index 2c0f9653c..08f289874 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x9lite.cpp @@ -621,7 +621,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -708,19 +708,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_x9lites.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_x9lites.cpp index 76ba4a39c..1fc15f977 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_x9lites.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_x9lites.cpp @@ -631,7 +631,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -718,19 +718,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_xlite.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_xlite.cpp index e38e41470..130bed166 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_xlite.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_xlite.cpp @@ -628,7 +628,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -715,19 +715,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_xlites.cpp index fc2e0a1fa..b105ab03e 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_xlites.cpp @@ -632,7 +632,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -719,19 +719,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_bits.cpp b/radio/src/storage/yaml/yaml_bits.cpp index a53faf72e..8031c6fdf 100644 --- a/radio/src/storage/yaml/yaml_bits.cpp +++ b/radio/src/storage/yaml/yaml_bits.cpp @@ -93,35 +93,51 @@ bool yaml_is_zero(uint8_t* data, uint32_t bitoffs, uint32_t bits) return !yaml_get_bits(data + (bitoffs>>3UL), bitoffs & 0x7, bits); } -int32_t yaml_str2int(const char* val, uint8_t val_len) +int32_t yaml_str2int_ref(const char*& val, uint8_t& val_len) { bool neg = false; int i_val = 0; - - for(uint8_t i=0; i < val_len; i++) { - if (val[i] == '-') - neg = true; - else if (val[i] >= '0' && val[i] <= '9') { - i_val = i_val * 10 + (val[i] - '0'); - } + + while (val_len > 0) { + if (*val == '-') { + neg = true; + } else if (*val >= '0' && *val <= '9') { + i_val = i_val * 10 + (*val - '0'); + } else { + break; + } + val++; val_len--; } return neg ? -i_val : i_val; } -uint32_t yaml_str2uint(const char* val, uint8_t val_len) +int32_t yaml_str2int(const char* val, uint8_t val_len) +{ + return yaml_str2int_ref(val, val_len); +} + +uint32_t yaml_str2uint_ref(const char* val, uint8_t val_len) { uint32_t i_val = 0; - for(uint8_t i=0; i < val_len; i++) { - if (val[i] >= '0' && val[i] <= '9') { - i_val = i_val * 10 + (val[i] - '0'); + while(val_len > 0) { + if (*val >= '0' && *val <= '9') { + i_val = i_val * 10 + (*val - '0'); + } else { + break; } + val++; val_len--; } return i_val; } +uint32_t yaml_str2uint(const char* val, uint8_t val_len) +{ + return yaml_str2uint_ref(val, val_len); +} + static char int2str_buffer[MAX_STR] = {0}; static const char _int2str_lookup[] = { '0', '1', '2', '3', '4', '5', '6' , '7', '8', '9' }; diff --git a/radio/src/storage/yaml/yaml_bits.h b/radio/src/storage/yaml/yaml_bits.h index fd67f890d..81f462b36 100644 --- a/radio/src/storage/yaml/yaml_bits.h +++ b/radio/src/storage/yaml/yaml_bits.h @@ -30,6 +30,9 @@ uint32_t yaml_get_bits(uint8_t* src, uint32_t bit_ofs, uint32_t bits); // assumes bits is a multiple of 8 bool yaml_is_zero(uint8_t* data, uint32_t bitoffs, uint32_t bits); +int32_t yaml_str2int_ref(const char*& val, uint8_t& val_len); +uint32_t yaml_str2uint_ref(const char* val, uint8_t val_len); + int32_t yaml_str2int(const char* val, uint8_t val_len); uint32_t yaml_str2uint(const char* val, uint8_t val_len); diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index d136bfd25..1667283ce 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -70,15 +70,108 @@ static bool in_write_weight(const YamlNode* node, uint32_t val, yaml_writer_func extern const struct YamlIdStr enum_MixSources[]; +// TODO sources: parse/output +// - lua(script#,n): LUA mix outputs +// - ls(n): logical switches +// - tr(n): trainer input +// - ch(n): channels +// - gv(n): gvars +// - tele(n): telemetry +// static uint32_t r_mixSrcRaw(const YamlNode* node, const char* val, uint8_t val_len) { if (val_len > 0 && val[0] == 'I') { return yaml_str2uint(val+1, val_len-1) + MIXSRC_FIRST_INPUT; + } else if (val_len > 4 && + val[0] == 'l' && + val[1] == 'u' && + val[2] == 'a' && + val[3] == '(') { + + // parse int and ignore ',' + val += 4; val_len -= 4; + uint8_t script = yaml_str2uint(val, val_len); + + if (!val_len) return MIXSRC_NONE; + val++; val_len--; + + // parse int and ignore closing ')' + return yaml_str2uint(val, val_len) + MIXSRC_FIRST_LUA + + script * MAX_SCRIPT_OUTPUTS; + + } else if (val_len > 3 && + val[0] == 'l' && + val[1] == 's' && + val[2] == '(') { + + val += 3; val_len -= 3; + // parse int and ignore closing ')' + return yaml_str2uint(val, val_len) + MIXSRC_FIRST_LOGICAL_SWITCH; + + } else if (val_len > 3 && + val[0] == 't' && + val[1] == 'r' && + val[2] == '(') { + + val += 3; val_len -= 3; + // parse int and ignore closing ')' + return yaml_str2uint(val, val_len) + MIXSRC_FIRST_TRAINER; + + } else if (val_len > 3 && + val[0] == 'c' && + val[1] == 'h' && + val[2] == '(') { + + val += 3; val_len -= 3; + // parse int and ignore closing ')' + return yaml_str2uint_ref(val, val_len) + MIXSRC_FIRST_CH; + + } else if (val_len > 3 && + val[0] == 'g' && + val[1] == 'v' && + val[2] == '(') { + + val += 3; val_len -= 3; + // parse int and ignore closing ')' + return yaml_str2uint_ref(val, val_len) + MIXSRC_FIRST_GVAR; + + } else if (val_len > 5 && + val[0] == 't' && + val[1] == 'e' && + val[2] == 'l' && + val[3] == 'e' && + val[4] == '(') { + + val += 5; val_len -= 5; + + // parse sign + uint8_t sign = 0; + if (*val == '-') { + sign = 1; + val++; val_len--; + } else if (*val == '+') { + sign = 2; + val++; val_len--; + } + + // parse int and ignore closing ')' + return yaml_str2uint_ref(val, val_len) * 3 + sign + MIXSRC_FIRST_TELEM; } return yaml_parse_enum(enum_MixSources, val, val_len); } +static constexpr char closing_parenthesis[] = ")"; + +static bool output_source_1_param(const char* src_prefix, size_t src_len, uint32_t n, + yaml_writer_func wf, void* opaque) +{ + if (!wf(opaque, src_prefix, src_len)) return false; + const char* str = yaml_unsigned2str(n); + if (!wf(opaque, str, strlen(str))) return false; + return true; +} + static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) { const char* str = nullptr; @@ -91,6 +184,69 @@ static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf, str = yaml_unsigned2str(val - MIXSRC_FIRST_INPUT); } +#if defined(LUA_INPUTS) + else if (val >= MIXSRC_FIRST_LUA + && val <= MIXSRC_LAST_LUA) { + + if (!wf(opaque, "lua(", 4)) return false; + + val -= MIXSRC_FIRST_LUA; + uint32_t script = val / MAX_SCRIPT_OUTPUTS; + + if (!output_source_1_param("lua(", 4, script, wf, opaque)) return false; + if (!wf(opaque, ",", 1)) return false; + + val = val % MAX_SCRIPT_OUTPUTS; + str = yaml_unsigned2str(val); + + if (!wf(opaque, str, strlen(str))) return false; + str = closing_parenthesis; + } +#endif + else if (val >= MIXSRC_FIRST_LOGICAL_SWITCH + && val <= MIXSRC_LAST_LOGICAL_SWITCH) { + + val -= MIXSRC_FIRST_LOGICAL_SWITCH; + if (!output_source_1_param("ls(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_TRAINER + && val <= MIXSRC_LAST_TRAINER) { + + val -= MIXSRC_FIRST_TRAINER; + if (!output_source_1_param("tr(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_CH + && val <= MIXSRC_LAST_CH) { + + val -= MIXSRC_FIRST_CH; + if (!output_source_1_param("ch(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_GVAR + && val <= MIXSRC_LAST_GVAR) { + + val -= MIXSRC_FIRST_GVAR; + if (!output_source_1_param("gv(", 3, val, wf, opaque)) return false; + str = closing_parenthesis; + } + else if (val >= MIXSRC_FIRST_TELEM + && val <= MIXSRC_LAST_TELEM) { + + val -= MIXSRC_FIRST_TELEM; + uint8_t sign = val % 3; + val = val / 3; + if (!wf(opaque, "tele(", 5)) return false; + if (sign == 1) { + if (!wf(opaque, "-", 1)) return false; + } else if (sign == 2) { + if (!wf(opaque, "+", 1)) return false; + } + str = yaml_unsigned2str(val); + if (!wf(opaque, str, strlen(str))) return false; + str = closing_parenthesis; + } else { str = yaml_output_enum(val, enum_MixSources); } diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index cf510201a..0fb96eb81 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -666,7 +666,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 8 ), + YAML_UNSIGNED_CUST( "source", 8, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_t12.cpp b/radio/src/storage/yaml/yaml_datastructs_t12.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t12.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t12.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_t8.cpp b/radio/src/storage/yaml/yaml_datastructs_t8.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t8.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t8.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_tlite.cpp b/radio/src/storage/yaml/yaml_datastructs_tlite.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tlite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tlite.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_tx12.cpp b/radio/src/storage/yaml/yaml_datastructs_tx12.cpp index 4e08a3b50..2de1f226e 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tx12.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tx12.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 45482c63f..1e768a088 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 027e6d428..3f43f5438 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x7.cpp b/radio/src/storage/yaml/yaml_datastructs_x7.cpp index 3a4d01222..a662a0ff5 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x7.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x7.cpp @@ -636,7 +636,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -723,19 +723,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index 1897417c3..6b4323b74 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -644,7 +644,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -736,19 +736,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 3, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 3, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index 2ab5a5992..e7d09858a 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -683,7 +683,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -775,19 +775,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 3, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 3, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp index 2c0f9653c..08f289874 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp @@ -621,7 +621,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -708,19 +708,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp index 76ba4a39c..1fc15f977 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp @@ -631,7 +631,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -718,19 +718,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp index e38e41470..130bed166 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp @@ -628,7 +628,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -715,19 +715,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index fc2e0a1fa..b105ab03e 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -632,7 +632,7 @@ static const struct YamlNode struct_TrainerModuleData[] = { }; static const struct YamlNode union_ScriptDataInput_elmts[] = { YAML_SIGNED( "value", 16 ), - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode union_ScriptDataInput[] = { @@ -719,19 +719,19 @@ static const struct YamlNode struct_TelemetrySensor[] = { }; static const struct YamlNode struct_FrSkyBarData[] = { YAML_IDX, - YAML_UNSIGNED( "source", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_SIGNED( "barMin", 16 ), YAML_SIGNED( "barMax", 16 ), YAML_END }; -static const struct YamlNode struct_unsigned_16[] = { +static const struct YamlNode struct_LineDataSource[] = { YAML_IDX, - YAML_UNSIGNED( "val", 16 ), + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), YAML_END }; static const struct YamlNode struct_FrSkyLineData[] = { YAML_IDX, - YAML_ARRAY("sources", 16, 2, struct_unsigned_16, NULL), + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), YAML_END }; static const struct YamlNode struct_TelemetryScriptData[] = { diff --git a/radio/src/storage/yaml/yaml_tree_walker.cpp b/radio/src/storage/yaml/yaml_tree_walker.cpp index 792c13ccb..5fb2b0e7d 100644 --- a/radio/src/storage/yaml/yaml_tree_walker.cpp +++ b/radio/src/storage/yaml/yaml_tree_walker.cpp @@ -510,6 +510,11 @@ bool YamlTreeWalker::generate(yaml_writer_func wf, void* opaque) if (!toParent()) return true; + if (getNode()->type == YDT_UNION) { + if (!toParent()) { + return true; + } + } toNextAttr(); continue; }