FIX: slave device online status not detected

This commit is contained in:
cyp0633 2022-08-29 10:53:35 +08:00
parent cd355f8c3f
commit e7713498ec
Signed by: cyp0633
GPG Key ID: CF90D09FB1FDCE45
1 changed files with 6 additions and 5 deletions

11
main.c
View File

@ -25,10 +25,10 @@ void uart1Process()
buf3[1] = DEVICE_SPECIAL_PROTOCOL;
buf3[2] = KEY_TEST_CONNECTION;
buf3[3] = KEY_ACTION_CONNECTION_OK;
buf3[4] = ((onlineStatus >> 0) & 0x01) << 1 || ((onlineStatus >> 1) & 0x01); // board 1 & 2
buf3[5] = ((onlineStatus >> 2) & 0x01) << 1 || ((onlineStatus >> 3) & 0x01); // board 3 & 4
buf3[6] = ((onlineStatus >> 4) & 0x01) << 1 || ((onlineStatus >> 5) & 0x01); // board 5 & 6
buf3[7] = ((onlineStatus >> 6) & 0x01) << 1 || ((onlineStatus >> 7) & 0x01); // board 7 & 8
buf3[4] = onlineStatus;
buf3[5] = 0x00;
buf3[6] = 0x00;
buf3[7] = 0x00;
break;
}
Uart1Print(buf3, 8);
@ -59,7 +59,8 @@ void uart2Process()
buf3[5] = 0x00;
buf3[6] = 0x00;
buf3[7] = 0x00;
onlineStatus = onlineStatus || (1 << (buf2[4] - 1));
// set the buf2[4]-th bit of onlineStatus to 1
onlineStatus |= (0x01 << (buf2[4] - 1));
Uart2Print(buf3, 8);
#ifdef DEBUG
Uart1Print(&onlineStatus, 1);