I am opening a serial port to a device that is already streaming data at 9600B. Occasionally I get a "Buffer Overrun detected" message, which I do not know how to get out of and so have to ^C and start over.

I have tried the 'lookclear' and 'purge_all' method (both return a '1') and it still happens.

Even when I read part of the buffer, kill the program, and restart (with data still in the buffer) it may still happen

$AppMainBoard_Port = Win32::SerialPort->start ($app_cfgfile) @result=$AppMainBoard_Port->lookclear; print "Result: @result\n"; @result=$AppMainBoard_Port->purge_all; print "Result: @result\n"; for ($i=0 ;; ) { if ( $c = $AppMainBoard_Port -> input) { print "$c"; do_other-stuff; } }

I will get a print of $result, but often get a buffer overrun as soon as I get to 'input'

Since starting this post, I tried changing '->input' to '->read(4096)' which SEEMS to have solved the problem so far, but would be happy to hear what the Monks have to say!

Thanks, Chris


In reply to Serial Buffer Overrun by ccherri

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.