Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA receiver problems

As I understand it so far, VISA's serial port receiver lacks the flexibility available to Win32 API programmers, namely intercharacter timeouts (ReadInterval), first character timeout (ReadConstant), etc. If the received messages are of unknown length, then the receiver behavior is indeterminate. Especially troublesome is characters left over in the buffer from previously received messages. Either I am overlooking something, or LabVIEW needs a better serial port driver, implemented probably as a Call Library Function Node serving a set of VIs. I've been thinking about writing one, but I don't want to re-invent that wheel if one already exists. Does it?
0 Kudos
Message 1 of 6
(4,012 Views)
I'm not sure what ReadInterval and ReadConstant do. There is a VISA property called Timeout that is used to set the maximum time a VISA Read operation will take. For messages of unknown length, there is VISA Bytes at Serial Port. This is a VISA property that I use all of the time by feeding its output to the byte counbt input of VISA Read. There is also the function VISA Flush I/O Buffer on Instrument I/>VISA>VISA Advanced>Interface Specific palette.
0 Kudos
Message 2 of 6
(4,012 Views)
ReadInterval and ReadConstant are explained in MSDN, which is meaningful to Win32 API programmers. The explanation causes eyes to glaze over, especially on Friday afternoon.
0 Kudos
Message 3 of 6
(4,012 Views)
Having had some time now to think about your answer, I think I should do this, perhaps in a sequence: VISA Flush, VISA Write, wait some time, feed BytesAtSerialPort into VISA Read. You think that will fly?
0 Kudos
Message 4 of 6
(4,012 Views)
It should work in the majority of cases and is basically what I do all of the time though I do it without a sequence structure. I just chain all of the functions together with the error clusters. There are a lot of variations that can be done. Instead of a fixed wait, the Bytes at Serial Port and Read VISA can be inside a while loop that will end when the serial buffer is empty or a time limit is reached. If the serial data is terminated with some character, the VISA read can be set to terminate upon detection of the character and the number of bytes to read can be some arbitrarily high number.
0 Kudos
Message 5 of 6
(4,012 Views)
" when the serial buffer is empty or a time limit is reached"
This describes what Win32 API's ReadInterval does. It's a time interval which, if it expires and no characters are received, then the received message is considered to be concluded.
Thanks for helping me solve my problem.
0 Kudos
Message 6 of 6
(4,012 Views)