# System.serial.readuntil timeout detection and buffer dumps

**URL:** <https://forum.inductiveautomation.com/t/system-serial-readuntil-timeout-detection-and-buffer-dumps/61531>\
**Category:** Ignition\
**Created:** [July 5, 2022, 7:30pm UTC](https://forum.inductiveautomation.com/t/system-serial-readuntil-timeout-detection-and-buffer-dumps/61531 "2022-07-05T19:30:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregory.sachs](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gregory.sachs](https://forum.inductiveautomation.com/u/gregory.sachs)\
**Post date:** [July 5, 2022, 7:30pm UTC](https://forum.inductiveautomation.com/t/system-serial-readuntil-timeout-detection-and-buffer-dumps/61531/1 "2022-07-05T19:30:05Z")

</div>

Trying to read from a serial barcode scanner, run by a person.  
Two things have popped up that I’m not sure how to solve:  
1: Possibility of scans when I’m not looking for them, generating junk data in the buffer. I can’t figure out how to dump incoming buffer, except by using a timer that continuously reads the port at a 1 sec interval with a short timeout. This only runs if my PLC request to scan is idle.  
Is there a better approach?  
2: readline and readuntil don’t seem to handle timeout well, for example just return a null string. Given that, it might be useful to amend the example to be this:

````auto
with system.serial.port(comPort, bitRate=system.serial.BIT_RATE_9600) as port:
	try: 
           line = port.readLine(15000) #readline reads until it gets \n, \r, or \r\n.```
        except:
           line=''

````

Did I miss a simple way of detecting the timeout condition?
