Billgamesh King of Uruk, the walled city

Images on 9front

KX P3124

The printer itself speaks PCL (Printer Control Language) and that has been easy enough to figure out. To send images, I have been using: ESC + '*' + m + nL + nH + data to send a line of bits to the print head for printing.

m = an arbitrary byte which sets the dot density
nL = (number of dot-columns) % 256
nH = (number of dot-columns) / 256
data = bytes of data to print. 1 bit=1 dot

I started with the Raspberry Pi, which is easy enough to set up a 9front CPU server on. However, 9front has no usblp drivers. While writing drivers is an eventual goal of mine, in order to avoid scope-creep, I decided to just use a x86_64 computer with a parallel port.

After installing 9front to the server however… the parallel port was not appearing in /dev/. I found the parallel port in the /sys/src/9/pc directory, but not in the pc64 directory. I asked about it on IRC and sigrid recommended I check pc64. Lo, there, under devices, was # lpt. I uncommented and rebuilt the kernel. Now I have /dev/lpt2data. The number depends on the port see /sys/src/9/pc/devlpt.c

Now, I just needed to be able to write to it. The following imports the printer to 9front on my laptop:

#!/bin/rc
rimport -b 192.168.0.102 '#L2' /dev

Piping text to it has the expected result: text is printed. I really wanted to figure out images though. My programming is a little rusty so I read through a manual for PCL ESC+’*’, and read a bunch of 9front manuals, and looked through other image software. Eventually, I found what I wanted: memdraw(2). I did it wrong a few times, and didn’t account for extra bytes in memdraw, but, eventually I had a working tool which took a plan9 image on stdin and sent out PCL on stdout.

It’s very WIP, but the version as of 2024/06/29 is included here:

Next step: