From 23738d97f60e5e7834067f4352c4ff35cd56bdc3 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 21 Apr 2016 14:01:53 +0200 Subject: [PATCH 1/2] Change variable types for strings used in writeDMR --- DMRSlot.cpp | 6 +++--- Display.h | 2 +- HD44780.cpp | 22 +++++++++++----------- HD44780.h | 2 +- Nextion.cpp | 14 +++++++------- Nextion.h | 2 +- NullDisplay.cpp | 2 +- NullDisplay.h | 2 +- TFTSerial.cpp | 14 +++++++------- TFTSerial.h | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index f40b3cb..505a9bf 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -178,7 +178,7 @@ void CDMRSlot::writeModem(unsigned char *data) if (m_netState == RS_NET_IDLE) { setShortLC(m_slotNo, m_rfLC->getDstId(), m_rfLC->getFLCO(), true); - m_display->writeDMR(m_slotNo, src.c_str(), m_rfLC->getFLCO() == FLCO_GROUP, dst.c_str(), "R"); + m_display->writeDMR(m_slotNo, src, m_rfLC->getFLCO() == FLCO_GROUP, dst, "R"); } LogMessage("DMR Slot %u, received RF voice header from %s to %s%s", m_slotNo, src.c_str(), m_rfLC->getFLCO() == FLCO_GROUP ? "TG " : "", dst.c_str()); @@ -288,7 +288,7 @@ void CDMRSlot::writeModem(unsigned char *data) if (m_netState == RS_NET_IDLE) { setShortLC(m_slotNo, dstId, gi ? FLCO_GROUP : FLCO_USER_USER, false); - m_display->writeDMR(m_slotNo, src.c_str(), gi, dst.c_str(), "R"); + m_display->writeDMR(m_slotNo, src, gi, dst, "R"); } LogMessage("DMR Slot %u, received RF data header from %s to %s%s, %u blocks", m_slotNo, src.c_str(), gi ? "TG ": "", dst.c_str(), m_rfFrames); @@ -550,7 +550,7 @@ void CDMRSlot::writeModem(unsigned char *data) if (m_netState == RS_NET_IDLE) { setShortLC(m_slotNo, m_rfLC->getDstId(), m_rfLC->getFLCO(), true); - m_display->writeDMR(m_slotNo, src.c_str(), m_rfLC->getFLCO() == FLCO_GROUP, dst.c_str(), "R"); + m_display->writeDMR(m_slotNo, src, m_rfLC->getFLCO() == FLCO_GROUP, dst, "R"); } LogMessage("DMR Slot %u, received RF late entry from %s to %s%s", m_slotNo, src.c_str(), m_rfLC->getFLCO() == FLCO_GROUP ? "TG " : "", dst.c_str()); diff --git a/Display.h b/Display.h index 61dcb6e..5dfdb32 100644 --- a/Display.h +++ b/Display.h @@ -36,7 +36,7 @@ public: virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) = 0; virtual void clearDStar() = 0; - virtual void writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type) = 0; + virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0; virtual void clearDMR(unsigned int slotNo) = 0; virtual void writeFusion(const char* source, const char* dest) = 0; diff --git a/HD44780.cpp b/HD44780.cpp index dcd55dd..e581b94 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -210,10 +210,10 @@ void CHD44780::clearDStar() } } -void CHD44780::writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type) +void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src != NULL); - assert(dst != NULL); + assert(src.c_str() != NULL); + assert(dst.c_str() != NULL); assert(type != NULL); if (!m_dmr) { @@ -262,44 +262,44 @@ void CHD44780::writeDMR(unsigned int slotNo, const char* src, bool group, const if (m_rows == 2U && m_cols == 16U) { char buffer[16U]; if (slotNo == 1U) { - ::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s > %s%s", src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 0); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); } else { - ::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s > %s%s", src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else if (m_rows == 4U && m_cols == 16U) { char buffer[16U]; if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); } else { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 2); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else if (m_rows == 4U && m_cols == 20U) { char buffer[20U]; if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); } else { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 2); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else if (m_rows == 2U && m_cols == 40U) { char buffer[40U]; if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 0); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); } else { - ::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst); + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } diff --git a/HD44780.h b/HD44780.h index 1815088..395e359 100644 --- a/HD44780.h +++ b/HD44780.h @@ -50,7 +50,7 @@ public: virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStar(); - virtual void writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type); + virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); virtual void clearDMR(unsigned int slotNo); virtual void writeFusion(const char* source, const char* dest); diff --git a/Nextion.cpp b/Nextion.cpp index 4113be5..d0d24f1 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -125,10 +125,10 @@ void CNextion::clearDStar() sendCommand("t1.txt=\"\""); } -void CNextion::writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type) +void CNextion::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src != NULL); - assert(dst != NULL); + assert(src.c_str() != NULL); + assert(dst.c_str() != NULL); assert(type != NULL); if (m_mode != MODE_DMR) { @@ -143,18 +143,18 @@ void CNextion::writeDMR(unsigned int slotNo, const char* src, bool group, const if (slotNo == 1U) { char text[30U]; - ::sprintf(text, "t0.txt=\"1 %s %s\"", type, src); + ::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str()); sendCommand(text); - ::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst); + ::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str()); sendCommand(text); } else { char text[30U]; - ::sprintf(text, "t2.txt=\"2 %s %s\"", type, src); + ::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str()); sendCommand(text); - ::sprintf(text, "t3.txt=\"%s%s\"", group ? "TG" : "", dst); + ::sprintf(text, "t3.txt=\"%s%s\"", group ? "TG" : "", dst.c_str()); sendCommand(text); } diff --git a/Nextion.h b/Nextion.h index 1ad11e9..d19b26a 100644 --- a/Nextion.h +++ b/Nextion.h @@ -41,7 +41,7 @@ public: virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStar(); - virtual void writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type); + virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); virtual void clearDMR(unsigned int slotNo); virtual void writeFusion(const char* source, const char* dest); diff --git a/NullDisplay.cpp b/NullDisplay.cpp index b02fad4..59186a6 100644 --- a/NullDisplay.cpp +++ b/NullDisplay.cpp @@ -51,7 +51,7 @@ void CNullDisplay::clearDStar() { } -void CNullDisplay::writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type) +void CNullDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { } diff --git a/NullDisplay.h b/NullDisplay.h index 27f6331..9e2f153 100644 --- a/NullDisplay.h +++ b/NullDisplay.h @@ -39,7 +39,7 @@ public: virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStar(); - virtual void writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type); + virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); virtual void clearDMR(unsigned int slotNo); virtual void writeFusion(const char* source, const char* dest); diff --git a/TFTSerial.cpp b/TFTSerial.cpp index 055a3df..8975fdf 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -188,10 +188,10 @@ void CTFTSerial::clearDStar() displayText(" "); } -void CTFTSerial::writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type) +void CTFTSerial::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src != NULL); - assert(dst != NULL); + assert(src.c_str() != NULL); + assert(dst.c_str() != NULL); assert(type != NULL); if (m_mode != MODE_DMR) { @@ -215,21 +215,21 @@ void CTFTSerial::writeDMR(unsigned int slotNo, const char* src, bool group, cons if (slotNo == 1U) { char text[30U]; - ::sprintf(text, "1 %s %s", type, src); + ::sprintf(text, "1 %s %s", type, src.c_str()); gotoPosPixel(5U, 55U); displayText(text); - ::sprintf(text, "%s%s", group ? "TG" : "", dst); + ::sprintf(text, "%s%s", group ? "TG" : "", dst.c_str()); gotoPosPixel(65U, 72U); displayText(text); } else { char text[30U]; - ::sprintf(text, "2 %s %s", type, src); + ::sprintf(text, "2 %s %s", type, src.c_str()); gotoPosPixel(5U, 90U); displayText(text); - ::sprintf(text, "%s%s", group ? "TG" : "", dst); + ::sprintf(text, "%s%s", group ? "TG" : "", dst.c_str()); gotoPosPixel(65U, 107U); displayText(text); } diff --git a/TFTSerial.h b/TFTSerial.h index cbc5fad..9147cef 100644 --- a/TFTSerial.h +++ b/TFTSerial.h @@ -41,7 +41,7 @@ public: virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStar(); - virtual void writeDMR(unsigned int slotNo, const char* src, bool group, const char* dst, const char* type); + virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); virtual void clearDMR(unsigned int slotNo); virtual void writeFusion(const char* source, const char* dest); From d4e2b5f77efc6eee9f81bbc59fe86ba94ef34039 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 21 Apr 2016 15:46:18 +0200 Subject: [PATCH 2/2] Delete unneeded asserts --- HD44780.cpp | 3 --- Nextion.cpp | 3 --- TFTSerial.cpp | 3 --- 3 files changed, 9 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index e581b94..79e2e19 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -44,7 +44,6 @@ m_dmr(false) { assert(rows > 1U); assert(cols > 15U); - assert(callsign.c_str() != NULL); } CHD44780::~CHD44780() @@ -212,8 +211,6 @@ void CHD44780::clearDStar() void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src.c_str() != NULL); - assert(dst.c_str() != NULL); assert(type != NULL); if (!m_dmr) { diff --git a/Nextion.cpp b/Nextion.cpp index d0d24f1..290606b 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -30,7 +30,6 @@ m_serial(port, SERIAL_9600), m_brightness(brightness), m_mode(MODE_IDLE) { - assert(callsign.c_str() != NULL); assert(brightness >= 0U && brightness <= 100U); } @@ -127,8 +126,6 @@ void CNextion::clearDStar() void CNextion::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src.c_str() != NULL); - assert(dst.c_str() != NULL); assert(type != NULL); if (m_mode != MODE_DMR) { diff --git a/TFTSerial.cpp b/TFTSerial.cpp index 8975fdf..8b413c1 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -51,7 +51,6 @@ m_serial(port, SERIAL_9600), m_brightness(brightness), m_mode(MODE_IDLE) { - assert(callsign.c_str() != NULL); assert(brightness >= 0U && brightness <= 100U); } @@ -190,8 +189,6 @@ void CTFTSerial::clearDStar() void CTFTSerial::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { - assert(src.c_str() != NULL); - assert(dst.c_str() != NULL); assert(type != NULL); if (m_mode != MODE_DMR) {