GithubHelp home page GithubHelp logo

vivier / phomemo-tools Goto Github PK

View Code? Open in Web Editor NEW
149.0 6.0 24.0 538 KB

CUPS driver for Phomemo M02 Label Printer

License: GNU General Public License v3.0

Python 89.29% Makefile 9.46% Shell 1.24%
bluetooth-printer

phomemo-tools's Introduction

Phomemo-tools

This package is trying to provide tools to print pictures using the Phomemo M02, M110, M120 and M220 thermal printers from Linux.

All the information here has been reverse-engineered sniffing the bluetooth packets emitted by the Android application.

python3-pybluez and phomemo-tools CUPS driver can be found at phomemo-tools RPM

1. Usage

1.1. Bluetooth

  • connection
$ bluetoothctl devices
Device DC:0D:30:90:23:C7 Mr.in_M02
$ bluetoothctl pair DC:0D:30:90:23:C7
Attempting to pair with DC:0D:30:90:23:C7
[CHG] Device DC:0D:30:90:23:C7 Connected: yes
[CHG] Device DC:0D:30:90:23:C7 Bonded: yes
[CHG] Device DC:0D:30:90:23:C7 ServicesResolved: yes
[CHG] Device DC:0D:30:90:23:C7 Paired: yes
Pairing successful
$ sudo rfcomm connect 0 DC:0D:30:90:23:C7
  Connected /dev/rfcomm0 to DC:0D:30:90:23:C7 on channel 1
  Press CTRL-C for hangup
  • Send the picture to the printer (the python script currently only works with M02 printers):
  tools/phomemo-filter.py my_picture.png > /dev/rfcomm0

1.2. USB

  • Plug the USB printer cable

  • Check the printer is present:

  $ lsusb
  ...
  Bus 003 Device 013: ID 0493:b002 MAG Technology Co., Ltd 
  ...

You can see the serial port in the dmesg and in /dev:

  $ dmesg
  ...
  usb 3-3.7.2: new full-speed USB device number 13 using xhci_hcd
  usb 3-3.7.2: New USB device found, idVendor=0493, idProduct=b002, bcdDevice= 3.00
  usb 3-3.7.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  usb 3-3.7.2: Product: USB Virtual COM
  usb 3-3.7.2: Manufacturer: Nuvoton
  usb 3-3.7.2: SerialNumber: A02014090305
  cdc_acm 3-3.7.2:1.0: ttyACM0: USB ACM device
  usblp 3-3.7.2:1.2: usblp0: USB Bidirectional printer dev 13 if 2 alt 0 proto 2 vid 0x0493 pid 0xB002
  $ ls -lrt /dev
  ...
  drwxr-xr-x.  2 root    root         100 Dec  5 17:44 usb
  crw-rw----.  1 root    dialout 166,   0 Dec  5 17:44 ttyACM0
  ...
  $ ls -lrt /dev/usb
  total 0
  crw-------. 1 root root 180, 96 Dec  5 16:46 hiddev0
  crw-------. 1 root root 180, 97 Dec  5 16:46 hiddev1
  crw-rw----. 1 root lp   180,  0 Dec  5 17:44 lp0
  • Send the picture to the printer (the python script currently only works with M02 printers):

You need to be root or in the lp group

  # tools/phomemo-filter.py my_picture.png > /dev/usb/lp0

2. CUPS

2.1. Installation

On Debian you can have to install cups:

  $ sudo apt-get update
  $ sudo apt-get -y install cups

Then you can build and install phomemo-tools files:

  $ cd cups
  $ make
  $ sudo make install

2.2. Configuration

2.2.1. GUI

2.2.2.1.1. Pre-requisite

To connect using USB, you need python3-pyusb. For instance, on Fedora:

   $ sudo dnf install python3-pyusb

On Fedora, SELinux seems to prevent the backend to create a bluetooth socket. If you have such error message in your syslog:

localhost.localdomain cupsd[2659]: Can\'t open Bluetooth connection: [Errno 13] Permission denied

You might need to disable SELinux enforcement to allow the backend to run correctly:

  $ sudo semanage permissive -a cupsd_t

I didn't find a way to define correctly the SELinux rules to allow the backend to use bluetooth socket without to change the enforcement mode (the couple ausearch/audit2allow doesn't fix the problem).

2.2.2.1.1. Pair the printer
  1. Switch on the printer
  2. Open the "Settings" window:

