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.

        luaprinter_type.set("getnextchar", &luaprinter::getnextchar);
        luaprinter_type.set("putnextchar", &luaprinter::putnextchar);

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.

[Linked Image from i.imgur.com]