From a4bf2cd7d7129130de6b31571cbb73ddc9dba2b0 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Mon, 30 Mar 2020 13:38:56 -0700 Subject: [PATCH] another try --- QnetGateway.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/QnetGateway.cpp b/QnetGateway.cpp index 9abf758..74bd989 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -639,22 +639,26 @@ void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod) { static unsigned int part[3] = { 0 }; static char txt[3][21]; - if ((data[0] != 0x55) || (data[1] != 0x2d) || (data[2] != 0x16)) { - const unsigned int c[3] = { (unsigned char)(data[0] ^ 0x70u), (unsigned char)(data[1] ^ 0x4fu), (unsigned char)(data[2] ^ 0x93u) }; // unscramble + if ((data[0] != 0x55u) || (data[1] != 0x2du) || (data[2] != 0x16u)) { + const unsigned int c[3] = { + data[0] ^ 0x70u, + data[1] ^ 0x4fu, + data[2] ^ 0x93u + }; // unscramble if (part[mod]) { // we are in a message if (part[mod] % 2) { // true when part[mod] = 1, 3, 5 or 7 // this is the second part of the 2-frame pair - memcpy(txt[mod]+5*(part[mod]/2)+2, c, 3); + memcpy(txt[mod]+(5*(part[mod]/2)+2), c, 3); if (++part[mod] > 7) { // we've got everything! - printf("Msg = %s\n", txt[mod]); + printf("Msg = '%s'\n", txt[mod]); part[mod] = 0; // now we can start over } } else { // we'll get here when part[mod] = 2, 4 or 6 unsigned int sequence = part[mod]++ / 2; // this is the sequency we are expecting, 1, 2 or 3 if ((sequence | 0x40u) == c[0]) { - memcpy(txt[mod]+5*sequence, c+1, 2); // got it! get the copy the two chars + memcpy(txt[mod]+(5*sequence), c+1, 2); // got it! get the copy the two chars } else { part[mod] = 0; // unexpected }