Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working on a pi? #136

Open
MrGloriousFast opened this issue Dec 28, 2022 · 8 comments
Open

not working on a pi? #136

MrGloriousFast opened this issue Dec 28, 2022 · 8 comments

Comments

@MrGloriousFast
Copy link

MrGloriousFast commented Dec 28, 2022

Hello i cant run this on a pi. i tested it successfully on my laptop.

lsubs output:

Bus 001 Device 013: ID 04f9:209d Brother Industries, Ltd QL-820NWB Label Printer

the udev rule on the pi:
ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="209d", SYMLINK="usb/lp0", OWNER = "pi"

it create the /dev/usb/lp0 file

but when i want to run the brother-ql i get this error:


`deprecation warning: brother_ql.devicedependent is deprecated and will be removed in a future release
INFO:brother_ql.backends.helpers:Sending instructions to the printer. Total: 9544 bytes.
Traceback (most recent call last):
  File "/home/pi/.local/bin/brother_ql", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/cli.py", line 147, in print_cmd
    send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/helpers.py", line 61, in send
    printer.write(instructions)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/generic.py", line 32, in write
    self._write(data)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/linux_kernel.py", line 55, in _write
    os.write(self.write_dev, data)
OSError: [Errno 22] Invalid argument
`

im using the following python script to run it:

import subprocess

cmd = [
    "brother_ql",
    "-m",
    "QL-820NWB",
    "-p",
    "file:///dev/usb/lp0",
    "-b",
    "linux_kernel",
    "print",
    "-l",
    "29",
    "image.png"
]

subprocess.run(cmd)

image.png is a normal image:

file image.png

give me this output:

image.png: PNG image data, 306 x 100, 8-bit/color RGB, non-interlaced

what can i do to print?

@MrGloriousFast
Copy link
Author

i changed the udev rule after reading another issue to:

ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="209d", SYMLINK="usb/lp0", MODE="0666"

still the same error

@MrGloriousFast
Copy link
Author

``i was curious what is even going on so i put the following print into the linux_kernel.py:

    def _write(self, data):
        print('write args:', self.write_dev, self.dev)
        os.write(self.write_dev, data)

and it just prints 4?

here is the output with the print:

deprecation warning: brother_ql.devicedependent is deprecated and will be removed in a future release
WARNING:brother_ql.conversion:Need to resize the image...
INFO:brother_ql.backends.helpers:Sending instructions to the printer. Total: 28702 bytes.
write args: 4 4
Traceback (most recent call last):
  File "/home/pi/.local/bin/brother_ql", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/cli.py", line 147, in print_cmd
    send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/helpers.py", line 61, in send
    printer.write(instructions)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/generic.py", line 32, in write
    self._write(data)
  File "/home/pi/.local/lib/python3.9/site-packages/brother_ql/backends/linux_kernel.py", line 56, in _write
    os.write(self.write_dev, data)
OSError: [Errno 22] Invalid argument

@MrGloriousFast
Copy link
Author

also i tried this:

$ echo "asd" > /dev/usb/lp0 -bash: echo: write error: Invalid argument

@FriedrichFroebel
Copy link

What do you mean by the following sentence?

it create the /dev/usb/lp0 file

/dev/usb/lp0 is a USB device socket and no real file - you should never create it yourself. When the printer is connected, you should be able to see the active devices using ls -l /dev/usb - the actual device name might differ.

and it just prints 4?

This is correct, as the backend writes to a plain file descriptor, which is identified by a simple integer.

@MrGloriousFast
Copy link
Author

MrGloriousFast commented May 10, 2023

Still not working. Same as above.

When i plug the printer into the usb socket /dev/usb/lp0 is there and i can see it via the ls command. if i unplug the printer the 'not real file' is not there.

when i type:
brother_ql -b pyusb discover

it outputs:

depreciation warning: brother_ql.device dependent is depreciated and will be removed in a future release
INFO:brother_ql.output_helpers: Found a label printer: usb://0x04f9:0x209d_ (model: unknown)

What can i do? How can i start printing?

i tried using the other backend (pyusb instead of linux-kernel) but i get a resource busy error. i used the following line:

brother_ql -m QL-820NWB -p usb://0x04f9:0x209d -b pyusb print -l 29 image.png

usb.core.USBError: [Errno 16] Resource busy

pls help me i am lost!

@FriedrichFroebel
Copy link

Is the Editor Lite mode disabled on the device? What is the current error when you try printing to /dev/usb/lp0 with the correct model and udev rules set up?

@MrGloriousFast
Copy link
Author

MrGloriousFast commented May 12, 2023

I wouldn't know how to turn on or off the 'Editor Lite mode'. Is this a Button on the printer? I looked all around and couldn't find one.

The error is the same as stated in the posts above.

Also tried the network backend. No luck.

$python print.py
brother_ql -m QL-820NWB -p tcp://192.168.178.35 -b network print -l 29 qr.png
depreciated warning: brother_ql.devicedependent is deprecated and will be removed in a future release
WARNING:brother_ql.conversion:Need to resize the image...
INFO:brother_ql.backends.helpers:Sending instructions to the printer. Total: 28702 bytes.

and then nothing. No printing. no LED on the printer blinks. no further commandline output.

After mroe tinkering i noticed that the wifi setting of the printer was turned on and i had to turn it off. now it could print via the network backend.

@Andr3wJ79
Copy link

Raspberry OS 32 bit Bullseye

usb.core.USBError: [Errno 16] Resource busy

Try remove ipp-usb: sudo apt remove ipp-usb

My printer rules (QL-810Wc):

SUBSYSTEM=="USB",ATTR{idVendor}=="04f9", ATTR{idProduct}=="209c", MODE="0666"

and a print command:

brother_ql -m QL-810W -p usb://0x04f9:0x209c print -l 62red --red img.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants