Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

First received serial messages corrupted

Hi, using NI's 2 port USB-485 converter, we are finding the first 2 or 3 messages received to our NI USB485 are corrupted. All subsequent messages received are behind by this same amount. It is as though there is garbage in a FIFO buffer after we initialize.

We are using a standard Windows API, RS422, 4 wire mode at 230k.

Thanks,

Gary Willenbring
SAIC
952-841-6732
0 Kudos
Message 1 of 5
(3,397 Views)
Is it possible that data is being transmitted to the USB-485 port before (or just as) you initialize? Data sent prior to, or during setting of the baud rate could result in "garbage" data in the FIFO.

Does flushing the input buffer after initialization clear the bad data?
0 Kudos
Message 2 of 5
(3,397 Views)
Thanks Chris. I should have mentioned the system operates on a command response mode.

When you refer to flushing the input buffer are you refering to memory on the NI USB-Serial converter or memory in our software application?

Gary
0 Kudos
Message 3 of 5
(3,397 Views)
Interesting - so you're rather certain that the port didn't receive any data prior to opening? I'm curious as to where this data is coming from since I'm fairly certain that the driver performs its own flush on open (I'll verify this).

In the meantime, the API function PurgeComm can be used to clear the read buffer. Here is a link to the MSDN description:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/purgecomm.asp
0 Kudos
Message 4 of 5
(3,397 Views)
The PurgeComm sounds like it will solve some problems for us. I added it to the code to occur after read message timeouts. Hopefully I'll be able to check it in the lab shortly.

Assuming the driver performs a data flush, what we were seeing could be the result of how we perform a BIT on powerup (ignore comm).

Thanks again for your help.

Gary
0 Kudos
Message 5 of 5
(3,397 Views)