Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

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

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


In reply to duplex serial read write by stumped

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (10)
    As of 2014-12-19 10:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (77 votes), past polls