How to send Serial data received to a text window?

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.

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.

Start here:

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.

2 Likes

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

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

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

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.