Moving the thermal printers to the NAS

I have a lot of various passions, and one of them is exotic printing gear.

As a teen I played a lot with electronic typewriters: I had access to two of them as computers quickly replaced them. I could play with the abandoned machines while grown up people would just use a computer and an Inkjet printer to get the real stuff done. Yes, inkjet, because I am not this old and just had the chance to stumble upon old typewriters stored in the attic for years.

They were funny: you could edit one line on the small LCD screen, and pressing the enter key would print the whole line loudly. The result looked the same as with a regular typewriter, but you could tell that it was an electronic one because the pressure applied to each character was uniform; there were no difference in letter opacity compared to a manual typewriter. On regular typewriters, you usually get angry at the machine jamming, fix it, and press a key very strong to prove your point: the result looked like a bold letter compared to the previous ones.

This hobby — with many others — has followed me during college when I bought a cheap USB receipt printer on Amazon with a bunch of paper rolls. Without Amazon I would have not be able to get this imported cheap printer so easily, as professional retailers would charge premium for an Epson thermal printer that was not affordable for someone just wanting to play with. The 30€ or so I payed for a cheap noname copy seemed fair in comparison. I used it to generate various reports as the cost per receipt was (and still is) way lower than printing an A4 sheet using my monochrome laser printer.

Since then, this printer has been connected on my desktop computer for some years and I tinker with it from time to time.

Another printer I acquired more recently, and which also uses the thermal printing technology, is a label printer from DYMO. It is labeled LabelWriter 450 (pun intended) and I picked it because it was compatible with the Linux platform. It works like a charm with CUPS and has helped me label a lot of boxes and stuff around in my attic. This printer also has been connected to my desktop computer for about a year.

As both printers are connected to the desktop, it means that whenever I would like to print a receipt for fun just because I can, or print a label for a shoebox that will store various items, I have to bring on the desktop on. This is quite a hassle, because I usually do most of the stuff using my laptop while reserving my main computer for playing videogames or compiling big stuff.

This is why I am decided to move both thermal printers to my home-assembled NAS computer that always stays on. I will then be able to share them on my local network and print from both the desktop and the laptop.

Moving up

First step is to physically move them from the desktop to the NAS. As I took cable management quite seriously over the years, a few ziptie cuts away and I can move the printers to their new location, and plug them on both AC power and on the NAS using the now-too-long USB cables.

A photo of the two thermal printers next to each other.

The two printers are well fitting side by side over the NAS and under the next level of the shelf. For the label printer, the labels can be grabbed quite easily. For the receipt printer however, the paper exit is more in the back and thus less accessible. My idea was to be able to see whatever has been printed without having to tear the paper, but this is now the only option as the receipt will quickly wrap behind the printer because of the upper shelf plate.

The very first label I printed on the LabelWriter was the reference and dimensions of the label roll I originally inserted into the machine, as I was always trying to figure out what where the label dimensions while tinkering with it. This label I sticked on the front of it is now obsolete, as I have changed the unfinished roll for a bigger label size one. However, I did not manage to remove the label properly as it has been applied about a year ago. I tried to pull it but it started to tear down. I am afraid to apply the label remover — that works great but smells like gasoline — as it may attack the printer's plastic along with the label glue, so I did not try this option (yet?).

Sharing the label writer using CUPS

Now that everything is wired physically, we will have to do the virtual wiring next. As I am using the Proxmox environment for my NAS to host multiple virtual machines, I need to tell it on which virtual machine I wish to connect both the USB devices. This I have already done for my laser printer that is now shared on one VM using CUPS, so it is quite easy to do the same (and reboot the VM for the changes to apply).

Then, we can install the printer on the VM using CUPS; but before, one need to install the printer-driver-dymo package in Debian. This package contains all the drivers and PPD files for many Dymo printers such as the LabelWriter 450 I am using. Without it, the printer will not behave correctly and many options like DPI setting will be missing. If the package is installed, then CUPS is able to correctly find the correct driver to use for the LabelWriter 450 model.

We can then print a test page. If you selected the correct label size, the CUPS test page should fill perfectly the label square. The text will be too tiny to check, but the most important is that the borders match the label dimensions and does not overflow on multiple labels. After this step is reached, we can print real labels using gLabels.

A photo of a label getting out of the printer with CUPS info.

It seems like CUPS is artificially adding blanks on the side of the labels, but I did not took time to figure out what is happening. This means that text can be cut out if too close from the borders.

Finally, we are good to install the printer on the other computers on the network. On each computer, we will also need to install the Dymo drivers package for the local CUPS instance to be able to correctly communicate with the remote printer and configure it properly (for example, switch from 300x300 DPI to 600x300 DPI when printing images or barcodes).

There may be a way to use a generic driver instead of installing the Dymo one on each machine, but since all of my machines are on Debian this is an apt-get away and I get full control of the label printer this way instead of using a generic driver.

Sharing the receipt printer

The receipt printer uses a text-based device driver to work, so using CUPS will be overkill as it will first have to raster a document and then print it as an image. It is better for this kind of printer to directly talk to it using the text interface of the driver.

For making things easier, and if you plain to do some formatting and eventually print images or barcodes, a userspace library is recommended to produce the correct escape codes before sending them on the text interface to enable various functionnalities.

My personnal choice is python-escpos as I am a fluent Python user and as it makes little sense to choose a compiled language for something that is very much more I/O than CPU bound: the receipt takes way more time to print than the printer to generate the escape codes.

But how do you share the printer access as it only consists of serial USB device access? Well, you mostly cannot, because the USB device is bond to the host.

I have not figured a final solution yet, but I see two options:

  • create a script that will copy a local python script to the NAS using scp and then run it on the remote host using ssh; or
  • put in place a TCP network share of the printer using netcat (nc) so that the library outputs to stdout and is piped to nc to transfer the raw bytes to a listening server that will output received content to the USB printer.

Both solutions could work, but the former would be way simpler to put in place. I have started to work on it, but there are some access problems to the device has I did not yet write a proper udev rule to provide user access to this USB device by matching its vendor and device ID.

Well, the label printer was more important anyways as I use it more often, and it now works like a charm and I can print labels from my couch. How nice is that?