I am writing to an embedded system over a serial port. The system is extremely limited and writing to it any faster than 50ms per character causes data to be dropped/lost. ... What I believe is happening is that each character gets buffered and finally the entire string gets spit out to the serialport at once, which of course cannot respond fast enough.

It seems your embedded system does not use any kind of handshake, telling the "big" system that it can't handle more data. RTS/CTS and XON/XOFF can be handled in hardware or by the OS, so everything would be completely transparent to your application. In the worst case, the OS would tell you it could deliver only n bytes, when you wanted to write m bytes (with n < m). In that case, you would have to try writing the remaining bytes again. (Any serial I/O library should handle that for you.)

Try enabling (or adding) handshaking at RS232 level and all your problems should be gone. If the embedded device can handle really slow RS232 speeds, try connecting at a low speed, eg. 300 or even 75 bits per second. This should at least reduce your problem.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Writing to serial port with a delay between each character by afoken
in thread Writing to serial port with a delay between each character by sidthakur

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.