another try

pull/14/head
Tom Early 6 years ago
parent 46f606b727
commit a4bf2cd7d7

@ -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
}

Loading…
Cancel
Save

Powered by TurnKey Linux.