Hardware Reference
In-Depth Information
whether it should move on to the next packet or resend the last. Once all three sensors have been sent, the program
starts sending the next data position in the array. All three of the sensor's data packets could be sent in one packet, but
for this demonstration they are split up to represent different nodes.
Listing 8-1. testApp.cpp, Part 2 of 7
void testApp::update(){
unsigned char DatatoSend[3] ;
if (counts == 500){
printf ("sensor 1 \n");
DatatoSend[0] = 'S';
DatatoSend[1] = '1';
DatatoSend[2] = point;
DatatoSend[3] = graph[point];
CreatePacket(DatatoSend, 4);
WaitForReply();
SensorsSent [0] = true;
}
if (counts == 1000){
printf ("sensor 2 \n");
DatatoSend[0] = 'S' ;
DatatoSend[1] = '2' ;
DatatoSend[2] = point;
DatatoSend[3] = graph1[point] ;
CreatePacket(DatatoSend , 4 );
WaitForReply();
SensorsSent [1] = true;
}
if (counts == 1500){
printf ("sensor 3 \n");
DatatoSend[0] = 'S';
DatatoSend[1] = '3';
DatatoSend[2] = point;
DatatoSend[3] = graph2[point] ;
CreatePacket(DatatoSend , 4 );
WaitForReply();
SensorsSent [2] = true;
}
if (SensorsSent [0] == true && SensorsSent [1] == true && SensorsSent [2] == true){
printf ("reset counts move point \n");
counts = 0;
point++;
SensorsSent [0] = false;
SensorsSent [1] = false;
SensorsSent [2] = false;
}
counts++;
CheckForIncoming();
} // end testApp::update()
 
Search WWH ::




Custom Search