# Easy way to clear the Serial buffer

**URL:** <https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [March 4, 2025, 8:30pm UTC](https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240 "2025-03-04T20:30:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spencer\_Lommel1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/spencer_lommel1/32/78679_2.png) [@Spencer\_Lommel1](https://forum.inductiveautomation.com/u/Spencer_Lommel1)\
**Post date:** [March 4, 2025, 8:30pm UTC](https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240/1 "2025-03-04T20:30:39Z")

</div>

I was looking at the system.serial commands and it looks like there's no easy way to clear the entire buffer. This would be a very nice feature for a reset functionality where you want to void out all current data in the buffer.

So my question is if this is possible currently and is there an easy way to clear out the buffer. If it isn't a feature where could I make a feature request to possibly get this added in the future?

> **[system.serial | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-serial)**
>
> Serial Functions

---

<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:** [March 4, 2025, 8:55pm UTC](https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240/2 "2025-03-04T20:55:25Z")

</div>

Just use `.readBytes()` with a large number of bytes and a short timeout. Discard the result.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 4, 2025, 8:59pm UTC](https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240/3 "2025-03-04T20:59:48Z")

</div>

Something like this _might_ work, untested:

```python
with system.serial.port("COM1") as port:
    port.serialPort.flushIOBuffers()

```

If it works, then it's because `port.serialPort` gets you the underlying [SerialPort](https://github.com/Fazecast/jSerialComm/blob/a8a307deed68bca2dda3048c1ecc5481eb5783fb/src/main/java/com/fazecast/jSerialComm/SerialPort.java#L1275) from the serial library, which has a `flushIOBuffers()` method.

No idea if this will accomplish what you're hoping, though.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2025, 11:07pm UTC](https://forum.inductiveautomation.com/t/easy-way-to-clear-the-serial-buffer/103240/4 "2025-03-04T23:07:53Z")

</div>

I think you'd have to throw in something like this to get at the private inner field:

```python
from org.apache.commons.lang3.reflect import FieldUtils
with system.serial.port("COM1") as port:
    jSerialPort = FieldUtils.readField(port, "serialPort", True)
    jSerialPort.flushIOBuffers()

```

Disclaimer: Still untested
