09-10-2015 07:01 AM
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.
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.
09-10-2015 07:15 AM
Putting a wait between the event block and the bytes at port solved the problem!
09-10-2015 07:16 AM
09-10-2015 07:45 AM
09-10-2015 07:51 AM
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".
09-10-2015 05:59 PM
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