A long time ago I used to write interface programs that could talk to PBX's and other devices across serial ports (from SCO boxes). The concepts I used back when still would work now with Perl.
example running of script:
# tee input.txt</dev/ttyS0 | perl-prog.pl | tee output.txt >/dev/ttyS0
What this does is take Standard Input from the serial port, tee puts a copy in input.txt, then pipes the data to your script, and finially all script output is sent through tee which logs it to a file again then out the serial port.
When you write your perl script you just have to treat it like a user was typing in the data. Great when developing, as you just run the program and type in what you want. You let Linux handle all the IO to the serial port.
Here's the actual start job from an old script:
# start job
SMDRdbctee harris.in < /dev/ttyr0a | SMDRdbc interfce | SMDRdbctee har
+ris.out > /dev/ttyr0a &
By linking tee to SMDRdbctee it's easy to see when doing
ps.
But in recent years I also moved onto Expect also for this type of work.
ronzo
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.