-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslave.h
24 lines (22 loc) · 1.04 KB
/
slave.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
//
// ----------- slave simulation -------------------------------------------
//
//
void slave() {
lprintf("Slave loop\n");
memcpy(errorsDB_backup, errorsDB, sizeof(errorsDB_backup)); // backup error DB
retCode = check4msg(SlaveMsgChannel, slaveAdr, NO_TIMEOUT); // message if available will stored in global rcvMSG variable
if(retCode == MSG_READY) { // ERR_OK (0)- no message, ERR_RCV_MSG (<0) -parsing error, MSG_READY (1)- message present
slaveProcessCmd(rcvMsg);
} // if retCode
else if(retCode != ERR_OK)
ErrWrite(ERR_WARNING, "Slave rcv cmd err");
// no message available for processing
// do something usefull like take a nap or read ADC and process the zones info
// or collect some errors info to be send as status to MASTER some day
convertZones(SzoneDB, SLAVE_ZONES_CNT, SzoneResult);
// find out if some new errors occured while receiving/processing the message
if(memcmp(errorsDB, errorsDB_backup, sizeof(errorsDB)))
printNewErrors();
}