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:
port.readBytes(1)
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!.