Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

number of bytes at serial port I/O buffer

When using the  Visa comm library, how can you check how many bytes there are at the Comm port before reading it?  Right now I have my read function set up so that it only reads one byte ata time in a continuous loop, until the ReadString() function times out.  But as I mentionned in the other thread, I'm not getting correct data... so maybe there's another way of doing it. Thanks...
0 Kudos
Message 1 of 9
(9,050 Views)
VISA Bytes At Port Propery Node under the Serial Pallete
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 9
(9,045 Views)
AnalogKid,
thanks, but can you give me a few more clues?  I'm afraid I'm a little new to this VISA stuff.... I did a search in the Visa Help for VISA Propery Node and didn't come up with anything.
0 Kudos
Message 3 of 9
(9,036 Views)
Search the help for the string 'VISA Bytes at Serial Port'!
This will return:
'Returns the number of bytes in the input buffer of the specified serial port.
The Number of Bytes at Serial Port property specifies the number of bytes currently available at the serial port used by this session.
Visa Bytes at Serial Port is a Property Node with a VISA class of Instr.'

This node uses the VISA PortRef and an error cluster as input and output and returns a longint (I32) containing the availabel bytes at the specified port.

HTH   and
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 4 of 9
(9,017 Views)

Resource Classes

Serial INSTR

Attribute Information

Description

VI_ATTR_ASRL_AVAIL_NUM

shows the number of bytes available in the global receive

buffer.

Related Items

See the

INSTR Resource description in Appendix B, Resources.

Access

Privilege Data Type Range Default

Read Only

Global

ViUInt32

0 to FFFFFFFFh N/A

-----------------------------
just pasted from the VISA Programmers Manual
 
 
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 9
(9,013 Views)
I am doing what has been recommended here, but... I am getting some problems.
I first send the VISA resource name to a property node (Serial Instr) and ask it for "bytes at port".Then I send the number of bytes to VISA Read.
The problem is that "bytes at port" return that I have e.g. 8bytes at the port. But ... if I read 8 bytes from the port I get a warning from VISA read saying there is still more bytes left to read. If I cut out the Bytes at port as input to VISA read, and instead ask it to return a high number of bytes (say 50) I will, while Bytes at port says there are 8 bytes at the port, be able to read 22 bytes from the port.
 
What is wrong? I don't think that there were 8 bytes at the port to begin with and that the remaining 14 are written before I run VISA read (I have waited a long time before running this sequence and the port should be stabilized)
0 Kudos
Message 6 of 9
(8,773 Views)
You get a warning that there may be more bytes to be read. When you use Bytes at Serial Port, it is best to use it in a loop. Keep calling it an reading until the number of bytes is zero. If you have the termination character enabled with the Configure Serial Port and your instrument does send a term character, then you can skip the VISA Bytes at Serial Port and specify some large number of bytes to read with the VISA Read. The VISA Read will automatically terminate when the termination character is detected.
Message 7 of 9
(8,769 Views)

Hallo,

 

VI_ATTR_ASRL_AVAIL_NUM flag can be used in order to determine the amount of data in the input serial asynch. COM buffer, but what about determining number of bytes in output buffer ? Is there any VISA function which query number of bytes in output buffer ?

 

BR,

Milan.

0 Kudos
Message 8 of 9
(8,101 Views)
0 Kudos
Message 9 of 9
(8,094 Views)