LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port event

I have a device that outputs its measurement data on a serial port at a fixed. I could make a reading at a fixed rate. But I want to try events. But it is not working as expected. In debug mode it works, I get three 3 lines per read. But in normal mode it doesn't work, I get paritial strings.

serial events.png

I get 97 a 8 characters and sometimes 104.  With the flush I would expect that the buffer is cleared an it waits on a whole new line.

 

Error -1073807252 occurred at VISA Read in Untitled 1, VISA:  (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

 

0 Kudos
Message 1 of 6
(4,806 Views)

Putting a wait between the event block and the bytes at port solved the problem!

0 Kudos
Message 2 of 6
(4,796 Views)
It appears far too complicated. With the termination character enabled, all that you need inside the loop is a VISA Read. None of the events, flushes, bytes at serial port, the wait, etc. You simply aren't keeping up so you get that error.
Message 3 of 6
(4,792 Views)
Adding a fixed wait is just adding more bad code to what you already have.
0 Kudos
Message 4 of 6
(4,779 Views)

I'm with Dennis, it is way too complicated.

 

Here is the setup I use for receiving random messages from a serial instrument (found here)

Note: In the 0 case, I have a wait to keep this loop from being "greedy".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(4,772 Views)

I'm with Dennis.  Serial events are almost never a go-to VISA feature.  If your device sends a termination character, you setup the VISA reference once, and call VISA read with an appropriate timeout, typically in a loop.  Done.

 

In my experience, code complexities only arise when you're dealing with serial protocols where there is no simple termination character (and unfortunately I've had to deal with plenty of those over the years).  Each pattern is unique, but they typically involve most of the following: the VISA how-many-bytes-at-port property, string appends, shift registers, match patterns, and a bunch of glue logic.  <dreammode>If only VISA had some kind of built-in regular expression message termination support.</dreammode>

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 6 of 6
(4,731 Views)