06-16-2022 04:35 AM
Hi,
I am communicating to a device over a virtual serial port. When using Hterm or most other serial terminal programs the handshake lines (RTS and DTR) are not activated. In Labview however, as soon as I use the "VISA Configure serial connect.vi", the RTS and DTR lines are set, even if flow control is off.
Serial log when connecting to port with Labview:
00000181 2022-06-15 16:56:44.3033533 +38.9896763 IRP_MJ_CREATE - process 13228 (LabVIEW.exe) DOWN 0x00000000
00000182 2022-06-15 16:56:44.3037947 +0.0004414 IRP_MJ_CREATE UP 0x00000000
00000191 2022-06-15 16:56:44.3038327 +0.0000065 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_BAUD_RATE DOWN 0x00000000 80 25 00 00 .%..
00000192 2022-06-15 16:56:44.3040171 +0.0001844 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_BAUD_RATE UP 0x00000000
00000193 2022-06-15 16:56:44.3040272 +0.0000101 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_RTS DOWN 0x00000000
00000194 2022-06-15 16:56:44.3041190 +0.0000918 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_RTS UP 0x00000000
00000195 2022-06-15 16:56:44.3041302 +0.0000112 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_DTR DOWN 0x00000000
00000196 2022-06-15 16:56:44.3042231 +0.0000929 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_DTR UP 0x00000000
00000197 2022-06-15 16:56:44.3042321 +0.0000090 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_LINE_CONTROL DOWN 0x00000000 00 00 08 ...
00000198 2022-06-15 16:56:44.3042330 +0.0000009 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_LINE_CONTROL UP 0x00000000
00000199 2022-06-15 16:56:44.3042363 +0.0000033 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_CHARS DOWN 0x00000000 00 00 00 00 11 13 ......
00000200 2022-06-15 16:56:44.3042369 +0.0000006 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_CHARS UP 0x00000000
Serial log when connecting to port with Hterm:
00000001 2022-06-15 16:56:01.9276245 +22.9518456 IRP_MJ_CREATE - process 12660 (HTerm.exe) DOWN 0x00000000
00000002 2022-06-15 16:56:01.9284102 +0.0007857 IRP_MJ_CREATE UP 0x00000000
00000013 2022-06-15 16:56:01.9284763 +0.0000083 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_BAUD_RATE DOWN 0x00000000 00 c2 01 00 ....
00000014 2022-06-15 16:56:01.9284771 +0.0000008 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_BAUD_RATE UP 0x00000000
00000015 2022-06-15 16:56:01.9284828 +0.0000057 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_CLR_RTS DOWN 0x00000000
00000016 2022-06-15 16:56:01.9285581 +0.0000753 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_CLR_RTS UP 0x00000000
00000017 2022-06-15 16:56:01.9285749 +0.0000168 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_CLR_DTR DOWN 0x00000000
00000018 2022-06-15 16:56:01.9286497 +0.0000748 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_CLR_DTR UP 0x00000000
00000019 2022-06-15 16:56:01.9286605 +0.0000108 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_LINE_CONTROL DOWN 0x00000000 00 00 08 ...
00000020 2022-06-15 16:56:01.9286617 +0.0000012 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_LINE_CONTROL UP 0x00000000
00000021 2022-06-15 16:56:01.9286668 +0.0000051 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_CHARS DOWN 0x00000000 00 00 00 00 00 00 ......
00000022 2022-06-15 16:56:01.9286677 +0.0000009 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_CHARS UP 0x00000000
Labview's toggling of the DTR/RTS lines is causing issues with my hardware. Is it possible to prevent Labview from changing these lines?
Thank you.
06-16-2022 06:52 AM
Cut the wires
06-16-2022 07:07 AM
They are needed in some cases.
06-16-2022 07:59 AM
You can use property node to manually set these lines.
The DTR State and RTS State properties.
06-16-2022 08:04 AM - edited 06-16-2022 08:06 AM
@AeroSoul wrote:
You can use property node to manually set these lines.
The DTR State and RTS State properties.
Yes you can if you want to control those lines yourself. The operators problem is the opposite. He does not want VISA to control those lines at all when it initializes the port and I don't think there is a way to do that other than the solution by JpB (or not use VISA). It can be a problem for instance for interfacing to Arduinos or other similar boards. They consider the toggling of the RTS line as a reset signal.
I think the OP did make an error in his post. I don't see any difference in what he claims to see for Hterm and NI-VISA, which is according to his text of course not what he observes.
06-16-2022 08:15 AM
@rolfk ha scritto:
I think the OP did make an error in his post. I don't see any difference in what he claims to see for Hterm and NI-VISA, which is according to his text of course not what he observes.
Do you mean that IOCTL_SERIAL_SET and IOCTL_SERIAL_CLEAR are the same?
06-16-2022 08:28 AM - edited 06-16-2022 08:30 AM
@pincpanter wrote:
@rolfk ha scritto:I think the OP did make an error in his post. I don't see any difference in what he claims to see for Hterm and NI-VISA, which is according to his text of course not what he observes.
Do you mean that IOCTL_SERIAL_SET and IOCTL_SERIAL_CLEAR are the same?
That is also unlikely to be exactly the same in Hterm but apparently not the problem of the OP. But the SERIAL_CLR_RTS DOWN/UP and SERIAL_CLR_DTR DOWN/UP calls are the ones he would not want to have been issued on serial port open. Hterm (and all other terminal applications I know of) have a configuration option that defines if RTS and CTS handling should be done at all and if that it disabled they will never try to control those lines.
NI VISA always does this initialization and there is no way to disable it on viOpen() that I know of. viOpen is either called when you do a an explicit VISA Open in LabVIEW or automatically as soon as you try to do anything with a VISA resource to access the underlying port.
Actually I just checked and there might be a small chance. VISA Open has an access mode parameter. One of the values is Load Configuration Settings. This is only supported for VISA ASRL resources but that is what we want here. If you go into NI Max you can configure the serial port with a default baud rate and flow control. If you pass this flag to VISA Open, NI VISA should use the settings as configured in NI Max and MIGHT refrain from trying to initialize the flow control lines during initialization if the flow control settings in NI Max for that port were set to None. I haven't tested this theory myself but it is worth an attempt. Of course you need to execute VISA Open explicitly before trying to access the VISA Resource by any other VISA function. Otherwise LabVIEW will do an implicit viOpen() without that flag set.
06-16-2022 09:53 AM - edited 06-16-2022 10:05 AM
@JÞB wrote:
Cut the wires
They are needed in
some cases.
Place relays on cut wires. If necessary cut the wires longer 😠
Cables adapters can be found too with dip switches. Actually that would not make a neat task for an EE intern to design one that has a serial controlled switch set with a USB powered device 500mA @5v (2.5W) should hold a few signal relays and a pic
06-16-2022 10:09 AM
@JÞB wrote:
Cut the wires
Or just build your own cable. All you need are a couple of DB-9 connectors (for most devices, you need a Male and a Female connector), 3 wires, and a soldering iron. Pin 2 on connector 1 goes to pin 3 on connector 2 (TX to RX), vice versa, and pin 5 to pin 5 (GND).
06-16-2022 10:15 AM
@rolfk wrote:
@pincpanter wrote:
@rolfk ha scritto:I think the OP did make an error in his post. I don't see any difference in what he claims to see for Hterm and NI-VISA, which is according to his text of course not what he observes.
Do you mean that IOCTL_SERIAL_SET and IOCTL_SERIAL_CLEAR are the same?
That is also unlikely to be exactly the same in Hterm but apparently not the problem of the OP. But the SERIAL_CLR_RTS DOWN/UP and SERIAL_CLR_DTR DOWN/UP calls are the ones he would not want to have been issued on serial port open. Hterm (and all other terminal applications I know of) have a configuration option that defines if RTS and CTS handling should be done at all and if that it disabled they will never try to control those lines.
NI VISA always does this initialization and there is no way to disable it on viOpen() that I know of. viOpen is either called when you do a an explicit VISA Open in LabVIEW or automatically as soon as you try to do anything with a VISA resource to access the underlying port.
Actually I just checked and there might be a small chance. VISA Open has an access mode parameter. One of the values is Load Configuration Settings. This is only supported for VISA ASRL resources but that is what we want here. If you go into NI Max you can configure the serial port with a default baud rate and flow control. If you pass this flag to VISA Open, NI VISA should use the settings as configured in NI Max and MIGHT refrain from trying to initialize the flow control lines during initialization if the flow control settings in NI Max for that port were set to None. I haven't tested this theory myself but it is worth an attempt. Of course you need to execute VISA Open explicitly before trying to access the VISA Resource by any other VISA function. Otherwise LabVIEW will do an implicit viOpen() without that flag set.
Unlikely to work. Arduino even maintains a FAQ to the effect that you may need to cut that special trace to avoid VISA Resetting the device.