vivier / phomemo-tools

CUPS driver for Phomemo M02 Label Printer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

T02 Phomemo seems incompatible - printing does not occur

stubkan opened this issue · comments

I acquired a little T02, hoping to replace my large thermal printer with it. I assumed from this repo that I would be able to use it, however it appears this may not be the case.

I have Ubuntu 22.04, and have cups, pybluez already installed on my system, no problems. Made and installed the cups driver from this repo, then went and paired the T02 device in bluetooth settings. But when I get to the Printer window, there is no T02 to be seen. I confirm the Phomemo driver is installed, as I can add a CUPS-BRK driver using the Phomemo M02 template, and tried to print to the T02 using that, but every time I print, it says it printed successfully then nothing at all happens.

Either I set up something wrongly, or the T02 is not supported?

Confirmed I have the prequisites;
cups is already the newest version (2.4.1op1-1ubuntu4.7).
Requirement already satisfied: pybluez in /usr/lib/python3/dist-packages (0.23)

The T02 does not show up in the printer devices when I try to add it here, as per the instructions;

image

So I tried to manually add it anyway, by creating a generic CUPS-BRF driver for M02 and named it T02;

image

This is the added printer info from localhost:631 CUPS interface;

image

Here is my cups access log;

localhost - - [03/Nov/2023:00:00:02 +0000] "POST / HTTP/1.1" 200 349 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:00:02 +0000] "POST / HTTP/1.1" 200 176 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:02:34 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:04:49 +0000] "POST / HTTP/1.1" 200 276 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:04:52 +0000] "POST / HTTP/1.1" 401 147 CUPS-Get-Devices successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:04:52 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:04:52 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - - [03/Nov/2023:00:05:54 +0000] "POST / HTTP/1.1" 401 147 CUPS-Get-Devices successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:05:54 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:05:54 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - - [03/Nov/2023:00:06:26 +0000] "GET /admin/conf/cupsd.conf HTTP/1.1" 401 0 - -
localhost - stubkan [03/Nov/2023:00:06:26 +0000] "GET /admin/conf/cupsd.conf HTTP/1.1" 200 4690 - -
localhost - - [03/Nov/2023:00:06:26 +0000] "GET /admin/conf/cupsd.conf HTTP/1.1" 401 0 - -
localhost - cups-pk-helper [03/Nov/2023:00:06:26 +0000] "GET /admin/conf/cupsd.conf HTTP/1.1" 200 4690 - -
localhost - - [03/Nov/2023:00:07:47 +0000] "POST / HTTP/1.1" 401 147 CUPS-Get-Devices successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:07:47 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:07:47 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:07:52 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:07:52 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - - [03/Nov/2023:00:07:53 +0000] "POST / HTTP/1.1" 200 5462486 CUPS-Get-PPDs -
localhost - - [03/Nov/2023:00:08:10 +0000] "POST / HTTP/1.1" 200 8498 CUPS-Get-PPD -
localhost - - [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 401 8549 CUPS-Add-Modify-Printer successful-ok
localhost - stubkan [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 8549 CUPS-Add-Modify-Printer successful-ok
localhost - - [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 401 166 Resume-Printer successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 166 Resume-Printer successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 166 CUPS-Accept-Jobs successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 166 CUPS-Set-Default successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 188 CUPS-Add-Modify-Printer successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:08:41 +0000] "POST /admin/ HTTP/1.1" 200 203 CUPS-Add-Modify-Printer successful-ok
localhost - - [03/Nov/2023:00:08:44 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 415 Print-Job successful-ok
localhost - - [03/Nov/2023:00:08:44 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:11:46 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:11:46 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:17:02 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 316 Create-Job successful-ok
localhost - - [03/Nov/2023:00:17:02 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 274339 Send-Document successful-ok
localhost - - [03/Nov/2023:00:18:33 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 316 Create-Job successful-ok
localhost - - [03/Nov/2023:00:18:33 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 274336 Send-Document successful-ok
localhost - - [03/Nov/2023:00:22:23 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 316 Create-Job successful-ok
localhost - - [03/Nov/2023:00:22:23 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 274336 Send-Document successful-ok
localhost - - [03/Nov/2023:00:24:01 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:24:01 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:24:01 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:24:01 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:24:22 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:24:22 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:24:22 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:24:22 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:24:34 +0000] "POST /jobs/ HTTP/1.1" 200 142 Restart-Job successful-ok
localhost - - [03/Nov/2023:00:25:20 +0000] "POST /jobs/ HTTP/1.1" 200 157 Cancel-Job successful-ok
localhost - - [03/Nov/2023:00:25:27 +0000] "POST /jobs/ HTTP/1.1" 200 157 Cancel-Job successful-ok
localhost - - [03/Nov/2023:00:25:32 +0000] "POST /jobs/ HTTP/1.1" 200 157 Cancel-Job successful-ok
localhost - - [03/Nov/2023:00:25:53 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:53 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:53 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:53 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:25:54 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:25:59 +0000] "POST /jobs/ HTTP/1.1" 200 157 Cancel-Job successful-ok
localhost - - [03/Nov/2023:00:26:00 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:26:00 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:26:00 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:26:00 +0000] "POST / HTTP/1.1" 200 365 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:27:42 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 316 Create-Job successful-ok
localhost - - [03/Nov/2023:00:27:42 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 367503 Send-Document successful-ok
localhost - - [03/Nov/2023:00:27:54 +0000] "POST / HTTP/1.1" 200 276 Create-Printer-Subscriptions successful-ok
localhost - - [03/Nov/2023:00:27:56 +0000] "POST / HTTP/1.1" 401 147 CUPS-Get-Devices successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:27:56 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:27:56 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - - [03/Nov/2023:00:34:00 +0000] "POST /printers/Phomemo-T02 HTTP/1.1" 200 415 Print-Job successful-ok
localhost - - [03/Nov/2023:00:35:48 +0000] "POST /admin/ HTTP/1.1" 200 66 - -
localhost - - [03/Nov/2023:00:35:48 +0000] "POST / HTTP/1.1" 401 75 CUPS-Get-Devices successful-ok
localhost - - [03/Nov/2023:00:35:48 +0000] "POST /admin/ HTTP/1.1" 200 1909 - -
localhost - - [03/Nov/2023:00:35:53 +0000] "POST /admin/ HTTP/1.1" 200 60 - -
localhost - - [03/Nov/2023:00:35:53 +0000] "POST / HTTP/1.1" 401 91 CUPS-Get-Devices successful-ok
localhost - - [03/Nov/2023:00:35:53 +0000] "POST /admin/ HTTP/1.1" 401 60 - -
localhost - - [03/Nov/2023:00:35:53 +0000] "POST /admin/ HTTP/1.1" 200 60 - -
localhost - stubkan [03/Nov/2023:00:35:58 +0000] "POST /admin/ HTTP/1.1" 200 60 - -
localhost - - [03/Nov/2023:00:35:58 +0000] "POST / HTTP/1.1" 401 91 CUPS-Get-Devices successful-ok
localhost - stubkan [03/Nov/2023:00:35:58 +0000] "POST / HTTP/1.1" 200 1493 CUPS-Get-Devices -
localhost - stubkan [03/Nov/2023:00:35:58 +0000] "POST /admin/ HTTP/1.1" 200 3360 - -
localhost - - [03/Nov/2023:00:36:41 +0000] "POST / HTTP/1.1" 401 147 CUPS-Get-Devices successful-ok
localhost - cups-pk-helper [03/Nov/2023:00:36:41 +0000] "POST / HTTP/1.1" 200 1549 CUPS-Get-Devices -
localhost - cups-pk-helper [03/Nov/2023:00:36:41 +0000] "POST / HTTP/1.1" 200 222 CUPS-Get-Devices -
localhost - - [03/Nov/2023:00:36:49 +0000] "POST / HTTP/1.1" 200 155 Cancel-Subscription successful-ok
localhost - - [03/Nov/2023:00:43:29 +0000] "POST / HTTP/1.1" 200 186 Renew-Subscription successful-ok

and the error log with debug turned on

E [03/Nov/2023:00:00:02 +0000] Unknown directive JobPrivateAccess on line 122 of /etc/cups/cupsd.conf.
E [03/Nov/2023:00:00:02 +0000] Unknown directive JobPrivateValues on line 123 of /etc/cups/cupsd.conf.
E [03/Nov/2023:00:00:02 +0000] Unknown directive SubscriptionPrivateAccess on line 124 of /etc/cups/cupsd.conf.
E [03/Nov/2023:00:00:02 +0000] Unknown directive SubscriptionPrivateValues on line 125 of /etc/cups/cupsd.conf.
E [03/Nov/2023:00:04:52 +0000] [cups-deviced] PID 49458 (phomemo) stopped with status 1!
E [03/Nov/2023:00:05:54 +0000] [cups-deviced] PID 49520 (phomemo) stopped with status 1!
E [03/Nov/2023:00:07:47 +0000] [cups-deviced] PID 49654 (phomemo) stopped with status 1!
E [03/Nov/2023:00:07:52 +0000] [cups-deviced] PID 49688 (phomemo) stopped with status 1!
E [03/Nov/2023:00:27:56 +0000] [cups-deviced] PID 53476 (phomemo) stopped with status 1!
E [03/Nov/2023:00:35:59 +0000] [cups-deviced] PID 54411 (phomemo) stopped with status 1!
E [03/Nov/2023:00:36:41 +0000] [cups-deviced] PID 54489 (phomemo) stopped with status 1!

@daig0rian @vivier @taylorjdlee

Sorry to ping, but is this repo going to be unsupported and new devices are not going to be added? T02 is supposedly compatible since it has the same protocols as M02 - but no matter what I try, it does not work.

Hi @stubkan
could you try to connect the printer using USB?

Hello @vivier, thanks for the reply. It turns up as "Jieli Technology device" when plugged in

lsusb
image

dmesg
image

tail of syslog
image

I do have the driver installed, and when I turn on my other older thermal printer (brother QL-700) it shows up in available printers to add immediately but the T02 doesnt show up, here a picture with both printers on ;

image

Some futher info, just in case.

CUPS driver is installed, I had difficulty getting pybluez due to distro issues but got it working in the end thanks to this guy https://stackoverflow.com/questions/75262991/i-found-the-way-to-install-pybluez-on-ubuntu-22-04

image

image

So, we spent a day to get the cups driver working with the T02 for bluetooth. The auto discovery with the cups ui did not work. We added it using the bdaddr with lpadmin.

Also the T02 did not show up as a printing device in dmesg, neither on a current ubuntu, nor arch, nor gentoo. We should document that the T02 apparently is not usable using usb. It only appears as a ttyACM0 device.

Also pybluez in current Ubuntu LTS is broken. And even with a patched version we only managed to get bad address exceptions.

The manual rfcomm cli way however worked well.

So we changed the M02 driver python script to not use pybluez but insteas use a native bluetooth socket. This works nicely.
We also needed to change the bottom line feed from 2 lines to 4 lines since it was too narrow.

We want to do a pull request. Not sure however how we should proceed.

I think in general since pybluez is deprecated and should be replaced.

Maybe the T02 should get its own backend?

@vivier any thoughts on the whole topic?

I have to correct my previous statement. The auto discovery works, now that I understood that cups reads some stdout print string from the bluetooth scan function to show the found printer. when we changed that to also take T02 as valid name into account, the auto discovery works as well.

@darkmattercoder

The installation method for pybluez had to be done differently for me, also on Ubuntu, however it SEEMS to be installed, although under a different name - are you saying this is broken and this is potentially a reason why I can't get the T02 to work on my end? I have installed python3-bluez instead of pybluez?

Hi, I've merged yesterday a pull request #20 from @klonfish that replace PyBluez by socket.
Does it fix your problem?
I don't have a lot of time to test and develop, but generally I try to merge the pull request I receive.

Yes, @klonfish and I did test that together, I will issue a follow up pull request which takes care of the name discovering during bt scanning in a couple of days.

Hi, I managed to get the T02 talking to Linux Mint by opening the .rpm and then just copying the filter and drv files into /usr/share/cups/..... and chowning them to root. I paired to the bluetooth printer and then added the printer as bluetooth://MACADDRESS (removing the colons in the address for some reason) ... That worked perfectly when added as a Phomemo M02.

I can print to the printer, BUT there's something odd about the way it scales images. If I make a label that's too large (e.g. A5). then although it's correctly scaled down and fits perfectly on the label, the printer spools a huuuuge long space before it prints. like, anywhere from 3 to 5 labels' worth of spooling, and then Zzzzt. a perfect print.

If I make a label that's too large, but it's a multiple of the dimensions that would fit, the driver scales it down so that it's smaller than the width. I tried making a label that's 50x150 - printed perfectly. I made a label that's 100x300, and it came out only 30mm wide on the 50mm paper. In the worst case, an image was square (about 400x400) and it just printed about 3 feet of blank and then stopped.

The obvious workaround is to scale everything to 50xheight at 203dpi and it seems to print perfectly. Would be good to find out why it does strange things if the source isn't exactly what the printer understands.

Did you notice the pr #21 ?
We improved the driver significantly in there. The only issue that I still cannot fix is that if you print large amounts of data, the printer suddenly stops printing and feeds before the print is completed.

However the overall detection over bluetooth, and using in cups has been improved in the pr.

Please check the latest version in git repo.

commented

I'm not a GitHub power user. I just converted to Linux as a desktop last year. I'm not up to compiling things from scratch, really, so if I need to clone the repo and build to get the update that may be beyond me. I'll check to see if the rpm linked from the main page (which doesn't mention the T02 yet) is updated and copy the files out again.

The driver works with some file wrangling, but would be great if there was an actual .deb release ready to be grabbed from GitHub and install, for noobs like me :)

I'm just happy it works! Awesome work reverse engineering the protocol!

2024-07-02-16-18-18-164

Hello,

OS: CachyOS Linux x86_64
Kernel: Linux 6.6.35-1-cachyos-lts
Using Plasma

Steps I've done:

  1. Pair the printer, just pair. (T02)
  2. Install phomemo-tools-git
  3. Restart cups (systemctl restart cups)
  4. Open printers ("Configuration de l'impression" or probably "Configure printers")
  5. Add
  6. It should be listed, just select, next, next, ...

I've also tested a simple icon to confirm it works.

Thanks so much.

Thank you @Buom01 for the information