Strange issue with system.serial.port

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.

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:

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

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!.

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

1 Like

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.