---

Rildo Pragana: Running a GDI printer under Linux — part 6 – Writing the printer software

[ Thanks to Rildo
Pragana
for this link. ]

In this final article of the series I will look at some
details when writing the actual printer software. The main idea, as
I said before, is to simulate the nearest possible the original
working driver (under the other OS), so you will not have to think
too much with command details nor discover the meaning of all
registers inside the printer interface.
If it works for the
other, it will work for Linux as well. Of course, there will be
found problems with timings, required commands (most are garbage,
as you will discover, which explains why my Linux driver is twice
as faster), and some minimum parameters to setup a correct printing
image. The easiest way to get the parameters is printing with
several page sizes but the same material (say, a image in
MS-paintbrush) and noticing what changed between the captured data
for both cases.”

“The pulses timings are more difficult to get. You will have to
experiment with them, placing delays with usleep() or even sleep().
Get first the log generated by Bochs, calling the function
bx_printf() at the devices.cc source file to get the timings in
machine clocks and convert them to microsecond units. I have
rewritten several times my Linux driver to get the best fit.”

“This article will be a tour through my printer driver’s
implementation, so you get a feeling of what to do after starting
discovering your printer. As I have done myself, you can start to
code your driver even before everything is well understood, if you
follow the mimic principle. Much functionality of my printer was
discovered that way, as my first driver was very crude to be
useful. I dare you to write a working driver, even if it only write
a tiny line, like my first experiment. Go ahead! Make your printer
sing!”

Complete
Story