Close

Bug fixes + features

A project log for Serial to Parallel Printer Interface

Old school open hardware meets modern-day open hardware. Adding serial to the original ink-jet printer.

dan-julioDan Julio 10/28/2018 at 22:580 Comments

As often happens, a new usage for something uncovers issues.  That happened when I went to add the ability to print a banner to my retro-computer.  Up to this point the printer interface had never had to print anything harder than a few Tiny Basic listings.  Although I had tested the XON/XOFF flow control when I originally wrote the sketch, the implementation of banner in the computer ended up refreshing my knowledge of buffer management.  Ultimately the problem was a deep buffer in the computer coupled with a delay seeing the XOFF flow-control from the printer that over-ran the printer's 2 kB buffer (1 kB in the arduino, 1 kB in the HP printer itself).  But debugging the problem uncovered bugs in the printer code too.

The new, v1.1 code is included in the zip file for this project.  It fixes the following bugs.

  1. Remove a buffer near-full check on incoming data so the printer can continue to receive data (through the Arduino's RX buffer) even after it has requested flow control.
  2. Refactored the code that drove parallel bytes to the printer to not block the main thread waiting for the printer to report ready for writing.
  3. Changed how serial data was read in the main loop to make flow-control generation more accurate.
  4. Decreased the high-water buffer mark to allow for more data to be sent after flow-control has been requested.

In addition, this code has a new feature where it will echo back the ETB (End of Transmission Block) control character when that character flows through the RX buffer to the printer.  This allows external devices to know when buffered data in the arduino-side of the printer has been exhausted.  The idea is that the external device will include the ETB character as a marker.  When it sees the character echoed back it knows all the buffered data before the character has been loaded into the printer.  I make use of this in the banner functionality to show (more-or-less) on the screen what character is being printed.

Discussions