05-20-2010 03:47 PM
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
05-20-2010 04:23 PM
06-01-2010 02:27 PM
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
06-01-2010 04:24 PM
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.
06-02-2010 08:58 AM
06-02-2010 09:20 AM
06-02-2010 02:25 PM
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
06-02-2010 03:29 PM
11-15-2010 08:23 AM
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 .
05-14-2019 08:17 AM
HI, ME TOO
I have the same problem