mounaiban / captdriver

Driver for Canon CAPT printers
GNU General Public License v3.0
87 stars 16 forks source link

Support LBP6020 #22

Open gbThreepwood opened 2 years ago

gbThreepwood commented 2 years ago

I am trying to add support for the LBP6020 printer. So far all I have done is add the line register_printer("LBP6020", lbp6000_ops.ops, EXPERIMENTAL); to prn_lbp2900.c, in hope that it would magically make the printer work. Unfortunately it does not appear to be sufficient.

The last four lines of the CUPS error_log file are:

W [21/Oct/2022:20:36:40 +0200] [Job 12] support of LBP6020 is experimental
E [21/Oct/2022:20:41:19 +0200] [Job 12] Unable to send data to printer.
E [21/Oct/2022:20:41:20 +0200] [Job 12] CAPT: bad reply from printer, expected A8 A0 xx xx xx xx, got
W [21/Oct/2022:20:41:20 +0200] [Job 12] Backend returned status 1 (failed)

I do not have much experience in reverse engineering printer protocols, but next on my TODO list is some experiments with Wireshark.

gbThreepwood commented 2 years ago

While trying to get Wireshark to capture the USB traffic the printer suddenly started operating. I have added and removed the printer from CUPS a few times and also restarted my laptop, but I have not made any other changes to the source code. At the moment the printer seems to operate reliably, but the prints are in the wrong scale so I only see half the page I try to print.

mounaiban commented 2 years ago

Thanks for opening this, I forgot all about the LBP6020! Just in case you haven't found out, there's a CAPT Wireshark Lua Dissector in my other repo.

Based on your success with re-using LBP6000 code, I am going to hazard a guess that the '6020 is very similar to the '6000/6018. I am also guessing the issue is caused by either:

mounaiban commented 1 year ago

@gbThreepwood also if you don't mind, I would be grateful if you would post the response to the 0xA1A1 command for your LBP6020, either here or in agalakhov#38. I'm trying to figure out the information returned by 0xA1A1. Thanks in advance!

gbThreepwood commented 1 year ago

Thanks for your replies. I have not had the time to do any further research on my printer yet, but here is the response I get on the A1A1 command:

a1 a1 40 00 00 0b bd 09 01 01 f0 ff 00 01 04 00
67 00 01 03 38 04 00 00 6f 08 00 00 e4 0d 00 00
00 00 00 00 fa 02 00 00 58 07 00 00 32 32 32 32
58 02 58 02 1f 04 04 00 00 14 02 00 00 00 00 00
frantimon commented 1 year ago

Hi guys,

first of all, allow me to say that highly admire the amount of dedication you put into making this project work.

I have a Canon LBP-6020 printer that I'm trying to make to work on Raspberry PI 3 A+. I've tried installing versions of 32- and 64-bit Raspbian, as well as 64-bit Ubuntu server and trying to get the printer running using Canon drivers available here, but without any luck.

In the meantime, I encountered your project and was wondering if we could maybe share knowledge and if you would help me adapt your project to add support for the aforementioned printer.

Best regards and keep up the good work!

mounaiban commented 1 year ago

@frantimon The Canon drivers were never going to work on the Raspberry Pi, because they were only compiled for x86-architecture systems. Only 'regular' PCs can run the Linux CAPT drivers, and then only with older GNU/Linux distros (Chromium OS doesn't count, but I could be wrong).

Ubuntu 14.04 was the last Ubuntu that I have successfully used it with, using a process adapted from @nerk's CAPT Printers on Ubuntu. I just substituted containers for a VM.

Are you good with Wireshark, and do you have a lot of patience? The first step would be to discover missing commands required for correct LBP6020 support. I have been capturing and analysing USB traffic from macOS and Windows with the official drivers to discover the commands. Hopefully, my CAPT dissector might help make things easier.

Once you know the commands, add them to src/prn_lbp2900.c. I'll be assuming that you would have an idea how the CAPT protocol works, that is important to help decide where to run the commands...

frantimon commented 1 year ago

@mounaiban Thank you for the feedback and sorry for the delay in replying. I do have some basic knowledge about how CAPT works, but am willing to learn more. Can you point me in the right direction in terms of what exactly to do and what to sniff for with Wireshark? Sorry for coming like this out of the blue, but I thought if you could help me save time sharing some of your knowledge and findings, then I might be able to invest this time in something more useful, such as contributing with whatever you need in terms of LBP-6020 support.

In the meantime, it might be useful to note that I managed to get the printer to run on more recent versions of Ubuntu/Mint using the following script.

mounaiban commented 1 year ago

@frantimon thanks for posting the script!

Here's how we analyse the communications protocol:

On a host system (virtual machine or a physical device) running the official Canon drivers, run Wireshark and log USB traffic between the host and the printer device. While the packet capture is running, send a print job. If everything is done right, Wireshark should be able to capture communications between the host and the printer.

We will usually start looking at the commands sent to the printer device right before the actual page. Page data is sent in the following commands on all known devices: 0xD0A0, 0xC0A0 and 0xC0A4 (see src/capt-command.h for details). We are looking for commands other than these, and such commands are the ones that vary between devices.

We are expecting page-related commands to be sent only once per page.