11-20-2017 06:29 PM
Hi Labview Experts,
I am reading a barcode label via RS232 and barcode reader send data every 8 seconds or so (presentation mode).
I have a timeout event (1000 seconds) to read RS232 port and it seems timeout event queues as many events and causes my program to repeat test several times.
I would like to disable or clear these “timeout” QUEUE events as to perform test once.
The total UUT test time is about 60 seconds, and I wonder if there is any practical solution to this issue?
Thanks,
Tstand
Solved! Go to Solution.
11-21-2017 04:01 AM
You might have programmed the read to return data up until the first "13", \r. So all the other data will remain on the serial buffer until the next time you read it. Then it will read the next data.
You need to read all data until there's nothing left. Then either use the last or read once more to get the most recent.
A parallel loop or VI that continuously reads the port might make sense...
11-21-2017 06:06 AM
@tstand wrote:
I am reading a barcode label via RS232 and barcode reader send data every 8 seconds or so (presentation mode).
Since the data is constantly being sent (even at a slow rate), I would recommend putting the reading of the serial port into a parallel loop. If you only care about the latest reading, you can use a Notifier or Global Variable to send the data to your main processing loop. If you want every reading, you should use a Queue or User Event.
Other note: DO NOT USE THE BYTES AT PORT TO DETERMINE HOW MANY BYTES TO READ!!!!!!!!!!!!!!!!!!!!!!!!!! (still now emphasized enough).
Based on your code, your instrument ends the data message with a Carriage Return (CR, 0xD, 13). You already have the VISA session set up to use this. So just tell the VISA Read to read more bytes than you expect in a message. The VISA Read will read until it reads the number of bytes you tell it, it reads the termination character, or times out. If you use the Bytes At Port like you are, you have a high risk of getting partial messages. But by telling the VISA Read to read more bytes than you expect, you are relying on that termination character and you will get the full message.
11-21-2017 08:24 AM
Hi crossrulz and wiebe,
Thanks for your input, and it looks like I have to use a parallel loop, as it does not appear to be a solution at the state machine module.
I was planning to use the barcode reader as a dual purpose: Read UUT's barcode label and start the test without pressing any keys at the front panel.
BTW, barcode label is a 12 digits long (with CR, 0xD, 13) and it will be scanned about 8 to 10 times during the duration of the test. I only need to read once, the very first, just at the start of the test, others are discarded (not needed, because scanner is programmed in presentation mode).
Thanks again,
tstand
11-21-2017 09:18 AM
tstand wrote: I only need to read once, the very first, just at the start of the test, others are discarded.
In that case, just make a state that opens the serial port, reads 1 message, and closes the port. You might want to add some logic to make sure you did not start reading in the middle of a message (try to read 20 bytes, make sure you got at least 12) and retry if your message was not complete.
11-21-2017 03:16 PM
Thanks crossrulz,
tstand