diff --git a/companion/src/firmwares/edgetx/yaml_moduledata.cpp b/companion/src/firmwares/edgetx/yaml_moduledata.cpp index 2d2126fd7..1064ef692 100644 --- a/companion/src/firmwares/edgetx/yaml_moduledata.cpp +++ b/companion/src/firmwares/edgetx/yaml_moduledata.cpp @@ -275,8 +275,10 @@ Node convert::encode(const ModuleData& rhs) Node pxx2; pxx2["receivers"] = rhs.access.receivers; pxx2["racingMode"] = rhs.access.racingMode; - for (int i=0; i<(int)rhs.access.receivers; i++) { - pxx2["receiverName"][std::to_string(i)] = rhs.access.receiverName[i]; + for (int i=0; i < PXX2_MAX_RECEIVERS_PER_MODULE; i++) { + if (rhs.access.receivers & (1 << i)) { + pxx2["receiverName"][std::to_string(i)]["val"] = rhs.access.receiverName[i]; + } } mod["pxx2"] = pxx2; } break; @@ -411,8 +413,15 @@ bool convert::decode(const Node& node, ModuleData& rhs) Node pxx2 = mod["pxx2"]; pxx2["receivers"] >> rhs.access.receivers; pxx2["racingMode"] >> rhs.access.racingMode; - for (const auto& rx : pxx2["receiverName"]) { - rx >> rhs.access.receiverName; + for (int i=0; i < PXX2_MAX_RECEIVERS_PER_MODULE; i++) { + if (pxx2["receiverName"][std::to_string(i)]) { + Node rcvrname = pxx2["receiverName"][std::to_string(i)]; + if (rcvrname.IsMap()) { + if (rcvrname["val"]) { + rcvrname["val"] >> rhs.access.receiverName[i]; + } + } + } } } else if (mod["ghost"]) { Node ghost = mod["ghost"];