Serial Port Acquisition

Hi,

I’m testing the serial port module (from this topic 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

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…

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=“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.