# Reading unpredictable input from serial port

**URL:** <https://forum.inductiveautomation.com/t/reading-unpredictable-input-from-serial-port/83360>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [December 20, 2023, 9:45am UTC](https://forum.inductiveautomation.com/t/reading-unpredictable-input-from-serial-port/83360 "2023-12-20T09:45:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiri\_Pise](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@Jiri\_Pise](https://forum.inductiveautomation.com/u/Jiri_Pise)\
**Post date:** [December 20, 2023, 9:45am UTC](https://forum.inductiveautomation.com/t/reading-unpredictable-input-from-serial-port/83360/1 "2023-12-20T09:45:37Z")

</div>

Hello,

I want to read data from serial port in vision. I have experimented with system.serial but there seems to be no way to read unpredictable inputs. I cannot use readBytesAsString since I dont know how many bytes will be on the input. I cannot use readUntil since I dont know what the last char will be. And reading whole line doesnt work either.

Is there a way to read char by char from the serial port with some delay and if in the time of the delay there is no new char on the input I simply stop reading? Or is there some other way to solve this?

Thanks

---

<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:** [December 20, 2023, 12:06pm UTC](https://forum.inductiveautomation.com/t/reading-unpredictable-input-from-serial-port/83360/2 "2023-12-20T12:06:08Z")

</div>

Yes, use [system.serial.readBytes()](https://docs.inductiveautomation.com/display/DOC81/system.serial.readBytes) with a short timeout.

When waiting for a new message, consider using it with a longer timeout and `numberOfBytes` set to one. Followed by the long read with short timeout.
