09-26-2014 04:14 AM
Hi All,
Currently trying to debug a problem i'm having with a Labview2011 VI and USB-485/2 device.
The setup has been simplified to have port 1 wire to port 2 in a 2wire-auto configuration. As described here:
http://digital.ni.com/public.nsf/allkb/D5CC369B3E3E6F0586256D1600563245
and here:
https://decibel.ni.com/content/docs/DOC-4169
Port 1 transmits an 8 byte message using visa-write then commences a 8 byte visa-read. (contained in a 10hz timed loop)
Port 2 is configured in a simple loop using the wait for byte visa event, then visa-read 8 bytes, wired directly into visa-write.
For Port 1 data transmitted, data received and the visa-read error code are logged to disk.
The setup sucessfully transmits are receives data without loss ... so the loop back is working..
However! every now and again, an additional zero byte is read from the visa-read of port1.
Almost all port 1 visa-read operations return the "1073676294" code (The number of bytes transferred is equal to the requested input count. More data might be available) which is fine. Very occasionally though, the error code "0" is return (operation completed sucessfully). This "0" code seems to be associated with the additional byte in the receiver.
This is causing a problem because it throws the command/response pairs of the intended application out of sync.
I have tried numerous buad rates, visa-read timeouts and transmit frequencies, the problem remains. Adding a visa-flush buffer prevents the error from propogating, but does not stop it occuring and upsetting the command/response logic.
Any ideas would be appreciated.
Solved! Go to Solution.
09-26-2014 06:20 AM
Care to share your code?
If you are using the Bytes At Port property node, just stop it. You expect 8 bytes, so just read 8 bytes.
What I'm thinking is happening is you are not waiting long enough for the data to come in and when you do the Bytes At Port, it returns 0. So you read 0 bytes.
09-29-2014 05:00 AM - edited 09-29-2014 05:12 AM
Cheers Crossrulz!
I'm not using the bytes at port property, as you say, just reading the required 8 bytes. However i may have resolved this by disabling the terminator character, though I'm not sure why this would cause the result it did.
Will attach code for completeness asap.
Thanks again !
09-29-2014 06:24 AM
If you are sending true binary data (which it sounds like you are), then you should have the termination character disabled. Remember that the VISA Read will complete when the FIRST of the following happen: the desired number of characters is read, the termination character is found, there is a timeout. So if there is a 0xA in your data, that will stop the read before you would want it to.
09-29-2014 08:28 PM
code snipit for completeness..
09-30-2014 06:24 AM
Just so you know, there is no need to continuously set the instrument timeout. You can just set that with the input on the Configure Serial Port.
And this probably is not the appropriate place to use a timed loop. A normal while loop will be just fine. Just put in a 100ms wait inside of the loop. The timed loop does a lot under the hood that I'm sure you don't want.