...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// Array in size of process-image
uint8_t abRecvData[27] = {0};
uint8_t abSendData[22] = {0};
...
...
...
// Set flags of header-states
abSendData[0] = 0x80;
abSendData[1] = 0x80;
abSendData[2] = 0x80;
abSendData[3] = 0x80;
// Do I/O data exchange until a key is hit
while(!kbhit())
{
if(CIFX_NO_ERROR != xChannelIORead(hChannel, 0, 0, sizeof(abRecvData), abRecvData, IO_WAIT_TIMEOUT)){
// ERROR reading IO Data area!
...
}
// Consumer-states for incomming data-slots - set to GOOD-Flag when all data could be received completely in
// in the consumer states in the outgoing image
abSendData[4] = 0x80;
abSendData[8] = 0x80;
// check if provider flags from node are GOOD-Flag...
if(abRecvData[8] != 0x80 || abRecvData[26] != 0x80){
// Provider status are BAD ... data from node are not persistent
...
}
// check if consumer reports a successful recaiption of the process data
if(abRecvData[9] != 0x80 || abRecvData[27] != 0x80){
// Cosumer status are BAD ... data could not receive correct from node
...
}
// Handle I/O data-arrays
... = abRecvData[/* {x: 4 .. 7 } */];
... = abRecvData[/* {x: 10 .. 25 } */];
abSendData[/* {x: 5, 6 } */] = ...
abSendData[/* {x: 9 .. 20 } */] = ...
// Provider-states for all outging data-slots - set to GOOD-Flag
abSendData[7] = 0x80;
abSendData[21] = 0x80;
if(CIFX_NO_ERROR != xChannelIOWrite(hChannel, 0, 0, sizeof(abSendData), abSendData, IO_WAIT_TIMEOUT)){
// ERROR writing IO data area!
...
}
...
}
|
...