Settings Menu

  1. Select the "Bluetooth" Panel:

Bluetooth Panel

  1. Select your bluetooth printer (here "Mr.in_M02"):

Bluetooth Printer

  1. Your printer must be paired but not connected ("Disconnected"):

Bluetooth Printer

  1. Select the "Printers" Panel:

Printers Panel

You'll probably need to unlock it to be able to add a new printer.

Click on "Add a Printer...".

  1. Select your printer and click on "Add":

Printers Panel

  1. Your printer will appear in the printers list:

Printers Panel

  1. Click on the settings menu of the printer and select "Printing Options":

Printers Panel

  1. Select "Media Size Label 50mmx70mm" and click on "Test Page":

Printers Panel

  1. Check the result:

Printers Panel

2.2.2. CLI

2.2.2.1. Bluetooth

This definition will use the "phomemo" backend to connect to the printer:

2.2.2.1.1 M02
  $ sudo lpadmin -p M02 -E -v phomemo://DC0D309023C7 \
                           -P /usr/share/cups/model/Phomemo/Phomemo-M02.ppd.gz
2.2.2.1.2 M110, M120, M220

Use ”Phomemo-M110.ppd.gz”. This driver is compatible with M110, M120, and M220. The -p option defines the printer name. It should be changed according to the printer used.

  $ sudo lpadmin -p M110 -E -v phomemo://DC0D309023C7 \
                           -P /usr/share/cups/model/Phomemo/Phomemo-M110.ppd.gz
2.2.2.2. USB

This definition will use the /dev/usb/lp0 device to connect to the printer:

2.2.2.2.1 M02
  $ sudo lpadmin -p M02 -E -v serial:/dev/usb/lp0 \
                           -P /usr/share/cups/model/Phomemo/Phomemo-M02.ppd.gz
2.2.2.1.2 M110, M120, M220

Use ”Phomemo-M110.ppd.gz”. This driver is compatible with M110, M120, and M220. The -p option defines the printer name. It should be changed according to the printer used.

  $ sudo lpadmin -p M110 -E -v serial:/dev/usb/lp0 \
                           -P /usr/share/cups/model/Phomemo/Phomemo-M110.ppd.gz
2.2.2.3. Check printer options

You can use the following command to check the options for your printer which will list the printer defaults with a "*":

  $ lpoptions -d M02 -l
2.2.2.4. Printing

You can use the following command to print text using CUPS:

  $ echo "This is test"  | lp -d M02 -o media=w50h60 -

You can use the following command to print an image using CUPS:

  $ lp -d M02 -o media=w50h60 my_picture.png

The M110, M120 & M220 printers have support for LabelWithGaps, Continuous and LabelWithMarks media types which can be specified as follows:

  $ echo "This is test"  | lp -d M110 -o media=w30h20 -o MediaType=Continuous

3. Protocol for M02

After dumpping bluetooth packets, it appears to be EPSON ESC/POS Commands.

3.1. HEADER

  0x1b 0x40      -> command ESC @: initialize printer
  0x1b 0x61      -> command ESC a: select justification
  0x01           range: 0 (left-justification), 1 centered,
                        2 (right justification)
  0x1f 0x11 0x02 0x04           

3.2. BLOCK MARKER

  0x1d 0x76 0x30 -> command GS v 0 : print raster bit image
  0x00              mode: 0 (normal), 1 (double width),
                          2 (double-height), 3 (quadruple)
  0x30 0x00         16bit, little-endian: number of bytes / line (48)
  0xff 0x00         16bit, little-endian: number of lines in the image (255)

Values seem to be 16bit little-endian

If the picture is not finished, a new block marker must be sent with the remaining number of line (max is 255).

3.3. FOOTER

  0x1b 0x64      -> command ESC d : print and feed n lines
  0x02           number of line to feed
  0x1b 0x64      -> command ESC d : print and feed n lines
  0x02           number of line to feed
  0x1f 0x11 0x08
  0x1f 0x11 0x0e
  0x1f 0x11 0x07
  0x1f 0x11 0x09

3.4. IMAGE

Each line is 48 bytes long, each bit is a point (384 pt/line). size of a line is 48 mm (80 pt/cm or 203,2 dpi, as announced by Phomemo). ratio between height and width is 1.

3.5. Printer message

1a 04 5a
1a 09 0c
1a 07 01 00 00
1a 08 
51 30 30 31 45 30 XX XX XX XX XX XX XX XX XX -> Serial Numer: E05C0XXXXXX

