Dotmatrix Printer and Raspberry PI
Posted: Tue Oct 07, 2014 11:48 am
by vachhaninimiT
Greetings everybody,
I have attached LQ-300+ 24 pin printer to my Raspberry Pi using usb to LPT cable. I want the dotmatrix printer to print each line i send to it using Python.
Any guidance is helpful.
Re: Dotmatrix Printer and Raspberry PI
Posted: Tue Oct 07, 2014 7:47 pm
by W. H. Heydt
When you say "USB to LPT" do you mean "USB to serial" or "USB to Centronics parallel"? (Shouldn't make a difference. Just curious as to what the actual interface is.)
You should be able to send data to the device as if it is a file (that being the way unix/Linux work). You may have to change the permissions on the device node for your program to do it. You will also have to open the :"file" that is the printer, and you should close it when you're done. Be sure to send both a linefeed *and* a carriage return at the end of each line.
If you don't need to see the program output "on the fly" (that is, each line as it is generated), you could write the data to a file and then issue an lp command to print it (assuming you have installed the printer through CUPS).
FYI...I have done direct printing on both serial and parallel printers attached to a unix system, and the "write a file and invoke lp" method using a network attached printer. Granted...I did it in C, not Python, but the OS doesn't care about that distinction.
For a "drop a file and print" to a laser printer, here is the code:
sprintf(cmd, "lp -oraw -d hp2055dn %s", ptr_file_name);
system(cmd);
Re: Dotmatrix Printer and Raspberry PI
Posted: Tue Oct 07, 2014 8:21 pm
by fruitoftheloom
vachhaninimiT wrote:Greetings everybody,
I have attached LQ-300+ 24 pin printer to my Raspberry Pi using usb to LPT cable. I want the dotmatrix printer to print each line i send to it using Python.
Any guidance is helpful.
LPT = Parallel Port
http://en.wikipedia.org/wiki/Parallel_port
Does lsusb recognise the USB-LPT Adaptor correctly and does the Printer work via CUPS?