Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

There are a lot of assumptions (on my behalf) inferred from the information you have given us.

14 bytes sounds like the default FIFO buffer size for COMn: ports (under win32 anyway).

That you get the first 14 bytes and no more suggests that some form of handshaking is involved. That it isn't being reset automatically means that it (the comm port) is probably set up for software (Xon/Xoff) handshaking.

If you are on a win32 system, the easiest way to verify this would be to open a CMD window and issue the command:

C:\test>mode com1 /STATUS Status for device COM1: ----------------------- Baud: 1200 Parity: Even Data Bits: 7 Stop Bits: 1 Timeout: OFF XON/XOFF: OFF CTS handshaking: OFF DSR handshaking: OFF DSR sensitivity: OFF DTR circuit: ON RTS circuit: ON C:\test>

That was from the (currently inactive) com1 on my NT system.

If you are simply reading from the port and want to 'slurp' as much as possible, you could use the control-panel->ports (or the mode command (see help mode) to switch the handshaking off.

This isn't going to help much if the device attached to the other end needs the hadshaking though. If the device is waiting for you to empty the buffer, and has recieved an Xoff (ascii 14?) ... it will be waiting for an Xon (ascii 15?). Maybe just writing the appropriate one will restart the flow. There is probably a module that will take care of this nastiness for you on CPAN.

Of course, if your not using win32, ignore me and wait for one of the "real programmers" to supply similar info for *nix systems:)

In reply to Re: Reading data from the Serial Port by BrowserUk
in thread Reading data from the Serial Port by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.