05-24-2011 11:15 AM
Hi all, thanks in advance for any help!
I am currently using a UDP connection to communicate with a device. This device requires several messages to be sent to it, to which it has several responses. The size (number of packets) in each response depends on the message sent. Trying to program this in LabView in a program flow kinda way (send first message --> recieve first repsonse --> send second message -->... etc.) fails because I end up missing packets if my program runs faster than the device.
To fix this, I am trying to write an event driven program, where messages are sent to the device, and a listener is constantly waiting for something to come back. The recieved messages are parsed and handled, and the program goes back the beginning and executes again. The problem is: Labview does not seem to have any support for UDP event driven programming (the only VIs are UDP open, read,write,and close), and trying to mock up my own event driven program by constantly polling the device (a UPD read command inside a while loop) throws all sorts of errors, because LabView does not allow you to read and write over the same UDP connection at the same time (from two different asynchronous loops).
Has anyone handled this sort of thing before? It seems like this is something that would come a lot in UDP communication...
Thanks,
-Dylan
05-24-2011 11:41 AM
You mentioned that your device that you are communicating with is essentially a command/response device. So, where are you loosing data if you write your application to support this. Is the device capable of processing multiple commands simultaneously? This is in effect what you are suggesting to do. Send commands back to back and read responses in parralel. It would seem to me that a new command should not be sent until you have received the complete response from the previous command.
We have written code though that can perform what appears to be asychronous reads/and writes on a single interface. It uses a state machine to switch between reads and writes. Data that is read is queued to another task for processing.
Are you able to post your code or an example of what you are trying to do? This would help in offering suggestions.