4. Protocol for M110/M120/M220

Dumpping USB packets.

4.1. HEADER

  0x1b 0x4e 0x0d  -> Print Speed
  0x05            range: 0x01 (Slow) -  0x05 (Fast)
  0x1b 0x4e 0x04  -> Print Density 
  0x0f            range: 01 - 0f
  0x1f  0x11      -> Media Type
  0x0a            Mode: 0a="Label With Gaps" 0b="Continuas" 26="Label With Marks"

4.2. BLOCK MARKER

  0x1d 0x76 0x30 -> command GS v 0 : print raster bit image
  0x00              mode: 0 (normal), 1 (double width),
                          2 (double-height), 3 (quadruple)
  0x2b 0x00         16bit, little-endian: number of bytes / line (43)
  0xf0 0x00         16bit, little-endian: number of lines in the image (240)

4.3. FOOTER

  0x1f 0xf0 0x05 0x00 
  0x1f 0xf0 0x03 0x00

phomemo-tools's People

Contributors

daig0rian avatar darkmattercoder avatar klonfish avatar taylorjdlee avatar vivier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

phomemo-tools's Issues

M110/M120 Bluetooth using CUPS

Hey I'm trying to connect the M120 printer via bluetooth but I'm having a hard time. I've tried to follow the guide and yes I can connect to the printer using the rfcomm connect command but I can't use the backend to connect to the printer via CUPS.

I've been trying to using this command sudo lpadmin -p M120 -E -v phomemo://047F0E775A68 -P /usr/share/cups/model/Phomemo/Phomemo-M110.ppd.gz followed by echo "This is test" | lp -d M02 -o media=w50h60 - to no avail

@daig0rian Any idea how to connect to bluetooth using the command line? As I know you have a M110, thanks!

Question: other printers

Forgive my ignorance (I know nothing about CUPS other than seeing it in /bar/spool/cups), but could these tools be used to automate the formatting and printing of QR codes with a D30? I noticed you only had case clauses for M02 and M110 and otherwise reject. The QR code generation is straightforward, but I don't know what serialization format printers need.

Thanks for the repo! Cool that you put this up.

Question: Compatibility with M220

I recently got an M220 and tried it with the M110 driver.
I found out that the M220 treats every GS v 0 as a separate print job introducing line feed and back feed resulting in a gap of approx. 6 mm.
I discovered that the M220 supports at most 1200 lines per GS v 0 command. Limiting the maximum printable size to 72 mm x 150 mm
Gaps_after_each_GS_v_0

Changing licensing to MIT

@vivier So I noticed we're currently using a GPL3 license? Maybe if switch to MIT will hopefully get more contributors for other printers

T02 Phomemo seems incompatible - printing does not occur

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!

Phomemo Wireless Label Printer Model P12 info

I couldn't find any information about the Phomemo P12 so here are my notes from testing it. The Phomemo P12 USB protocol seems to be the same as the M110/M120/M220 so it was surprisingly easy to get it working.
The width is 12 bytes (96 pixels). I only have tape media so I'm using media 0b (Continuous).
The P12 must be powered on after connecting it to USB power by pressing the button. It will work if the button is held down continuously so the button can be clamped or glued to keep it on permanently (so it turns back on automatically after power is interrupted).

FCC ID: 2ASRB-P12

USB info:
idVendor: 0x4C4A = Vendor ID not listed with USB.org
idProduct: 0x4155
bcdDevice: 0x0100
iManufacturer: 0x01
English (United States) "Jieli Technology"
iProduct: 0x02
English (United States) "USB Composite Device"
iSerialNumber: 0x03
English (United States) "1234567890ABCDEF"
bNumConfigurations: 0x01

Bluetooth communication is too fast.

Hello. Thank you for your great work at first. Recently I've got a Phomemo M120 printer and tried your CUPS driver.
However, it only prints about 1/3 of a 30 mm long page. It seems that (at least) M120 requires slower data transfer. I tried a slow-transferring code (rastertoppm02.py) like this:

<     bytes = block.tobytes()
<     for i in range(lines):
<         stdout.write(bytes[image.width * i:image.width * (i + 1)])
<         stdout.flush()
<         time.sleep(0.05)
---
>     stdout.write(block.tobytes())

It works fine with my M120.

In addition, I'm using "gap paper", with which your original driver feeds an extra page after printing. So I also modified rastertopm02.py like this:

