Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print to a bluetooth device via rfcomm and printer.File() #643

Open
1 task done
dubaleeiro opened this issue May 13, 2024 · 3 comments
Open
1 task done

Print to a bluetooth device via rfcomm and printer.File() #643

dubaleeiro opened this issue May 13, 2024 · 3 comments

Comments

@dubaleeiro
Copy link

I have:

  • searched open and closed issues for duplicates

This is rather a question than a bug: I am trying to print to a cat thermal printer MX06 similar to this one via rfcomm and using printer.File('/dev/rfcomm0') without success. I would appreciate any help on that !

Steps to reproduce

  • connect Raspberry Pi to the printer via bluetoothctl
  • configure bluetooth device as serial port with sudo rfcomm bind /dev/rfcomm0 MAC-ADRESS
  • create printer with p = printer.File('/dev/rfcomm0')
  • command to send test line to printer with p.text("Hello World\n") not responding - no error message though

Device info

Printer: 'Cat' Thermal Printer Model MX06

python-escpos version: 3.1

python version: 3.12.2

operating system: Raspbian GNU/Linux (Raspberry Pi 4)

@belono
Copy link
Contributor

belono commented May 14, 2024

Hi @dubaleeiro .

I'm not an expert on this subjects, at all. But I will try to help you.

Have you managed to send some unfiltered text to the device from your terminal?.
Note that maybe you need to run it as sudo.

echo 'Hello World!\n' > /dev/rfcomm0

If the former worked, then you can send some escpos commands as raw bytes:

echo '\x1b\x45\x01' > /dev/rfcomm0
echo 'Hello World!\n' > /dev/rfcomm0

If your printer understands ESC/POS, then "Hello World!" should appear in bold.
Otherwise I would assume that your printer speaks a different dialect and therefore cannot use python-escpos to print to it.

@dubaleeiro
Copy link
Author

Hi @belono , thank you very much for your hints!

I am not not sure if the printer understands ESC/POS, I will check that. In addition, I think I have another problem: I cant setup the rfcomm on my pi. When I send the commands suggested by you, command line keeps 'thinking' withou any result. I will dig it further...

@belono
Copy link
Contributor

belono commented May 15, 2024

Hope you are success @dubaleeiro .

Let us know if you make any progress.
This could be interesting for the eventual incorporation of a Bluetooth printer connector in this library.

Cheers!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants