Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 output buffer byte count

I am accessing the RS232 directly (without VISA) from Labview. I need to reset the port sometimes. It seems that because the output is buffered, even the RS232 write vi is finished, it is still possible that the output buffer could be overrun by the reset. A routine similar to RS232 (INPUT) byte count that counts the length of the output buffer would help me. Any suggestions?
0 Kudos
Message 1 of 10
(6,778 Views)
Unfortunately, there is no VI that has that functionality. There is a function in the Windows serial driver API called GetOutQLen that returns the number of characters in the output queue. However there is no VI that has the functionality. If you need that functionality in LabVIEW, you would need use a code interface node(CIN) or a call library function to access that functionality. ie write code in C that accesses that function and 1) call the code with a CIN or 2)build that dll from the code to use with the call library function.

This is the help for the function as list by LabWindows/CVI:

GetOutQLen (int COMPort);

Purpose
Returns the number of characters in the output queue of a COM port.

Parameter
Input
Name Type Description
COMPort integer
Range 1�1,000.


Return Value
Name Type Description
len integer Number of characters in the output queue.


Using This Function
You can use GetOutQLen to ensure the output queue empties before you close the port. This function has no effect on the output queue.

GetOutQLen returns an error if you have not opened the port of if you pass an invalid value for COMPort.
0 Kudos
Message 2 of 10
(6,777 Views)
If you move to VISA, a call to VISA Flush with mode 32 will drain any contents out of the output buffer.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 3 of 10
(6,777 Views)
Dan,
It is the opposite I want. I want to know if the output buffer is empty before carry on. Any ideas?
Zuolan
0 Kudos
Message 4 of 10
(6,777 Views)
Thanks Ray.
I tried to use GetOutQLen() from within CVI but it did not quite work. As you mentioned that I have to use OpenCom first which begs another question: Can I access the same COM Port from both CVI routine and Labview RS232 vis at the same time? Any thought?

It would also help me if someone could point some CVI codes that uses these COM Port functions.

Thanks.
Zuolan
0 Kudos
Message 5 of 10
(6,777 Views)
Dan,
I am looking at your answer again. I agree that it could work for me. Thanks.

This brings another question. Currently I am not using VISA because when delivering EXE application, it involves installing NI-VISA real-time which puts a lot of things to the customers computer (GPIB etc). Has this changed for the new versions (6.1, 7.0)?
Thanks again.
Zuolan
0 Kudos
Message 6 of 10
(6,777 Views)

Hi,

There is a property named "Number of Bytes at Serial port". The property is available on the functions palette >> Instrument Control >> Serial.

The versions you are refering to are LabVIEW versions, not VISA version. The lastest VISA vesion is 3.0.

In any version, the VISA run-time engine only installs the VISA library.

DiegoF
National Instruments.

0 Kudos
Message 7 of 10
(6,777 Views)
Zuolan:

When building an application with LabVIEW 7, there is an option for it to include the portion of the NI-VISA run-time that includes just the Serial support. That should be exactly what you want.

Dan Mondrik
0 Kudos
Message 8 of 10
(6,777 Views)
Dear Sir. could you tell me how can I build my serial aplication, and with only de needed VISA functions, and no more?
 
Regards.
 
Kike
0 Kudos
Message 9 of 10
(6,572 Views)
On the Installer tab of the app builder, check the Create Installer box and then click the Advanced button. You'll see a check box for Serial Port Support.
0 Kudos
Message 10 of 10
(6,568 Views)