From 258a2cd5649120dab852ab38cebbf5aa2b75f7a8 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Jun 2020 19:53:00 +0100 Subject: [PATCH] Patching YSF2P25 matching G4KLX code --- YSF2P25/Conf.cpp | 32 +++++++++++--------------------- YSF2P25/Conf.h | 12 ++++++------ YSF2P25/YSF2P25.cpp | 4 ++-- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/YSF2P25/Conf.cpp b/YSF2P25/Conf.cpp index 49eda7c..e25286b 100644 --- a/YSF2P25/Conf.cpp +++ b/YSF2P25/Conf.cpp @@ -126,7 +126,6 @@ bool CConf::read() // Remove quotes from the value size_t len = ::strlen(value); char *t; - unsigned char tokencnt = 0; if (len > 1U && *value == '"' && value[len - 1U] == '"') { value[len - 1U] = '\0'; value++; @@ -163,7 +162,7 @@ bool CConf::read() else if (::strcmp(key, "WiresXMakeUpper") == 0) m_wiresXMakeUpper = ::atoi(value) == 1; else if (::strcmp(key, "RadioID") == 0) - ::memcpy(m_ysfRadioID, value, 5); + m_ysfRadioID = value; else if (::strcmp(key, "FICHCallsign") == 0) m_fichCallSign = ::atoi(value); else if (::strcmp(key, "FICHCallMode") == 0) @@ -180,22 +179,13 @@ bool CConf::read() m_fichSQLType = ::atoi(value); else if (::strcmp(key, "FICHSQLCode") == 0) m_fichSQLCode = ::atoi(value); - else if (::strcmp(key, "DT1") == 0){ - tokencnt = 0; - while((t = strtok_r(value, ",", &value)) != NULL){ - if(tokencnt < 10){ - m_ysfDT1[tokencnt++] = atoi(t); - } - } - } - else if (::strcmp(key, "DT2") == 0){ - tokencnt = 0; - while((t = strtok_r(value, ",", &value)) != NULL){ - if(tokencnt < 10){ - m_ysfDT2[tokencnt++] = atoi(t); - } - } - } + else if (::strcmp(key, "DT1") == 0){ + while ((t = strtok_r(value, ",", &value)) != NULL) + m_ysfDT1.push_back(::atoi(t)); + } else if (::strcmp(key, "DT2") == 0){ + while ((t = strtok_r(value, ",", &value)) != NULL) + m_ysfDT2.push_back(::atoi(t)); + } else if (::strcmp(key, "Daemon") == 0) m_daemon = ::atoi(value) == 1; else if (::strcmp(key, "Debug") == 0) @@ -334,17 +324,17 @@ unsigned char CConf::getFICHSQLCode() const return m_fichSQLCode; } -unsigned char* CConf::getYsfDT1() +std::vector CConf::getYsfDT1() { return m_ysfDT1; } -unsigned char* CConf::getYsfDT2() +std::vector CConf::getYsfDT2() { return m_ysfDT2; } -char* CConf::getYsfRadioID() +std::string CConf::getYsfRadioID() { return m_ysfRadioID; } diff --git a/YSF2P25/Conf.h b/YSF2P25/Conf.h index b0556c5..d95d1c3 100644 --- a/YSF2P25/Conf.h +++ b/YSF2P25/Conf.h @@ -53,9 +53,9 @@ public: unsigned char getFICHDataType() const; unsigned char getFICHSQLType() const; unsigned char getFICHSQLCode() const; - unsigned char* getYsfDT1(); - unsigned char* getYsfDT2(); - char* getYsfRadioID(); + std::vector getYsfDT1(); + std::vector getYsfDT2(); + std::string getYsfRadioID(); bool getDaemon() const; bool getNetworkDebug() const; @@ -97,9 +97,9 @@ private: unsigned char m_fichDataType; unsigned char m_fichSQLType; unsigned char m_fichSQLCode; - unsigned char m_ysfDT1[10]; - unsigned char m_ysfDT2[10]; - char m_ysfRadioID[5]; + std::vector m_ysfDT1; + std::vector m_ysfDT2; + std::string m_ysfRadioID; bool m_daemon; bool m_networkDebug; diff --git a/YSF2P25/YSF2P25.cpp b/YSF2P25/YSF2P25.cpp index 2e2635b..966b8d9 100644 --- a/YSF2P25/YSF2P25.cpp +++ b/YSF2P25/YSF2P25.cpp @@ -636,7 +636,7 @@ int CYSF2P25::run() unsigned char csd1[20U], csd2[20U]; memset(csd1, '*', YSF_CALLSIGN_LENGTH/2); - memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2); + memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2); memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH); memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH); @@ -676,7 +676,7 @@ int CYSF2P25::run() unsigned char csd1[20U], csd2[20U]; memset(csd1, '*', YSF_CALLSIGN_LENGTH/2); - memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2); + memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2); memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH); memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);