question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can we send data to cups server and print from there instead of usb or serial? I tried Network but seems not working. I also tried PR#348 but failed-perhaps it is incompatible for today’s python-escpos.Any solutions?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
SydneyOwlcommented, Aug 10, 2022

I use pip install -U git+https://github.com/belono/python-escpos.git@f07d5e06109e37aa45a5a139f49f56d6399b98d3 instead of pip install -U git+git://github.com/python-escpos/python-escpos/pull/348/commits/f07d5e06109e37aa45a5a139f49f56d6399b98d3. Pip failed to clone pr via git+git://, so I used the former one. I made some changes to your code (constructor of CupsPrinter(Escpos)) to enable connecting to remote CUPS server:

def __init__(self, host=None,port=None,printer_name=None, *args, **kwargs):
            Escpos.__init__(self, *args, **kwargs)
            if host!=None:
                cups.setServer(host)
            if port!=None:
                cups.setPort(port)
            self.conn = cups.Connection()
            self.tmpfile = None
            self.printer_name = printer_name
            self.job_name = ''
            self.pending_job = False
            self.open()

And according to your instruction I ran

import escpos.printer as printer

cups_conn = printer.CupsPrinter(host="192.168.2.1",port=631,printer_name="XP-58IIH")  # Default CUPS printer
cups_conn.textln("Hello CUPS!")  # or any python-escpos command
cups_conn.close()

It works!

Here are detailed info of my devices. Hope they’re useful to you.

CUPS server: raspi zero w, Linux raspberrypi 5.15.32+ #1538 Thu Mar 31 19:37:58 BST 2022 armv6l GNU/Linux Printer: XP-58IIH print request sender: an simple armv7l device based on armbian

0reactions
SydneyOwlcommented, Aug 12, 2022

Glad that I could be of help😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

CUPS.org
The standards-based, open source printing system developed by Apple for iOS ®, iPadOS ®, and macOS ®. CUPS uses IPP Everywhere™ to support...
Read more >
OpenPrinting CUPS
CUPS supports printing to: ... CUPS provides the System V ("lp") and Berkeley ("lpr") command-line interfaces, a configurable web interface, a C API,...
Read more >
Service - CUPS | Ubuntu
The primary mechanism for Ubuntu printing and print services is the Common UNIX Printing System (CUPS). This printing system is a freely available,...
Read more >
Introduction to CUPS - Configuring and Managing Printing in ...
CUPS includes support for dynamic printer detection and grouping. CUPS replaces the lpr command with its own command and the LPD printer drivers...
Read more >
CUPS - Wikipedia
CUPS is a modular printing system for Unix-like computer operating systems which allows a computer to act as a print server. A computer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found