From 5ce41bd91eeee7a75784f838f420384c99764ddc Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Mon, 4 Sep 2023 14:11:20 +1000 Subject: [PATCH] fix(cpn): Custom fumction filename length (#3930) --- .../firmwares/edgetx/yaml_customfunctiondata.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp index d8ec947bb30..a3227a696b7 100644 --- a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp +++ b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp @@ -21,6 +21,7 @@ #include "yaml_customfunctiondata.h" #include "yaml_rawswitch.h" #include "yaml_rawsource.h" +#include "eeprominterface.h" static bool fnHasEnable(AssignFunc fn) { @@ -164,8 +165,12 @@ Node convert::encode(const CustomFunctionData& rhs) def += std::to_string(rhs.param); break; case FuncPlayPrompt: + case FuncBackgroundMusic: { + std::string temp(rhs.paramarm); + temp.resize(getCurrentFirmware()->getCapability(VoicesMaxLength)); + def += temp; + } break; case FuncPlayScript: - case FuncBackgroundMusic: def += std::string(rhs.paramarm); break; case FuncReset: @@ -285,11 +290,16 @@ bool convert::decode(const Node& node, } catch(...) {} } break; case FuncPlayPrompt: - case FuncPlayScript: case FuncBackgroundMusic: { std::string file_str; getline(def, file_str, ','); - strncpy(rhs.paramarm, file_str.c_str(), sizeof(rhs.paramarm)-1); + file_str.resize(getCurrentFirmware()->getCapability(VoicesMaxLength)); + strncpy(rhs.paramarm, file_str.c_str(), sizeof(rhs.paramarm) - 1); + } break; + case FuncPlayScript: { + std::string file_str; + getline(def, file_str, ','); + strncpy(rhs.paramarm, file_str.c_str(), sizeof(rhs.paramarm) - 1); } break; case FuncReset: { std::string rst_str;