Home   Archive   Permalink

serial receipt printer

Nick, did you write a generic serial printer driver? I bought a few receipt printers and before I attempt to write a basic driver for them, wonder if you have already done that.

posted by:   Graham       7-Feb-2011/23:02:35-8:00

Nope - we use standard brother Laser printers, but if you'd like some help, please let me know. I'd like to get to know the type of printers you're using. If you send me the specs, I'll be happy to work on some code...

posted by:   Nick       8-Feb-2011/9:00:36-8:00

They come with USB and serial ports, but only drivers for XP. So, I'd have to write a serial driver if I want to use them. Axiohm A758 is the printer model, and rebadged by NCR. Also comes with a cash drawer port.

posted by:   Graham       8-Feb-2011/14:53:43-8:00

I found the manual below - is it for the correct model?

posted by:   Nick       8-Feb-2011/22:14:50-8:00

yes, that's the same as I one I have.
Pity really, these are $400 printers being chucked out.

posted by:   Graham       9-Feb-2011/3:40:48-8:00

This _shouldn't_ be too difficult. REBOL serial port documentation is at http://www.rebolforces.com/archive/rep/rep004.html . Page 217 of the printer manual shows how to send hex control codes to the printer in DOS and BASIC. The Basic example is below:
     LPRINT CHR$(&H12); "ABC"; CHR$(&H0A)
Try this:
     printer: open/no-wait serial://
     insert printer #{12}
     insert printer to-hex to-integer #"A"
     insert printer to-hex to-integer #"B"
     insert printer to-hex to-integer #"C"
     insert printer #{0A}
     print copy printer
     close printer
You'll probably need to change REBOL's default serial port settings for port, speed, data bits, parity, stop bits, rts-cts, etc., based on how the machine is configured. The /binary, /direct and /no-wait refinements might also apply:
     printer: open/binary/direct/no-wait serial://com2/4800/8/none/1
     printer/rts-cts: false
     update printer
I'm not sure if you even need to convert the characters to hex, or if you could just send a string. Either way, a simple function to send each character in hex format could be something like:
send2printer: func [str] [
     foreach chr str [
         insert printer to-hex to-integer to-char chr
Since I don't have the hardware, I can't experiment with it at all. Lemme know how you progress!
There's a helpful thread about serial port usage here: http://www.rebol.org/ml-display-thread.r?m=rmlGCBQ

posted by:   Nick       9-Feb-2011/5:52:09-8:00