# Serial Port Acquisition

**URL:** <https://forum.inductiveautomation.com/t/serial-port-acquisition/4747>\
**Category:** Ignition\
**Created:** [July 2, 2012, 6:41pm UTC](https://forum.inductiveautomation.com/t/serial-port-acquisition/4747 "2012-07-02T18:41:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrooge](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chrooge](https://forum.inductiveautomation.com/u/chrooge)\
**Post date:** [July 2, 2012, 6:41pm UTC](https://forum.inductiveautomation.com/t/serial-port-acquisition/4747/1 "2012-07-02T18:41:56Z")

</div>

Hi,

I’m testing the serial port module (from this topic [http://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=8358](http://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=8358)).  
I would like to capture serial data (sent by an old SCADA server) and answer when necessary.  
Time between two received packets is about 0.5 s and 1 s (the size: 90 to 135 bytes - 38400 bauds).  
What’s the best way to do that ? timer (fixed delay - dedicated thread)?  
Is it possible to add a serial event (new line) ?

Thanks in advance.

Christophe

---

<div class="post-metadata">

**Author:** ![Michael.Stofan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.stofan/32/3342_2.png) [@Michael.Stofan](https://forum.inductiveautomation.com/u/Michael.Stofan)\
**Post date:** [July 2, 2012, 11:48pm UTC](https://forum.inductiveautomation.com/t/serial-port-acquisition/4747/2 "2012-07-02T23:48:56Z")

</div>

I think you’re on the right track. A gateway timer script on fixed delay would probably be a good place to start. I’m not quite sure what you meant by ‘add a serial event (new line)’ though…

---

<div class="post-metadata">

**Author:** ![chrooge](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chrooge](https://forum.inductiveautomation.com/u/chrooge)\
**Post date:** [July 3, 2012, 5:24pm UTC](https://forum.inductiveautomation.com/t/serial-port-acquisition/4747/3 "2012-07-03T17:24:14Z")

</div>

By “add a serial event”, I mean :  
launch a script when there is a new ascii line in the serial buffer.

I don’t know if we can test the state of the port before reading it.

---

<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:** [July 3, 2012, 5:30pm UTC](https://forum.inductiveautomation.com/t/serial-port-acquisition/4747/4 "2012-07-03T17:30:34Z")

</div>

[quote=“chrooge”]By “add a serial event”, I mean :  
launch a script when there is a new ascii line in the serial buffer.

I don’t know if we can test the state of the port before reading it.[/quote]

No, you can’t do that. The serial functionality is basic. All control is explicit: you open the port, do whatever you want with it (read something, write something, write something and wait for a read, etc…), then you close it.

Opening and closing can be done on startup and shutdown scripts if you want, but that means that serial port is going to be locked and nothing else on the system can use it.
