# jSerialComm toggles DTR when opening COM port

**URL:** <https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 16, 2023, 2:34am UTC](https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508 "2023-10-16T02:34:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justop](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@justop](https://forum.inductiveautomation.com/u/justop)\
**Post date:** [October 16, 2023, 2:34am UTC](https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508/1 "2023-10-16T02:34:56Z")

</div>

Every time I open a serial port, it appears jSerialComm is toggling the DTR pin. This is causing my serial device to reboot. Is there a way to open a COM port without toggling the DTR pin?

```auto
	from com.fazecast.jSerialComm import SerialPort

	ports = list(SerialPort.getCommPorts())
		
	for x in ports:
	  	x.clearDTR()

	output = 'Hello World' + '\n'

	system.serial.configureSerialPort(
		port="COM4",
		bitRate = system.serial.BIT_RATE_115200,
		dataBits = system.serial.DATA_BITS_8,
		hardwareFlowControl = False,
		handshake = system.serial.HANDSHAKE_NONE,
		parity = system.serial.PARITY_NONE,
		stopBits=system.serial.STOP_BITS_1)
	
	# Open serial port
	system.serial.openSerialPort( "COM4" )

	#serial device reboots here!

	system.serial.write( "COM4" , output)

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 16, 2023, 10:32am UTC](https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508/2 "2023-10-16T10:32:45Z")

</div>

May be of interest:

> <https://github.com/Fazecast/jSerialComm/issues/125>
>
> For Arduino programming it is important to be able to disable DTR or the Arduino… is going to reset each time a connection with DTR is established.
> 
> Calling
> 
> \> port.setFlowControl( SerialPort.FLOW\_CONTROL\_DISABLED );
> \> port.clearDTR();
> \> port.openPort();
> 
> has no effect. The Arduino resets, so DTR must be still active.
> 
> Sadly the old JSSC library doesn't work anymore and was updated last time 4 years ago, so I was hoping for this library to work.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 16, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508/3 "2023-10-16T12:04:07Z")

</div>

It looks like the only chance you have of getting this working is to program against the jSerialComm API directly instead of using the Ignition scripting functions.

This:

```auto
	ports = list(SerialPort.getCommPorts())
		
	for x in ports:
	  	x.clearDTR()

```

is operating on a different list of SerialPort objects than the one that gets created when you call `system.serial.openSerialPort`, so it's not going to work.

You'll have to try programming directly against jSerialComm API + using the suggested code from issue linked by Jordan.

---

<div class="post-metadata">

**Author:** ![justop](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@justop](https://forum.inductiveautomation.com/u/justop)\
**Post date:** [October 16, 2023, 7:24pm UTC](https://forum.inductiveautomation.com/t/jserialcomm-toggles-dtr-when-opening-com-port/80508/4 "2023-10-16T19:24:53Z")

</div>

Thanks for the feedback. At this point, the simples fix I found was hardware based. ...similar to what was mentioned in the link @JordanCClark shared.
