# How to send Serial data received to a text window?

**URL:** <https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617>\
**Category:** Ignition\
**Tags:** ignition81, scripting, vision\
**Created:** [June 10, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617 "2022-06-10T14:26:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Mears](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@Ian\_Mears](https://forum.inductiveautomation.com/u/Ian_Mears)\
**Post date:** [June 10, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/1 "2022-06-10T14:26:06Z")

</div>

I’m currently making a UI to make it easier for someone to basically use a terminal like PuTTY. I can run the script to open and write commands using a serial adapter, and I can see feedback from that serial adapter after opening the com port. But I don’t see any way to send all the feedback to a text window. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [June 10, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/2 "2022-06-10T14:34:15Z")

</div>

Where exactly are you seeing feedback from the serial adapter/how? If it’s in Ignition your best bet might be to save to a tag, or use a message handler to send the data to the text window.

But I don’t really understand the setup enough to go further than that.

---

<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:** [June 10, 2022, 2:41pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/3 "2022-06-10T14:41:03Z")

</div>

Start here:

> [@How to listen serial data without interruption](https://forum.inductiveautomation.com/t/how-to-listen-serial-data-without-interruption/15709):
>
> I am using serial module to get data from a rs232 device, and the device is could only send its data to serial port ,but could not accept any request. the problem is I don’t know when the data will be send,so I need to listen the serial constantly to avoid lose any data. but unfortunately, there are no any event trigger on serial component in ignition . dose anyone meet the same problem and could give some help? (I’m using ignition 7.7.5) I put scripts on a timer , but datas always los…

The key is that a script that is going to block reading from the serial port (even briefly) must be run in a background thread. Data to deliver to your UI must use `system.util.invokeLater()` to delegate snippets of code back on the UI thread.

---

<div class="post-metadata">

**Author:** ![Ian\_Mears](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@Ian\_Mears](https://forum.inductiveautomation.com/u/Ian_Mears)\
**Post date:** [June 10, 2022, 2:41pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/4 "2022-06-10T14:41:17Z")

</div>

The “Interactive Interpreter” will show all the feedback on a script

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [June 10, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/5 "2022-06-10T14:49:49Z")

</div>

My way might pose more issues. Pturmels link above has some pretty good insight

---

<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:** [June 10, 2022, 2:55pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/6 "2022-06-10T14:55:35Z")

</div>

Some additional information on background threads and updates to the UI:

> [@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() …

---

<div class="post-metadata">

**Author:** ![Ian\_Mears](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@Ian\_Mears](https://forum.inductiveautomation.com/u/Ian_Mears)\
**Post date:** [June 10, 2022, 4:00pm UTC](https://forum.inductiveautomation.com/t/how-to-send-serial-data-received-to-a-text-window/60617/7 "2022-06-10T16:00:10Z")

</div>

these are pretty instantaneous replies.

If I put in the script, a write command ’ system.serial.write(“COM4”, “MYDATAINPUT”, 1000, “UTF-8”) ’ and then right below it put ’ system.serial.readBytesAsString(“COM4”, 60000, 1000, “UTF-8”) ’

then I receive back MYDATAINPUT no problem. the same goes for the application I was using putty for.

I’m not understanding how I can display the readBytesAsString input into a text window after it comes in.
