LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I set XonLimit and XoffLimit for serial port communication?

I am trying to initialize serial port settings for an instrument that already has software written for it (other than in LabVIEW). Using the port monitoring program Portmon, I know that the initialization commands for the already-written software are as follows:

 

IRP_MJ_CREATE Serial0 SUCCESS Options: Open  
IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS  
IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS  
IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS  
IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS  
IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 115200 
IOCTL_SERIAL_CLR_RTS Serial0 SUCCESS  
IOCTL_SERIAL_CLR_DTR Serial0 SUCCESS  
IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 
IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:0 XOFF:0 
IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0 Replace:0 XonLimit:1024 XoffLimit:1024 
IOCTL_SERIAL_SET_QUEUE_SIZE Serial0 SUCCESS InSize: 50000 OutSize: 128 
IOCTL_SERIAL_SET_TIMEOUTS Serial0 SUCCESS RI:-1 RM:0 RC:0 WM:0 WC:0 

 

Here is what I can reproduce with LabVIEW using 'Serial Port Init.vi':

 

IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS  
IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS  
IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS  
IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS  
IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS  
IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS  
IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS  
IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS  
IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 115200 
IOCTL_SERIAL_CLR_RTS Serial0 SUCCESS  
IOCTL_SERIAL_CLR_DTR Serial0 SUCCESS  
IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 
IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:0 XOFF:0 
IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0 Replace:0 XonLimit:10 XoffLimit:10 
IOCTL_SERIAL_PURGE Serial0 SUCCESS Purge: TXABORT RXABORT TXCLEAR RXCLEAR 
IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS  
IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS  
IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS  
IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS  

 

What I can't figure out how to do is change the values XonLimit, XoffLimit, InSize, Outsize, and the timeouts in LabVIEW. Is there a way to do this? According to the manufacturer's Serial Protocol, there is no flow control, which is why (I think) XON and XOFF are zero in the original program.

 

However, once the incoming data reaches the buffer size, the LabVIEW program crashes. And I'm thinking it's due to the xonlimit/xofflimit/insize/outsize/timeout values not equaling those in the original program?

 

Any help on the topic is appreciated!

 

Thanks,

dkopp

0 Kudos
Message 1 of 13
(9,801 Views)
XON/XOFF settings are set using VISA Property Nodes. The limit value is based on the buffer size (which in your case is being set to 50000). If you open the Example Finder (Help -> Find Examples) and search for serial, and open the "Advanced Serial Write and Read" example you will see how it is done. You can check the VISA documentation for details on each VISA property. The documentation can be accessed from (on Windows) Start -> All Programs -> National Instruments -> VISA -> Documentation.
Message 2 of 13
(9,785 Views)

How can I send IOCTL_SERIAL_PURGE the serial port? Also, is there a way that I can explicitly set the Shake and Replace values in the IOCTL_SERIAL_SET_HANDFLOW command?

 

Thanks,

Derick

0 Kudos
Message 3 of 13
(9,717 Views)

dkopp wrote:

How can I send IOCTL_SERIAL_PURGE the serial port?


The PURGE is done when you do a flush with the VISA Flush I/O Buffers.

 


Also, is there a way that I can explicitly set the Shake and Replace values in the IOCTL_SERIAL_SET_HANDFLOW command?

 

To what? I'm not 100% sure, but I think the Shake and Replace values are set automatically based on the type of flow control that you select.

 

 

0 Kudos
Message 4 of 13
(9,705 Views)
Per the instrument protocol, I need to set Shake and Replace to zero.
0 Kudos
Message 5 of 13
(9,688 Views)
Which you have done and since the Xonlimit/Xofflimit is only used with flow control on, there does not appear to be any issue with these settings. Did you set the buffer size?
0 Kudos
Message 6 of 13
(9,681 Views)

What I did not realize initially when I posted at first was that once I ran the initialization in the original program, it set Shake and Replace to zero until the computer was rebooted. So that when I ran the initialization in LabVIEW, Shake and Replace were already set to zero. However, if I run the initialization in LabVIEW using the VISA Configure Serial Port immediately after a reboot, Shake is set to 1 and Replace is set to 40. I know that the Shake and Replace values will change dependent on the flow control settings. However with flow control set to none, they seem to be set to 1 and 40, respectively, by default. Thus I was curious if I could change their setting independent of other settings? I do appreciate any input on this matter.

 

Derick

 

0.00000810 LabVIEW.exe IOCTL_SERIAL_SET_BAUD_RATE Serial0 SUCCESS Rate: 115200 
0.00000419 LabVIEW.exe IOCTL_SERIAL_SET_RTS Serial0 SUCCESS  
0.00000447 LabVIEW.exe IOCTL_SERIAL_SET_DTR Serial0 SUCCESS  
0.00000307 LabVIEW.exe IOCTL_SERIAL_SET_LINE_CONTROL Serial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 
0.00000196 LabVIEW.exe IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:0 XOFF:0 
0.00000307 LabVIEW.exe IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:1 Replace:40 XonLimit:1024 XoffLimit:1024 
0.00000168 LabVIEW.exe IOCTL_SERIAL_GET_BAUD_RATE Serial0 SUCCESS  
0.00000168 LabVIEW.exe IOCTL_SERIAL_GET_LINE_CONTROL Serial0 SUCCESS  
0.00000168 LabVIEW.exe IOCTL_SERIAL_GET_CHARS Serial0 SUCCESS  
0.00000140 LabVIEW.exe IOCTL_SERIAL_GET_HANDFLOW Serial0 SUCCESS  
0.00000140 LabVIEW.exe IOCTL_SERIAL_SET_QUEUE_SIZE Serial0 SUCCESS InSize: 50000 OutSize: 50000 
0.00000168 LabVIEW.exe IOCTL_SERIAL_SET_TIMEOUTS Serial0 SUCCESS RI:-1 RM:0 RC:0 WM:0 WC:250 

0 Kudos
Message 7 of 13
(9,665 Views)
Now I'm the one who's confused. You want to set XON/XOFF parameters, but you want flow control off? Then what's the point?
Message 8 of 13
(9,653 Views)

Hi 

I have similar problem . I am using Advanced serial write and Read example and I want to change some of those initializations .I have software that it shows what the original program is sending .Due to those commands i want to change followings : 

1- XonLimit and XoffLimit   (in original program it has been set to  2048 and  512 resp. but in LabVIEW i cann't set these values .

2- I want to set DTR and  RTS off

3- set these  ReadInterval=500, ReadTotalTimeoutMultiplier=2000, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0

4- In/out queue size 1000/1000

 

Many thanks if anybody help me .

Message 9 of 13
(9,272 Views)

HI, ME TOO

I have the same problem

0 Kudos
Message 10 of 13
(5,186 Views)