http://www.perlmonks.org?node_id=1062622
stumped has asked for the wisdom of the Perl Monks concerning the following question:

Hardware

I have a home automation system which I am currently monitoring with a script, on a fedora box, which uses Device:SerialPort to read the output and then DBI to write it to a database. The data is hex terminated with a x0A. So I use a while loop with lookfor. When the status changes a status change message is sent, so there are random time intervals, which if there are no status changes can be very long.

The problem

I now want to control the HA system through the perl script. So I need to be able to write data to the serial port without disturbing the monitoring above. The data flows will be 98% incoming lookfor reads with irregular intervals and 2% writing instructions.

I have tried searching for a suitable module or code, but there does not seem to be a clear way to approach the problem with alternatives being some sort of filehandle or a socket (perhaps a pair of sockets?). The examples I can find all seem to be based on win32, so not directly comparable.

Can anyone help with a simple low overhead method of writing a hex string (which I can prepare with pack), given that the script may be in a loop waiting at the lookfor for the next status message?

Thanks,

stumped