Sam Imberman   About Me

Bootstrapping a receipt printer in Linux

I love playing with different display media, and receipts are one of my favourite. Here is how I managed to print from a Bixolon SRP-350plusCOPG under Linux. More on my projects in another post (or five).

Set up the printer as a serial device

These instructions are taken from the python-escpos documentation. They will let you write to the printer as a serial device.

I’m assuming you have a Debian machine set up and more-or-less working, and that you can futz around at a terminal a little bit. I’m using Debian testing (buster) on this machine, but these instructions should work in many recent Debian or Ubuntu versions.

Plug in the printer, turn it on, and run: sudo dmesg | tail. This will print the last few things that have happened to the computer. You should have output like:

[ 7905.706142] usb 1-6: New USB device found, idVendor=1504, idProduct=0006
[ 7905.706144] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7905.706146] usb 1-6: Product: BIXOLON SRP-350plus
[ 7905.706148] usb 1-6: Manufacturer: SAMSUNG ELECTRONICS CO.,LTD
[ 7905.707269] usblp 1-6:1.0: usblp1: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid 0x1504 pid 0x0006

Note the idVendor and idProduct codes; you need them for the next stop.

In order to make the user able to write to the printer, you will need to add a rule to udev (the Linux device manager) to allow individuals in the dialout group to write to the printer, and then add your own user to that same group.

Run sudo gedit /etc/udev/rules.d/99-escpos.rules and paste the following:

SUBSYSTEM=="usb", ATTRS{idVendor}=="1504", ATTRS{idProduct}=="0006", MODE="0664", GROUP="dialout"

but replace the idVendor and idProduct with the ones you wrote down.

Now you will have to add yourself to the dialout group. Use:

sudo usermod -a -G dialout yourusername

…but replacing yourusername with your actual username.

Now restart udev with sudo service udev restart and restart your terminal so that you are in the correct group. Unplug and re-plug your receipt printer, and it should now work. If it doesn’t, try rebooting first.

A test script

One way to check that the printer is working correctly is to run a quick Python script which will use the ESC-POS protocol to print something directly. You will need Python and pip installed, and use pip to install the python-escpos package. Here is such a script:

import os, sys
from escpos import *

rpr = printer.Usb(0x1504, 0x0006)

rpr.set("center", "A", "normal", 2, 2)
rpr.text("Hello, world!")

rpr.cut()

Check out the python-escpos documentation to get deeper than this.

Using CUPS

Bixolon also publishes CUPS drivers that let you use the receipt printer like any other printer. In my case they worked, but only after I made sure that the printer was at the most recent version of its firmware. You can get the firmware by contacting Bixolon support.