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

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

Open
xfiremen opened this issue Mar 19, 2020 · 15 comments
Open

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

xfiremen opened this issue Mar 19, 2020 · 15 comments

Comments

@xfiremen
Copy link

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.

@andrey-ushakov
Copy link
Owner

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

@xfiremen
Copy link
Author

xfiremen commented Mar 19, 2020

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)

@andrey-ushakov
Copy link
Owner

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.

@andrey-ushakov
Copy link
Owner

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!

@xfiremen
Copy link
Author

xfiremen commented Mar 21, 2020

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

@xfiremen
Copy link
Author

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

@andrey-ushakov
Copy link
Owner

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.

@xfiremen
Copy link
Author

@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.

@hamzamon
Copy link

@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.

@aakashbapna
Copy link

@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.

@Unlaytsabxwb
Copy link

I try with Niimbot B3S doesn't work anymore

@Rabeeh96
Copy link

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

@Pun-Mengly
Copy link

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

@Pun-Mengly
Copy link

How can we print pdf files without conversion to images?

@cmh81325
Copy link

cmh81325 commented Mar 20, 2022

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.

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

No branches or pull requests

8 participants