From fdbf97b1c605a2a477e5d163f09559bc8a0ccbcd Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sat, 2 Jul 2016 22:56:22 +0100 Subject: [PATCH 1/6] Fix DMR unable to log into master due to locale issues When system locale used commas as decimal points, writeConfig() was sending an invalid config string to the master. --- DMRIPSC.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index 4bad24b..db72784 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -466,6 +466,7 @@ bool CDMRIPSC::writeConfig() ::memcpy(buffer + 0U, "RPTC", 4U); ::memcpy(buffer + 4U, m_id, 4U); + setlocale(LC_ALL,"C"); ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(), m_description.c_str(), slots, m_url.c_str(), m_version, software); From c97f9d4801b4c4363a6f73d478af575dd40ef9b8 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Sat, 2 Jul 2016 23:48:00 +0100 Subject: [PATCH 2/6] Fix date/time formats broken with login fix --- DMRIPSC.cpp | 2 +- HD44780.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index db72784..eddf37c 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -466,7 +466,7 @@ bool CDMRIPSC::writeConfig() ::memcpy(buffer + 0U, "RPTC", 4U); ::memcpy(buffer + 4U, m_id, 4U); - setlocale(LC_ALL,"C"); +// setlocale(LC_ALL,"C"); ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(), m_description.c_str(), slots, m_url.c_str(), m_version, software); diff --git a/HD44780.cpp b/HD44780.cpp index c900b33..23f44c4 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -752,7 +752,7 @@ void CHD44780::clockInt(unsigned int ms) Time = localtime(¤tTime); } - setlocale(LC_ALL,""); + setlocale(LC_TIME,""); strftime(m_buffer1, 128, "%X", Time); // Time strftime(m_buffer2, 128, "%x", Time); // Date From c0bb3cdc205bb09f3d5bc1adfeed7c7f0d295b99 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Sat, 2 Jul 2016 23:50:33 +0100 Subject: [PATCH 3/6] Remove code no longer needed after applying fixes --- DMRIPSC.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index eddf37c..4bad24b 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -466,7 +466,6 @@ bool CDMRIPSC::writeConfig() ::memcpy(buffer + 0U, "RPTC", 4U); ::memcpy(buffer + 4U, m_id, 4U); -// setlocale(LC_ALL,"C"); ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(), m_description.c_str(), slots, m_url.c_str(), m_version, software); From b565400b2437118df3a3727744bfe993d9f653a2 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 3 Jul 2016 00:14:31 +0100 Subject: [PATCH 4/6] Propagate locale fix to Nextion displays --- Nextion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nextion.cpp b/Nextion.cpp index 4d74c38..3a36803 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -246,7 +246,7 @@ void CNextion::clockInt(unsigned int ms) else Time = ::localtime(¤tTime); - setlocale(LC_ALL,""); + setlocale(LC_TIME,""); char text[50U]; strftime(text, 50, "t2.txt=\"%x %X\"", Time); sendCommand(text); From 3da7ebe085989447a28bee6b33109900e71a7649 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 3 Jul 2016 10:03:50 +0100 Subject: [PATCH 5/6] Fix blacklist hit causing crash --- DMRSlot.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index aaf461c..354c3d4 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -801,13 +801,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = m_netLC->getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } @@ -873,13 +873,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = m_netLC->getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } @@ -914,14 +914,14 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = m_netLC->getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); writeEndNet(); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); writeEndNet(); return; } @@ -983,13 +983,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = dataHeader.getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } @@ -1037,13 +1037,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = dmrData.getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } @@ -1144,13 +1144,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = m_netLC->getDstId(); if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } @@ -1215,13 +1215,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // - G7RZU unsigned int did = dstId; if (DstIdBlacklist(did, m_slotNo)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG blacklisted)", m_slotNo, did); return; } // true sets allow greater than 4k. Need to add boolean in conf for this later. if (!DstIdWhitelist(did, m_slotNo, true)) { - LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist) dataType: %s", m_slotNo, did, dataType); + LogMessage("DMR Slot %u, invalid traffic to TG%u (TG not in whitelist)", m_slotNo, did); return; } From 48c273814cce9b7b87e706a4a9631fd491fdc384 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 3 Jul 2016 10:20:32 +0100 Subject: [PATCH 6/6] More fixes to black/white list behaviour --- DMRSlot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 354c3d4..b120336 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -1516,11 +1516,12 @@ bool CDMRSlot::DstIdWhitelist(unsigned int did, unsigned int slot, bool gt4k) return true; // No reflectors on slot1, so we only allow all IDs over 99999 unless specifically whitelisted. + //Allow traffic to TG0 as I think this is a special case - need to confirm if (gt4k) { - if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did >= 99999U) + if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did >= 99999U || did == 0) return true; } else { - if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end()) + if (std::find(m_dstWhiteListSlot1.begin(), m_dstWhiteListSlot1.end(), did) != m_dstWhiteListSlot1.end() || did == 0) return true; } } else {