# readBytes

**URL:** <https://forum.inductiveautomation.com/t/readbytes/5051>\
**Category:** Ignition\
**Created:** [August 24, 2012, 4:06pm UTC](https://forum.inductiveautomation.com/t/readbytes/5051 "2012-08-24T16:06:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [August 24, 2012, 4:06pm UTC](https://forum.inductiveautomation.com/t/readbytes/5051/1 "2012-08-24T16:06:23Z")

</div>

We are about to test system.serial.readBytes. Would it be possible for a developer to supply a couple of lines of code as an example of how it should been implemented?

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [August 24, 2012, 4:20pm UTC](https://forum.inductiveautomation.com/t/readbytes/5051/2 "2012-08-24T16:20:05Z")

</div>

There is an outstanding bug with the serial library on 64bit machines:  
[viewtopic.php?f=72&t=8604](http://www.inductiveautomation.com/forum/viewtopic.php?f=72&t=8604)

I’ve not had this working yet due to the bug, but it should look like this:

```auto
port = '/dev/ttyUSB0'
system.serial.openSerialPort(port)
system.serial.configureSerialPort(
    port,
    bitRate=system.serial.BIT_RATE_9600
)
bytes = system.serial.readBytes(port, 16)
system.serial.closeSerialPort(port)
```

On Unix systems it shouldn’t matter whether you open or configure first, and you can reconfigure at any time. This might not be true for other operating systems so try swapping those calls if you have problems.

Please let me know how you get on.

---

<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:** [August 24, 2012, 4:26pm UTC](https://forum.inductiveautomation.com/t/readbytes/5051/3 "2012-08-24T16:26:09Z")

</div>

You beat me to the example!

> [@](#):
>
> On Unix systems it shouldn't matter whether you open or configure first, and you can reconfigure at any time. This might not be true for other operating systems so try swapping those calls if you have problems.

This isn't true using the serial scripting functions. configureSerialPort() just modifies a SerialConfig data structure; but the actual SerialPort object doesn't listen for changes to that data structure. It's passed one when it's opened and uses the parameters configured at that point. (It does look at them again when reset() or configure() is called, but that's not exposed to the scripting API)
