Issue opening port - Serial communication through Scripting

Hi all,

I am trying to send a message via Serial communication.

system.serial.port(port, bitRate, dataBits=8, stopBits=1)
system.serial.write(port, message)

The issue I'm having is that I have tested the script in the console, and it works beautifully, but when using the gateway scripts, it doesn't work. This is because it's opening the COM port in the gateway, and not in the machine where my designer is.

Error running action 'component.onActionPerformed' on Templates/Configuration/Site Config Attribute@C$0:0:3$0:2:0[5]$0:1[5]/root/Script: Traceback (most recent call last): File "function:runAction", line 4, in runAction File "function:runAction", line 4, in runAction File "", line 1, in File "module:shared.Serial", line 74, in testSerialConnection at com.inductiveautomation.ignition.modules.serial.scripting.SerialScriptModule.openSerialPort(SerialScriptModule.java:258) at com.inductiveautomation.ignition.modules.serial.scripting.SerialScriptModule$PortManager.(SerialScriptModule.java:209) at com.inductiveautomation.ignition.modules.serial.scripting.SerialScriptModule.port(SerialScriptModule.java:201) at jdk.internal.reflect.GeneratedMethodAccessor285.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.io.IOException: java.io.IOException: failed to open port: COM5

Is there a way of solving this?

No, Perspective scripts run only in the gateway. You simply cannot access local resources from a Perspective browser session, or Workstation session. You can only access selected local resources in a Mobile session.

(This is trivial in Vision. If you are trying to convert a Vision application that does this, you will need to relocate the serial devices to talk to the gateway. Perhaps with serial-to-ethernet converters. Or just keep using Vision.)