I have fiddled some more with this serial logging. I'm ultimately trying to log the smdr output from a telephone switchboard (PBX), but I seem to be getting only intermittent success. My poll currently looks like this:
for(;;){ my $result=$PortObj->input; if($result =~ m/foo/){ $count++; my $query="INSERT INTO logs(cl_date, cl_dialled) value +s(now(),'$count')"; my $clsth=&db_query($query); } }
In this experiment I am then sending strings down the serial connection from the other box with:
bash-2.05b# echo "foo" >> /dev/ttyS0 bash-2.05b# echo "foo" >> /dev/ttyS0 bash-2.05b# echo "foo" >> /dev/ttyS0
heh - you get the idea.. However, there seems to be some mad entropy behind whether or not I detect anything at the logging end - If I sent 4 lines, I might only get 1 or 2 new rows in the databse - then perhaps I'll send 8 lines and get nothing, so then I'll restart the logger and send 5 lines.. and I get 3 new entries in the database... What I'm trying to say is that it's totally random whether or not the text gets picked up at the other end. I guess I generally manage to log 10-20% of the strings that get sent down.

For info, here is the result from stty on /dev/ttyS0 - I also turned on IGNBRK.
root@alexis:/export/serial/# stty -a < /dev/ttyS0 speed 9600 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; +eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -i +xon -ixoff -iuclc -ixany -imaxbel -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 +bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tost +op -echoprt -echoctl -echoke
now, I wonder if there is some way that Device::SerialPort can be made to detect that Data is ready to send, rather than just polling - am I going about this the wrong way?

thanks for your help,
christo :)

In reply to poll on serial device fails intermittently by planet_guru

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!
  • 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:
    & &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.