phomemo-tools icon indicating copy to clipboard operation
phomemo-tools copied to clipboard

Question: other printers

Open dougpagani opened this issue 2 years ago • 16 comments

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.

dougpagani avatar Mar 19 '22 10:03 dougpagani

QR codes are generated by the appropriate software (like gLabels) and sent as a bitmap to the cups driver that translates it to the printer language. So as long you have a software that can use the CUPS framework you can automate what you want.

Unfortunately I have only the M02 printer so the CUPS driver only supports M02 printer (M110 is not tested, but I guessed it's like a M02 with 300 dpi rather than 203 dpi).

vivier avatar Mar 21 '22 18:03 vivier

I got an M110 today so I'll test it out with your package & report back once I figure out how to bridge host connection with a Linux VM (I'm on macos so I can't use it natively).

dougpagani avatar May 05 '22 16:05 dougpagani

I tried to use this library with a M110 and it doesn't seem to work. I will try to document everything to see if someone smarter than me can make it work. The FCC id is 2ASRB-M110 and resolution is 203 dpi instead of 300 dpi. Printer firmware 1.0.8 Labels: 50x80mm

Bluetooth I can pair the printer to Ubuntu and by commenting two lines in phomemo.py I was able to find the printer and add it. Using the M02 driver the test print just made the printer beep twice and nothing else.

USB This is very close, with the M02 drive the test print starts and prints about a third of the page, then continues in the second label printing only about a third, third label has the bottom of the test page and a fourth label is blank.

lsusb: Bus 004 Device 002: ID 0483:5740 STMicroelectronics Virtual COM Port

usb-devices

T:  Bus=04 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0483 ProdID=5740 Rev=02.00
S:  Manufacturer=QUIN
S:  Product=QUIN Printer
S:  SerialNumber=P0V00000011N
C:  #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=400mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=usblp
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:  If#= 1 Alt= 0 #EPs= 0 Cls=02(commc) Sub=02 Prot=01 Driver=(none)
I:  If#= 2 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms

hci-tools 04:7F:0E:77:3D:70 Q119E22H0010058

from python

{
  "Address": "04:7F:0E:77:3D:70",
  "AddressType": "public",
  "Name": "Q119E22H0010058",
  "Alias": "Q119E22H0010058",
  "Class": 1050240,
  "Icon": "printer",
  "Paired": 1,
  "Trusted": 1,
  "Blocked": 0,
  "LegacyPairing": 0,
  "RSSI": -39,
  "Connected": 0,
  "UUIDs": [
    "00001101-0000-1000-8000-00805f9b34fb",
    "e5b152ed-6b46-09e9-4678-665e9a972cbc"
  ],
  "Adapter": "/org/bluez/hci0",
  "ManufacturerData": {
    "0": [
      4,
      127,
      14,
      119,
      61,
      112
    ]
  },
  "ServicesResolved": 0
}

csaleman avatar Jun 24 '22 05:06 csaleman

if you comment out lines 88,89 and 96 the M110 works for me

...
while remaining > 0:
    lines = remaining
#    if lines > 256:
#        lines = 256
    print_marker(lines)
    remaining -= lines
    while lines > 0:
        print_line(image, line)
        lines -= 1
        line += 1
# print_footer()

glsys avatar Dec 02 '22 13:12 glsys

Nice, I will try it again, thank you @glsys !

dougpagani avatar Jan 27 '23 02:01 dougpagani

Hi guys any idea if something similar can be done with the M120, M200, M220 and M221? I assume it should be the case, it'll be good to support as many phomemo printers as possible

taylorjdlee avatar May 31 '23 15:05 taylorjdlee

I have added a modification for the M110 to the source in Pull Request #5 #6. In the process I captured the communication between the M110 and the M110 Windows driver and compared it to the communication for the M02 that vivier analyzed, but the headers and footers for the M110 and M02 were completely different. Therefore I had to separate and customize the filter for the M110 from the filter for the M02. Perhaps the same process will be needed for other models.

Get and share a dump of USB communications for these models in Wireshark would be helpful for development.

daig0rian avatar Jun 01 '23 00:06 daig0rian

@daig0rian Seems I got the M120 working with the M110 drivers you made. Seems under the hood the M120 and M110 are pretty much the same (in the Phomemo app they are even in the same section). Though I'm having an issue using the code present on the master branch in prints out the following 20230605_165221 when using this image Logo-Test

I guess it maybe something to do with the image size? I'm using the following command to print python3 tools/phomemo-filter.py Logo-Test.png > /dev/usb/lp0

I'm also using the test 40mm x 30mm labels by the way

I assume it's because I'm not using a resolution of 203 dpi but I'll update this later on if it works

taylorjdlee avatar Jun 05 '23 21:06 taylorjdlee

The output of the commands even line up to what @csaleman was experiencing leading me to believe the M110 & M120 are one in the same lsusb: Bus 001 Device 007: ID 0483:5740 STMicroelectronics Virtual COM Port usb-devices:

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  7 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0483 ProdID=5740 Rev=02.00
S:  Manufacturer=QUIN
S:  Product=QUIN Printer
S:  SerialNumber=P0V00000011N
C:  #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=400mA
I:  If#=0x0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=usblp
I:  If#=0x1 Alt= 0 #EPs= 0 Cls=02(commc) Sub=02 Prot=01 Driver=(none)
I:  If#=0x2 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)

taylorjdlee avatar Jun 05 '23 21:06 taylorjdlee

So awesome got it to work with the M120 the drivers seem to be the exact same. I ended up getting this printed (seems it went across two labels so guess I need some minor adjustments to the image size for 40mmx30mm) but overall @daig0rian if anyone is using an M120 they should be able to use your M110 drivers without issue!

test

20230605_172636

taylorjdlee avatar Jun 05 '23 21:06 taylorjdlee

Thank you @taylorjdlee,

You can test by text with the following commands. $ echo "This is test" | lp -d M110 -o media=w30h20 -

You can test by image with the following commands. $ lp -d M110 -o media=w30h20 phomemo_log_150x150px.png

and this is how it prints on my M110.

This 150x150px image can be download in here.

You can get a list of label sizes that can be specified with the following command. Default paper size is marked with an asterisk.

$ lpoptions -d M110 -l
PageSize/Media Size: w20h100 w20h10 w20h20 w25h10 w25h30 w25h38 w30h20 w30h25 w30h30 w35h15 w40h20 *w40h30 w40h40 w40h60 w40h80 w45h60 w50h20 w50h30 w50h50 w50h70 w50h80 Custom.WIDTHxHEIGHT
Resolution/Resolution: *203dpi
ColorModel/Color Mode: *Gray

Label sizes not listed can be specified in this way lp -d M110 -o media=Custom.40x30mm

daig0rian avatar Jun 05 '23 22:06 daig0rian

If M120 supports a paper type other than "Label With Gaps", ~~it can be specified in the daig0rian:master version that waiting for merge.~~ ~~Version vivier:master has a fixed EPSON ESC/POS header with "Label With Gaps".~~ clone vivier:master again.

daig0rian avatar Jun 05 '23 23:06 daig0rian

@daig0rian I can confirm this worked successfully and I was able to print .pngs on a single label! So if anyone has an M120 the M110 drivers work the exact same. Due to this I assume the M120 also supports the same paper types as the M110.

I saw your branch has been merged into master, for future reference how do you select the paper type? I guess in a similar way to how we select the media size?

Would probably be a good idea to add the steps we talked about here to the readme for any future user that is using an M110 or M120

taylorjdlee avatar Jun 07 '23 05:06 taylorjdlee

The current vivier:master supports the M110 MediaType selection. You can display the MediaType options in lpoptions in the CUI.

$ lpoptions -d M110 -l
PageSize/Media Size: w20h100 w20h10 w20h20 w25h10 w25h30 w25h38 w30h20 w30h25 w30h30 w35h15 w40h20 *w40h30 w40h40 w40h60 w40h80 w45h60 w50h20 w50h30 w50h50 w50h70 w50h80 Custom.WIDTHxHEIGHT
Resolution/Resolution: *203dpi
ColorModel/Color Mode: *Gray
MediaType/Media Type: *LabelWithGaps Continuas LabelWithMarks

You can test following commands. echo "This is test" | lp -d M110 -o media=w30h20 -o MediaType=Continuas -

You can also display and select MediaType options in the GUI. Screenshot from 2023-06-08 12-36-22 (In this screenshot, the OS locale is set to Japanese. Maybe it's so hard to read,sorry.)

daig0rian avatar Jun 08 '23 03:06 daig0rian

Would probably be a good idea to add the steps we talked about here to the readme for any future user that is using an M110 or M120

I think it is a very good idea. I look forward to your contribution.

daig0rian avatar Jun 08 '23 04:06 daig0rian

Awesome just added a quick PR with updates to the README #7

taylorjdlee avatar Jun 08 '23 05:06 taylorjdlee