# About the timeout error in \`system.serial.readLine\`

**URL:** <https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440>\
**Category:** Ignition\
**Tags:** scripting, vision\
**Created:** [September 8, 2025, 7:19am UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440 "2025-09-08T07:19:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_tanaka](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@m\_tanaka](https://forum.inductiveautomation.com/u/m_tanaka)\
**Post date:** [September 8, 2025, 7:19am UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/1 "2025-09-08T07:19:02Z")

</div>

Hello  
I have a question about system.serial.readLine.

I'm new to Ignition. Currently, I'm using system.serial to connect to a serial communication device.  
Connection tests confirmed the device connection and data retrieval worked, but when I try to retrieve data after a timeout with system.serial.readLine, it throws an error.

Even when I create if statements or Try / catch blocks to handle cases where the value is NULL, the error still occurs.  
How should I handle this situation? Should I change the settings on the device side?

```python
data = system.serial.readLine("COM3", 20000)

```

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 8, 2025, 10:41am UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/2 "2025-09-08T10:41:29Z")

</div>

I would post the config and the errors you get, we aren't mind readers.

---

<div class="post-metadata">

**Author:** ![m\_tanaka](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@m\_tanaka](https://forum.inductiveautomation.com/u/m_tanaka)\
**Post date:** [September 9, 2025, 2:10am UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/3 "2025-09-09T02:10:02Z")

</div>

Understood, that's correct! My apologies.  
The script I created is as follows.  
The error details are contained within the JSON file.  
This file was generated when the error occurred.

■code：

```python
try:
        #Definition of Connected Devices
        system.serial.configureSerialPort(port="COM3",
        bitRate=system.serial.BIT_RATE_9600,
        dataBits=system.serial.DATA_BITS_8,
        handshake=system.serial.HANDSHAKE_NONE,
        hardwareFlowControl=False,
        parity=system.serial.PARITY_NONE,
        stopBits=system.serial.STOP_BITS_1)
        
        #Connection
        system.serial.openSerialPort("COM3")
        
        #Data acquisition
        data = system.serial.readLine("COM3", 50000)
        
        if data is None:
           data = "Timeout occurred"
        
        system.serial.closeSerialPort("COM3")

        return data
     #The returned data is being used by each component.

```

■Error Details：

[NonResponsiveEdt-2025-08-29\_193604 (1).json](https://forum.inductiveautomation.com/uploads/short-url/fTwuBSFCfkjA3uoRmbNAdyyf8MC.json) (65.4 KB)

---

<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 9, 2025, 12:45pm UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/4 "2025-09-09T12:45:35Z")

</div>

The problem is that you are running this script directly in the foreground UI thread, which is not allowed to wait. You need to use `system.util.invokeAsynchronous()` to launch a background thread to do all of the serial line work. The background thread would report results by writing to client tags or using a shared jython variable, as background threads are not permitted to directly access windows and components.

---

<div class="post-metadata">

**Author:** ![m\_tanaka](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@m\_tanaka](https://forum.inductiveautomation.com/u/m_tanaka)\
**Post date:** [September 11, 2025, 1:36am UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/5 "2025-09-11T01:36:02Z")

</div>

Thank you! I'll try running a connection test using that method!

---

<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 11, 2025, 12:19pm UTC](https://forum.inductiveautomation.com/t/about-the-timeout-error-in-system-serial-readline/110440/6 "2025-09-11T12:19:14Z")

</div>

You should study this old topic if you wish to manipulate your UI from the background:

> [@Update GUI via Asynchronous thread](https://forum.inductiveautomation.com/t/update-gui-via-asynchronous-thread/9666):
>
> I’ve got a script I am experimenting with that can take a lot of time to execute, so I now use the system.util.invokeAsynchronous to run the script in a separate thread to keep the GUI from locking up. I am using the asynchronous thread to copy files from one place to another, and I would like to show the progress of the file copy with a progress bar. How would I go about this? I am importing a few python libraries to do this. import shutil def fileTransfer(): path = system.file.openFile() …