<         print_and_feed(stdout, 0)
---
>         print_and_feed(stdout, 2)

I hope this information helps you or others who use Phomemo printers.

Thank you.

Question: M02 PRO

Hello! Thank you so much for this repo. I'm trying to use it with my M02 pro.
The test page sort of prints, but only 1.5cm and then it stops. Any tips on how to add this version? If you point me in the right direction I can maybe try to contribute. <3

Adding support for P3200

I got a new P3200 printer (similar to a p-touch) and I'd like to use it on Linux, I wanted to try modifying the M110 driver to start with, but my printer is an ACM device and not a usblp device, any ideas how I go around to try to get it working?
I'm a developer, but inexperienced with printer drivers.
Thanks

Question: Image printing size

Hello sir,
I currently own the Phomemo M110 and my objective is to print a QR Code on a page (30*20mm).
Is it possible to print an image with specific settings or do I need to use another method (working on python)?
Many thanks

Other Phomemo printer repos

It seems there's a few other repos that worked on different Phomemo printers we should be able to add more driver support by taking a look into these repos:

Phomemo D30 (should be able to derive headers footers from here): https://github.com/polskafan/phomemo_d30/blob/master/print_text.py

M02s (already made a PR for this): https://github.com/privatwolke/phomemo-tools

M02 Pro (seems to similar to the M02s both are 300 dpi): https://github.com/noullove/phomemo-tools

T02 (was reversed with help from this project): https://github.com/iamjackg/esp32-phomemo-gameboy-printer

P12Pro, D35, D30 and M220 (Not too sure how much we can derive from here): https://github.com/Knightro63/phomemo

M03 (should be able to derive headers/footers from here): https://github.com/whitechip4/Phomemo-M03-Mod/blob/master/phomemo_m03.py

P12 (should be able to derive headers/footers from here): https://github.com/S1artie/InternetOfTrash/blob/master/labelprinter/labelprinter.py

But yeah it's a good start and it'll be nice to get this repo supporting as many Phomemo printers as possible!

Info about M02S

Thank you a lot for your work, which I'm going to use as a base for what I'm trying to do (I don't really want a CUPS driver, but I'm trying to make a command line program so I can run label "Some String" and get exactly that printed on one of the 1/3 or 1/2 width sticky labels.

Anyway, I just bought a Phonemo M02S, and it seemed that I just wasn't able to print anything - until I realized the M02S has 512 pixels full width, instead of the 384 that the M02 seems to have.

When I changed the 0300 in the initialization code to 0400, and the 384 from the width adjuster to 512, printing on the 1/3 width label worked great.

Unfortunately, there doesn't seem to be an easy way to autodetect if you have a M02 or a M02s - the lsusb has exactly the same device identifier:

Bus 001 Device 099: ID 0493:b002 MAG Technology Co., Ltd

and it doesn't look like the log from plugging the printer in has any useful distinction either:

Aug 27 15:35:11 natascha kernel: [862343.900189] usb 1-1.4.4: new full-speed USB device number 99 using xhci_hcd
Aug 27 15:35:12 natascha kernel: [862344.275498] usb 1-1.4.4: New USB device found, idVendor=0493, idProduct=b002, bcdDevice= 3.00
Aug 27 15:35:12 natascha kernel: [862344.275505] usb 1-1.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 27 15:35:12 natascha kernel: [862344.275508] usb 1-1.4.4: Product: USB Virtual COM
Aug 27 15:35:12 natascha kernel: [862344.275510] usb 1-1.4.4: Manufacturer: Nuvoton
Aug 27 15:35:12 natascha kernel: [862344.275512] usb 1-1.4.4: SerialNumber: A02014090305
Aug 27 15:35:12 natascha kernel: [862344.334555] cdc_acm 1-1.4.4:1.0: ttyACM0: USB ACM device
Aug 27 15:35:12 natascha kernel: [862344.338797] usblp 1-1.4.4:1.2: usblp1: USB Bidirectional printer dev 99 if 2 alt 0 proto 2 vid 0x0493 pid 0xB002

The MAC address for the BT interface is from a different range however, and the device name does include the S:

gbl@natascha$ hcitool scan
Scanning ...
	04:7F:0E:56:12:17	M02S

If you're interested in supporting that printer, and want any more information, feel free to contact me. Else, feel just as free to just close and ignore this issue.

Thanks again for your work, it's going to help me a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.