Printer implementations¶
Module escpos.printer
This module contains the implementations of abstract base class Escpos.
| author: | Manuel F Martinez and others |
|---|---|
| organization: | Bashlinux and python-escpos |
| copyright: | Copyright (c) 2012 Bashlinux |
| license: | GNU GPL v3 |
-
class
escpos.printer.Dummy(*args, **kwargs)¶ Bases:
escpos.escpos.EscposDummy printer
This class is used for saving commands to a variable, for use in situations where there is no need to send commands to an actual printer. This includes generating print jobs for later use, or testing output.
inheritance:
-
close()¶
-
output¶ Get the data that was sent to this printer
-
-
class
escpos.printer.File(devfile=u'/dev/usb/lp0', *args, **kwargs)¶ Bases:
escpos.escpos.EscposGeneric file printer
This class is used for parallel port printer or other printers that are directly attached to the filesystem. Note that you should stay away from using USB-to-Parallel-Adapter since they are unreliable and produce arbitrary errors.
inheritance:
-
close()¶ Close system file
-
flush()¶ Flush printing content
-
open()¶ Open system file
-
-
class
escpos.printer.Network(host, port=9100, timeout=60, *args, **kwargs)¶ Bases:
escpos.escpos.EscposNetwork printer
This class is used to attach to a networked printer. You can also use this in order to attach to a printer that is forwarded with
socat.If you have a local printer on parallel port
/dev/usb/lp0then you could startsocatwith:socat -u TCP4-LISTEN:4242,reuseaddr,fork OPEN:/dev/usb/lp0
Then you should be able to attach to port
4242with this class. Otherwise the normal usecase would be to have a printer with ethernet interface. This type of printer should work the same with this class. For the address of the printer check its manuals.inheritance:
-
close()¶ Close TCP connection
-
open()¶ Open TCP socket with
socket-library and set it as escpos device
-
-
class
escpos.printer.Serial(devfile=u'/dev/ttyS0', baudrate=9600, bytesize=8, timeout=1, parity='N', stopbits=1, xonxoff=False, dsrdtr=True, *args, **kwargs)¶ Bases:
escpos.escpos.EscposSerial printer
This class describes a printer that is connected by serial interface.
inheritance:
-
close()¶ Close Serial interface
-
open()¶ Setup serial port and set is as escpos device
-
-
class
escpos.printer.Usb(idVendor, idProduct, interface=0, in_ep=130, out_ep=1, *args, **kwargs)¶ Bases:
escpos.escpos.EscposUSB printer
This class describes a printer that natively speaks USB.
inheritance:
-
close()¶ Release USB interface
-
open()¶ Search device on USB tree and set it as escpos device
-