I made a luaprinter for both centronics and rs232 and was having some trouble sorting out why it was dropping characters for the serial port.
Still sorting it out, gonna try a mutex, but I thought why not try to "replay" a print job to the lua printer.
It's pretty easy, just put chars into the buffer with putnextchar(). First I had to add putnextchar to luaengine which was trivial.
I made a printout with the regular serial printer, and -printout test.txt to send it to a file.
Then did this from the console:
f = io.open("test.txt")
filedata = f:read("*a")
for i=1,#filedata do lp0:putnextchar(string.byte(filedata,i)) end
and to "print" it again, this time with a different xdpi for instance:
xpos=0 ypos=0 lp0:clearpage() paperxdpi=72 for i=1,#filedata do lp0:putnextchar(string.byte(filedata,i)) end
Of course this is only going to work if it fits entirely into the buffer.