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.
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||