Print text as a raster bit image from a Phomemo printer.
Project description
Phomemo printer - python utilities to allow printing text from the Phomemo printer
I have not been able to print text to the Phomemo printer using standard ESC/POS print commands (if your printer does work with these commands, you should use the library here). To work around this, this library allows printing of text as a raster bit image.
Various methods to connect to the Phomemo printer and print images are excellently described here. This package currently only allows connection to the printer via bluetooth.
Tools were tested on a Phomemo M02 Pro printer.
Requirements
- python3
- bluetooth interrogation tools (e.g. via the
bluez
package)
Installation
sudo python3 setup.py install
This will create a CLI called phomemo_printer
on your PATH.
Alternatively, install via pip:
python3 -m pip install phomemo_printer
Usage
The printer is connected to over bluetooth. To connect, the bluetooth address and channel must be determined.
Finding the printer's bluetooth address and channel
The Debian package bluez
provides the utilities needed to scan for and connect to the printer via bluetooth.
- Find the printer's bluetooth address
The printer should be powered on and not connected to any computer or app.
$ hcitool scan
Scanning ...
00:AA:13:41:11:A5 M02 Pro
The bluetooth address should be in the format xx:xx:xx:xx:xx:xx. If more than one bluetooth device is discovered, look for one with the name of your printer.
- Determine which channel to connect to the device on
Format: sdptool browse bluetooth_address
$ sdptool browse 00:AA:13:41:11:A5
Browsing ...
Service Name: SerialPort
Service RecHandle: 0x1000f
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 6
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0102
Sending text to the printer
Via CLI
Format: phomemo_printer -a bluetooth_address -c bluetooth_channel -t "text to print"
phomemo_printer -a 00:AA:13:41:11:A5 -c 6 -t "Hello world"
Via module import
from phomemo_printer.ESCPOS_printer import Printer
printer = Printer(bluetooth_address="00:AA:13:41:11:A5", channel=6)
printer.print_text("Hello world")
printer.close()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file phomemo_printer-1.0.4.tar.gz
.
File metadata
- Download URL: phomemo_printer-1.0.4.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 128777bcb905d0a3575995a82b4a35250b3f891f88e2e9ad33ad4d7c4e9e1e0c |
|
MD5 | 23f1481bfdb03d67a86b065ab64d98b2 |
|
BLAKE2b-256 | 74a0318305963fcaf458572dfc52de321cda2466511c9e99cda02278afe3230f |
File details
Details for the file phomemo_printer-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: phomemo_printer-1.0.4-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f3385156d4e2df93e5fee5da0e79173400e4caf2cfb44ccb203f1026a9ecc0e |
|
MD5 | b0e49f91c41a75a63daecfe76971fc44 |
|
BLAKE2b-256 | d767aa8c1d755ecbeb43bfffcddfcd0d5d87783d0baffcdcf56e104d47d41c94 |