DOC improve doc on network printing

This commit is contained in:
Patrick Kanzler 2016-01-17 16:00:03 +01:00
parent 720545979c
commit ae37de2577
1 changed files with 12 additions and 2 deletions

View File

@ -139,7 +139,17 @@ class Network(Escpos):
""" Network printer """ Network printer
This class is used to attach to a networked printer. You can also use this in order to attach to a printer that 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 `netcat`. is forwarded with ``socat``.
If you have a local printer on parallel port ``/dev/usb/lp0`` then you could start ``socat`` with:
.. code-block:: none
socat -u TCP4-LISTEN:4242,reuseaddr,fork OPEN:/dev/usb/lp0
Then you should be able to attach to port ``4242`` with 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.
""" """
def __init__(self, host, port=9100, *args, **kwargs): def __init__(self, host, port=9100, *args, **kwargs):
@ -154,7 +164,7 @@ class Network(Escpos):
self.open() self.open()
def open(self): def open(self):
""" Open TCP socket and set it as escpos device """ """ Open TCP socket with ``socket``-library and set it as escpos device """
self.device = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.device = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.device.connect((self.host, self.port)) self.device.connect((self.host, self.port))