From de8f991f5a242f7554be8e3377a1f6142f534eb0 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 7 Aug 2023 20:14:49 +0100 Subject: [PATCH 1/2] Move DMR TA to t8 and t9 on the Nextion display. --- Nextion.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Nextion.cpp b/Nextion.cpp index 6df9a6d..89dc30e 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -485,11 +485,11 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, const unsigned char* talkerAli if (type[0] == ' ') { if (slotNo == 1U) { if (m_screenLayout & LAYOUT_TA_COLOUR) - sendCommand("t0.pco=33808"); + sendCommand("t8.pco=33808"); sendCommandAction(64U); } else { if (m_screenLayout & LAYOUT_TA_COLOUR) - sendCommand("t2.pco=33808"); + sendCommand("t9.pco=33808"); sendCommandAction(72U); } @@ -498,37 +498,37 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, const unsigned char* talkerAli if (slotNo == 1U) { char text[50U]; - ::sprintf(text, "t0.txt=\"1 %s %s\"", type, talkerAlias); + ::sprintf(text, "t8.txt=\"%s %s\"", type, talkerAlias); if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) - sendCommand("t0.font=3"); + sendCommand("t8.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) - sendCommand("t0.font=2"); + sendCommand("t8.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) - sendCommand("t0.font=1"); + sendCommand("t8.font=1"); } if (m_screenLayout & LAYOUT_TA_COLOUR) - sendCommand("t0.pco=1024"); + sendCommand("t8.pco=1024"); sendCommand(text); sendCommandAction(63U); } else { char text[50U]; - ::sprintf(text, "t2.txt=\"2 %s %s\"", type, talkerAlias); + ::sprintf(text, "t9.txt=\"%s %s\"", type, talkerAlias); if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) - sendCommand("t2.font=3"); + sendCommand("t9.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) - sendCommand("t2.font=2"); + sendCommand("t9.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) - sendCommand("t2.font=1"); + sendCommand("t9.font=1"); } if (m_screenLayout & LAYOUT_TA_COLOUR) - sendCommand("t2.pco=1024"); + sendCommand("t9.pco=1024"); sendCommand(text); sendCommandAction(71U); @@ -581,6 +581,7 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t1.txt=\"\""); sendCommand("t4.txt=\"\""); sendCommand("t6.txt=\"\""); + sendCommand("t8.txt=\"\""); } else { sendCommand("t2.txt=\"2 Listening\""); sendCommandAction(69U); @@ -595,6 +596,7 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t3.txt=\"\""); sendCommand("t5.txt=\"\""); sendCommand("t7.txt=\"\""); + sendCommand("t9.txt=\"\""); } } From 2c0f08e2a62d2f46e1cd86da1b6abe451263070b Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Thu, 10 Aug 2023 08:08:06 +0200 Subject: [PATCH 2/2] Fix memcpy overflow, as src and dest are 32 bytes long, only 31 bytes has to be copied, not 32, since an offset is applied to src. --- DMRTA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DMRTA.cpp b/DMRTA.cpp index 055116e..94ecbaf 100644 --- a/DMRTA.cpp +++ b/DMRTA.cpp @@ -98,7 +98,7 @@ bool CDMRTA::decodeTA() case 1U: // ISO 8 bit case 2U: // UTF8 - ::memcpy(m_ta, m_buf + 1U, sizeof(m_ta)); + ::memcpy(m_ta, m_buf + 1U, sizeof(m_ta) - 1); break; case 3U: { // UTF16 poor man's conversion