fixed a stupid decl

pull/14/head
Tom Early 6 years ago
parent 219967f800
commit 5ace689922

@ -640,25 +640,24 @@ void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod)
static unsigned int part[3] = { 0 };
static char txt[3][21];
if ((data[0] != 0x55u) || (data[1] != 0x2du) || (data[2] != 0x16u)) {
const unsigned int c[3] = {
data[0] ^ 0x70u,
data[1] ^ 0x4fu,
data[2] ^ 0x93u
const unsigned char c[3] = {
static_cast<unsigned char>(data[0] ^ 0x70u),
static_cast<unsigned char>(data[1] ^ 0x4fu),
static_cast<unsigned char>(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]+(5u*(part[mod]/2u)+2u), c, 3); // offset is 2, 7, 12 or 17
printf("c=0x%02x 0x%02x 0x%02x part[%d]=%u Msg='%s'\n", c[0], c[1], c[2], mod, part[mod], txt[mod]);
if (++part[mod] > 7) {
// we've got everything!
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]) {
printf("c=0x%02x 0x%02x 0x%02x part[%d]=%u Msg='%s'\n", c[0], c[1], c[2], mod, part[mod]-1u, txt[mod]);
memcpy(txt[mod]+(5u*sequence), c+1, 2); // got it! get the copy the two chars
} else {
part[mod] = 0; // unexpected
@ -668,7 +667,6 @@ void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod)
// start of new message
memset(txt[mod], 0, 21);
memcpy(txt[mod], c+1, 2);
printf("c=0x%02x 0x%02x 0x%02x part[%d]=%u Msg='%s'\n", c[0], c[1], c[2], mod, part[mod], txt[mod]);
part[mod] = 1;
}
} else {

Loading…
Cancel
Save

Powered by TurnKey Linux.