dshahin:

I've done tons of hardware interfacing. While it's a great idea to check your code, you may be trying to feed data to the cash register faster than it's able to consume it. Here are a couple of things you might try:

1) Check the manual for the cash register and make sure that your cable is correct. Many serial devices use hardware handshaking signals to regulate the data flow to a rate they can handle. If it uses hardware handshaking and you're using a serial cable wired to fool itself, you'll get the symptoms you describe.

I've seen this happen in lots of microcontroller-based hardware for example: many don't have a UART in them and they emulate the UART by bit-banging. When the microcontroller is busy doing something else (such as ejecting cash drawer, talking with LCD display, or some such) it can't be monitoring the serial channel. So they may use the CTS or DTR line to put a hold on incoming data.

2) Another thing I've encountered is that some devices don't use hardware handshaking, but they're not quite fast enough to handle a serial port going full-bore. You might try small delays after carriage returns to give the controller a chance to process the line before sending the next line.

One final note: Delays should be your last resort. Too often, people put them in, and it works most of the time. Then you add more delays, and it's a bag of rats. If the device uses hardware handshaking, you'll save yourself some grief by cabling it correctly rather than using arbitrary delays.

...roboticus


In reply to Re: Serial port losing data by roboticus
in thread Serial port losing data by dshahin

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.