Dot Matrix Printer Client

A one day hack to enable easy printing over USB from my mac, to my Dot Matrix Printer.
2 min read

I recently was given an old Dot Matrix Printer. From what I can gather, it was new around 2006-ish. Maybe. They have drivers available for Windows on their site. For MacOS - no joy. Nor would I want to install what I imagine likely over engineered and non-free.

In trying to see if macOS would figure out what to do with it - my Mac decided to configure it as a generic PostScript printer. This had the fun side effect of it printing two pages worth of PostScript commands as it tried to detect features. So clearly - the USB interface is pretty much just an onboard serial adapter and if we can get ahold of it, we can send text and print.

I was originally going to buy a DB25 to USB adapter, which probably is the more ‘universal’ way of doing this, and then I could just cat X > /dev/ttyUSB.... But what’s the fun in that.

So, I vibe hacked this client together to interact with it. I figured if I could get access to the device over USB, I could just pipe data into the device and it would print it out.

Process

It does the following:

  1. Open the user file on disk to check it exists, parse args (I added a --print-line-numbers for code printing).
  2. Init libusb via libusb_init
  3. Claim the device via it’s vendor/product ID libusb_open_device_with_vid_pid
  4. Claim the first interface the device exports libusb_claim_interface
  5. Open the file, and buffer it out line by line, prepending line numbers.
  6. Close and clean up usb/file.

https://github.com/richinfante/ml1120-usb-print

Initial Test - Success!

ml1120 printing test

Feedback

Found a typo or technical problem? report an issue!

Subscribe to my Newsletter

Like this post? Subscribe to get notified for future posts like this.