andrey-ushakov / esc_pos_bluetooth

ESC/POS (thermal, receipt) printing for Flutter & Dart (Android/iOS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Printing not smooth, it can't print with a large byte array

xfiremen opened this issue · comments

I have tested on iOS with this printer. All functions worked well.
https://www.craftdata.co.uk/thermal-printers/fk-pc301-d-3-mobile-thermal-printer-with-autocutter
But it has some problems need to be improved.
1/ writeData method with big data, this device auto disconnect.
2/ Printing not smooth. Maybe you should support split byte data to more packets.

Hi @xfiremen ,
Thank you for your feedback! What the size of your bytecode? Does it include any images?
Could you provide your code, please?

Hi @andrey-ushakov,
I am tried on your demo. I removed all images. I try to multiple x10 times your receipt. ~ 14540 bytes.

New result: I have tried it with more printers. Some big printer work well. You should buy some CHINA printer and test on it. I thought it belong to printer. Some device has small memory, that can not handle big message.

Solution: I splitted my ticket message into more parts. With max-size 100 bytes/ packet. Can you support it on your method WriteBytes.

On react-native I am using under library. (https://github.com/innoveit/react-native-ble-manager)

Actually I've tested on 3 cheap small Chinese Bluetooth printers and it looks like it works.
I'm going to test bigger bytecode then.

Yes, you are absolutely right about splitting the data. Normally we should use 20 bytes chunks (it's also the default value in the package you mentioned).

In the latest version, I'm splitting the data and using the sleep function before calling the platform-specific method.

This probably could be improved by splitting and waiting for the device response on the lower level (for Android and iOS) instead of using sleep.

PRs are welcomed!

I update my project to using new version 0.25. When scan device, it fail. Error starting scan.
Error: Unhandled Exception: MissingPluginException(No implementation found for method startScan on channel flutter_bluetooth_basic/methods) @andrey-ushakov

@andrey-ushakov . I created pull request for you. Let check it!
andrey-ushakov/flutter_bluetooth_basic#6

Error: Unhandled Exception: MissingPluginException(No implementation found for method startScan on channel flutter_bluetooth_basic/methods)
Thank you! That's a bit strange why it's still working on iOS in my case (without changing pubspec .yaml).

Did you get a chance to check the printing issue btw? I've tested it on my cheap small Bluetooth printers and it works. However, the sleeping time (in ms) could be different for different printers. That's a "quick and dirty" solution and it must be improved in future releases.

@andrey-ushakov .
-queueSleepTimeMs must default 10ms & chunkSizeBytes 50. It worked well on most printers. I have tested on 7 models.
Some issues when you rescan before connect. Some printers need more than 3-5 seconds to find. In writeData you rescan with 1 second timeout. One more thing. I think you don't need to disconnect after print.

@andrey-ushakov .
-queueSleepTimeMs must default 10ms & chunkSizeBytes 50. It worked well on most printers. I have tested on 7 models.
Some issues when you rescan before connect. Some printers need more than 3-5 seconds to find. In writeData you rescan with 1 second timeout. One more thing. I think you don't need to disconnect after print.

I have made all adjustment in queueSleepTimeMs & chunkSizeBytes for printing jpg, but still I getting the image as breaking parts in printout. Printer model: Model MHT-P5801 How I can resolve this issue?, Please help.

@hamzamon try increasing the chunkSizeBytes if its too slow, I had to set chunkSizeBytes to 200 and queueSleepTimeMs to 10 for smoother printing of images.

I try with Niimbot B3S doesn't work anymore

facing version mismatching when I use esc_pos_printer&esc_pos_bluetooth at the same time..
any solution for it?

Performance while printing text, QRcode, and others were good but the image was poor. Have you any solutions?

How can we print pdf files without conversion to images?

Actually I've tested on 3 cheap small Chinese Bluetooth printers and it looks like it works. I'm going to test bigger bytecode then.

Hi, Can your share the link of printers? Thanks!
I tried it on Xprinter XP-T202UA via bluetooth. It actually works well on connecting the machine but not work for printing.