Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Serial Buffer Overrun

by ccherri (Novice)
on Dec 19, 2012 at 22:38 UTC ( #1009655=perlquestion: print w/ replies, xml ) Need Help??
ccherri has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Serial Buffer Overrun
Download Code
Re: Serial Buffer Overrun
by jmlynesjr (Pilgrim) on Dec 20, 2012 at 02:48 UTC

    Buffer Overrun indicates that the UART's input buffer was not read(emptied) when the next character was received. At 9600 baud a character shows up about every millisecond. Your system occasionally gets busy and doesn't get back to service the UART in time. Other options are to try at 4800 baud if that is an option or use xon/xoff or rts/cts handshaking/flow control.

    James

    There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1009655]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-08-01 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls