08-18-2007 04:08 AM
08-18-2007 07:55 AM
08-19-2007 06:49 PM
08-19-2007 11:03 PM - edited 08-19-2007 11:03 PM
Try putting a small wait (perhaps 100ms, you may want to experiment) between your VISA write and your read Loop subVI in the main program, or at the beginning of your subVI before you start the read loop.
What I think is happening:
You issue a write command, the data goes out of the serial port. It takes a small amount of time for the device to get the message and begin to transmit the response. Before the response begins, your sub VI runs. Since no data has yet hit the input buffer (bytes at port =0), the subVI ends and you have no data the first time. Next time you execute, the device has since returned data from the previous execution and put it in the serial port buffer, the subVI runs and collects this data out of the buffer.
Alsom you may want to put a small wait statement inside the loop inside your Read Loop subVI. Without it, the loop runs as fast as possible and there is a slight chance (which would increase with slower baud rates), that the bytes in buffer could equal zero if it happens to check the buffer before the next byte has arrived.
Message Edited by Ravens Fan on 08-20-2007 12:09 AM
08-20-2007 03:57 AM
Thanks for your suggestions. It seems work.