# Strange issue with system.serial.port

**URL:** <https://forum.inductiveautomation.com/t/strange-issue-with-system-serial-port/41484>\
**Category:** Ignition\
**Created:** [December 14, 2020, 12:00am UTC](https://forum.inductiveautomation.com/t/strange-issue-with-system-serial-port/41484 "2020-12-14T00:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmunin](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mmunin](https://forum.inductiveautomation.com/u/mmunin)\
**Post date:** [December 14, 2020, 12:00am UTC](https://forum.inductiveautomation.com/t/strange-issue-with-system-serial-port/41484/1 "2020-12-14T00:00:29Z")

</div>

I’m trying to use system.serial.port to handle opening and closing serial connections for me, all in the gateway scope. For testing purposes, I have created a tag change script, so my code runs in the gateway scope. I have the following script bound to a memory boolean tag so I can trigger the script at will.

```auto
with system.serial.port(port = "/dev/rfcomm0",
	bitRate = system.serial.BIT_RATE_38400,
	dataBits = system.serial.DATA_BITS_8,
	handshake = system.serial.HANDSHAKE_NONE ,
	hardwareFlowControl = False,
	parity = system.serial.PARITY_NONE ,
	stopBits = system.serial.STOP_BITS_1) as port:
	
	port.readBytes(1)

```

When I check my logs in the gateway, I see the following strange error.

```auto
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 9, in TypeError: readBytes(): argument bytes: expected int instance, got PyInteger

```

For some reason, it doesn’t consider 1 to be an int, rather a PyInteger. I’m sure this is some Jython weirdness that is frankly out of pay grade, but I would love someone else who knows more than me to confirm this!.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2020, 12:26am UTC](https://forum.inductiveautomation.com/t/strange-issue-with-system-serial-port/41484/2 "2020-12-14T00:26:54Z")

</div>

Try without the context manager (separate configurePort, openPort, readBytes). It might be a bug in the context manager’s wrapper for readBytes.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/strange-issue-with-system-serial-port/41484/3 "2020-12-14T15:52:13Z")

</div>

It’s just a bug; unfortunately, it means that the context manager is pretty gimped until we fix it, but it should happen pretty soon.
