I want to control multiple robots using my laptop. Robots do not have intelligence, they are sending sensor values to PC which computes the sensors values and sends back result to robots.(Centralized control of robots using PC ).
Robots are communicating with PC through serial communication using Zigbee mudule.
Problem: How to make & send a structure (from robot) like {sen1, sen2,sen3..,robot id} where sen1, sen2..are sensors values and robot id is to recognize particular robot. After editing..... The code I was using for sending sensors was like.
void TxData(unsigned char tx_data)
{ SBUF = tx_data; //Transmit data that is passed to this function
while(TI == 0); //wait while data is being transmitted
}
and then sending sensor values one by one
TxData(left_whiteline_sensor);
TI=0; // resetting transmit interrupt after each character
TxData(middle_whiteline_sensor);
TI=0;
TxData(right_whiteline_sensor);
TI=0;
TxData(front_sharp_sensor);
TI=0;
At PC end reading these values in buffer
read(fd, buf1, sizeof(buf1));
.....
options.c_cc[VMIN]=4; // wait till not getting 4 values
This was working fine when there was only one robot, now as we have multiple robots and each robot is sending data using above function, I am getting mixed sensor values of all robots of at PC end. One solution is to make a structure which I mentioned above and send it to PC. This is what I want to ask "How to make and send such a structure" Sorry for not framing question correctly before.
Thanks...