07-09-2014 07:41 AM - edited 07-09-2014 07:44 AM
If you see my protocol then *B$ I need to send using COM1 and from COM2 I need to read *BOK$....Again in the next command I need *Dc1$ from COM2 and *DOK$ from COM1.. again in next I need to change the COM ports
Now its not good as per me to use 4 while loops.
What say?
07-09-2014 08:13 AM
@Ranjeet_Singh wrote:
If you see my protocol then *B$ I need to send using COM1 and from COM2 I need to read *BOK$....Again in the next command I need *Dc1$ from COM2 and *DOK$ from COM1.. again in next I need to change the COM ports
Now its not good as per me to use 4 while loops.
What say?
Since it seems like a "laundry list" of things to do, maybe you would use some kind of state machine to process your commands and responses.
07-09-2014 08:41 AM
@Ranjeet_Singh wrote:
If you see my protocol then *B$ I need to send using COM1 and from COM2 I need to read *BOK$....Again in the next command I need *Dc1$ from COM2 and *DOK$ from COM1.. again in next I need to change the COM ports
Now its not good as per me to use 4 while loops.
What say?
Nothing wrong with having another loop that works as a state machine that sends the commands around and reads data from a queue.
But based on what you just showed, I would just make a simple state machine.