Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


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?



In reply to duplex serial read write by stumped

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    NodeReaper wonders through a maze of twisty little sayings, all alike

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (6)
    As of 2017-12-11 14:08 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (295 votes). Check out past polls.