From 63242de249de891e8a2869de6ba8370885f319f6 Mon Sep 17 00:00:00 2001 From: George Date: Sun, 19 Jul 2020 20:34:43 +1000 Subject: [PATCH 1/3] Serialsend6 * Adds serialsend6, allowing sending of binary data with comma-delimited string of decimal numbers. --- tasmota/support.ino | 11 +++++++++++ tasmota/support_command.ino | 3 +++ 2 files changed, 14 insertions(+) diff --git a/tasmota/support.ino b/tasmota/support.ino index 50cc4f920..ae42f3840 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -906,6 +906,17 @@ void SerialSendRaw(char *codes) } } +// values is a comma-delimited string: e.g. "72,101,108,108,111,32,87,111,114,108,100,33,10" +void SerialSendDecimal(char *values) +{ + char* &p; + uint8_t code; + for (str = strtok_r(values, ",", &p); str; str = strtok_r(nullptr, ",", &p)) { + code = (uint8_t)atoi(str); + Serial.write(code); + } +} + uint32_t GetHash(const char *buffer, size_t size) { uint32_t hash = 0; diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index abd75960e..5854c0ed1 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1354,6 +1354,9 @@ void CmndSerialSend(void) else if (5 == XdrvMailbox.index) { SerialSendRaw(RemoveSpace(XdrvMailbox.data)); // "AA004566" as hex values } + else if (6 == XdrvMailbox.index) { + SerialSendDecimal(XdrvMailbox.data); + } ResponseCmndDone(); } } From 8a4a0d67ff415ca59072f999a2ce1815304894d4 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 20 Jul 2020 10:08:20 +1000 Subject: [PATCH 2/3] serialsend6 - fixes Forgot to fix top condition --- tasmota/support_command.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 5854c0ed1..61a0962b4 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1334,7 +1334,7 @@ void CmndSerialConfig(void) void CmndSerialSend(void) { - if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 5)) { + if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 6)) { SetSeriallog(LOG_LEVEL_NONE); Settings.flag.mqtt_serial = 1; // CMND_SERIALSEND and CMND_SERIALLOG Settings.flag.mqtt_serial_raw = (XdrvMailbox.index > 3) ? 1 : 0; // CMND_SERIALSEND3 From 2ced749e4d48bdbdb8e0a6b7246bb8760499c9d2 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 20 Jul 2020 10:14:01 +1000 Subject: [PATCH 3/3] serialsend6 - more fixes oops --- tasmota/support.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index ae42f3840..2e36793b0 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -909,9 +909,9 @@ void SerialSendRaw(char *codes) // values is a comma-delimited string: e.g. "72,101,108,108,111,32,87,111,114,108,100,33,10" void SerialSendDecimal(char *values) { - char* &p; + char *p; uint8_t code; - for (str = strtok_r(values, ",", &p); str; str = strtok_r(nullptr, ",", &p)) { + for (char* str = strtok_r(values, ",", &p); str; str = strtok_r(nullptr, ",", &p)) { code = (uint8_t)atoi(str); Serial.write(code); }