# Issue opening port - Serial communication through Scripting

**URL:** <https://forum.inductiveautomation.com/t/issue-opening-port-serial-communication-through-scripting/95470>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [September 3, 2024, 10:18am UTC](https://forum.inductiveautomation.com/t/issue-opening-port-serial-communication-through-scripting/95470 "2024-09-03T10:18:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Bermejo](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Sam\_Bermejo](https://forum.inductiveautomation.com/u/Sam_Bermejo)\
**Post date:** [September 3, 2024, 10:18am UTC](https://forum.inductiveautomation.com/t/issue-opening-port-serial-communication-through-scripting/95470/1 "2024-09-03T10:18:18Z")

</div>

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?

---

<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:** [September 3, 2024, 12:09pm UTC](https://forum.inductiveautomation.com/t/issue-opening-port-serial-communication-through-scripting/95470/2 "2024-09-03T12:09:21Z")

</div>

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