Android Question EscPosPrinter and Android 11

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello All,
My App prints (EscPOS Bluetooth printer) without errors or issues in Android 8 thru 10, but in Android 11 (Samsung Tab Active3) it can't print the whole ticket
It always stop half way, even with resets between the prints, and after it misprints, I cannot print anything else.
I have to disconnect, reconnect and then printer to be able to print another ticket.

Any ideas ?

Thanks
 

jahswant

Well-Known Member
Licensed User
Longtime User
Hello All,
My App prints (EscPOS Bluetooth printer) without errors or issues in Android 8 thru 10, but in Android 11 (Samsung Tab Active3) it can't print the whole ticket
It always stop half way, even with resets between the prints, and after it misprints, I cannot print anything else.
I have to disconnect, reconnect and then printer to be able to print another ticket.

Any ideas ?

Thanks
Do a complete buffer of your text before printing. Don't a line at a time. Print everthing once.
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
To have a printer shared between activity what would be the best practice ?
Declare Public BTPrinter as EscPosPrinter in the Starter service, declare it in main ? Declare Private BTPrinter as EscPosPrinter in every activity_create ?
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
I have solved it, by not complicating it.
I have several activies that can print, so I initialized and connected the EscPosPrinter object in the start of each, do all the printing required and disconnect the printer on exit (Activity.close)
That done it for me.
 
Upvote 0

dws

Member
Licensed User
Longtime User
I have solved it, by not complicating it.
I have several activies that can print, so I initialized and connected the EscPosPrinter object in the start of each, do all the printing required and disconnect the printer on exit (Activity.close)
That done it for me.
Thanks For Replay ... my problem is on printer. (Different model)
 
Upvote 0
in attach code of bluetooth and print activity what's the matter??? in android 11 print half of receipt
Care to elaborate ? Need help in exactly what ?
in attach code of bluetooth and print activity what's the matter??? in android 11 print half of receipt
 

Attachments

  • code of blutooth.txt
    17.7 KB · Views: 241
  • code of print activity.txt
    30.3 KB · Views: 208
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
until I did the following
Have you tried to do all the Printer-Communication from the Starterservice (or any other Service) and call the print-methods (in the service) from all activities then?
 
Upvote 0
For me nothing worked until I did the following
Initialize the printer on each activity
Connect before every print job
disconnect after printing was complete

but I had to print from a multi activity App
the error apppear this message
2022-04-13 11:33:10.692 4721-4825/? E/bt_btif_sock_rfcomm: send data to app error writing RFCOMM data back to app: Broken pipe
in attach put bluetooth operation
 

Attachments

  • bluettoth.txt
    12.1 KB · Views: 151
Upvote 0

MicroDrie

Well-Known Member
Licensed User
You see an abruptly disconnection in Android with the error message "E/bt_btif_sock_rfcomm" and a half printed receipt. The printer has a limited internal memory buffer in which the printer data is temporarily stored. In this case, full = full. If the buffer is about to become full, the printer will send an XOFF command with the intention to directly stop receiving more incommoding data. If an OS is more efficient at processing the printer data, sending it faster, or Bluetooth than the printer can print, the printer's internal buffer becomes full.

When the buffer can receive data again, it sends an XON character. If your program does not stop sending printer data after an XOFF message, the printer will hang. Only what is in the buffer is still printed and the printer stops immediately (thats why you see a half receipt). If that is in the middle of a printer control command, my experience is that almost no printer survives this without a power off/on action (thats why you must hard reset the printer).

What I am missing in the program is checking whether the printer has an XOFF status message with the character Pause transmission code XOFF, ASCII codec DC3, 19 decimal or 13 Hexadecimal. The XON Resume transmission ASCII code is DC1, ASCII code 17 or 11 Hexadecimal. All this is missing from the program.

This so-called XON/XOFF printer handshake could of course be hidden in either the OS or the printer driver. Another possibility is that the XON/XOFF printer handshake is turned off in the printer setting because, for example, the printer setting is based on a serial or parallel interface hardware printer handshake.

My question is how the printer settings are. This can often be printed out by pressing the on/off line feed button or a reset button for some time when switching on the printer. See the user manual for the correct actions.
 
Upvote 0
You see an abruptly disconnection in Android with the error message "E/bt_btif_sock_rfcomm" and a half printed receipt. The printer has a limited internal memory buffer in which the printer data is temporarily stored. In this case, full = full. If the buffer is about to become full, the printer will send an XOFF command with the intention to directly stop receiving more incommoding data. If an OS is more efficient at processing the printer data, sending it faster, or Bluetooth than the printer can print, the printer's internal buffer becomes full.

When the buffer can receive data again, it sends an XON character. If your program does not stop sending printer data after an XOFF message, the printer will hang. Only what is in the buffer is still printed and the printer stops immediately (thats why you see a half receipt). If that is in the middle of a printer control command, my experience is that almost no printer survives this without a power off/on action (thats why you must hard reset the printer).

What I am missing in the program is checking whether the printer has an XOFF status message with the character Pause transmission code XOFF, ASCII codec DC3, 19 decimal or 13 Hexadecimal. The XON Resume transmission ASCII code is DC1, ASCII code 17 or 11 Hexadecimal. All this is missing from the program.

This so-called XON/XOFF printer handshake could of course be hidden in either the OS or the printer driver. Another possibility is that the XON/XOFF printer handshake is turned off in the printer setting because, for example, the printer setting is based on a serial or parallel interface hardware printer handshake.

My question is how the printer settings are. This can often be printed out by pressing the on/off line feed button or a reset button for some time when switching on the printer. See the user manual for the correct actions.
Unfortunately, the problem is not with the printer, because it prints perfectly with all Android devices except Android 11
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Unfortunately, the problem is not with the printer, because it prints perfectly with all Android devices except Android 11
I use Android11 (and other android versions)
The example EscPOSPrinter works with not porblem at all.

Have you tested the example using Android11?

if the issue is not in your printer maybe it is in your code.. better post a small example showing the issue
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
If the issue is not in your printer maybe it is in your code.. better post a small example showing the issue
You should create a single string buffer and send it once to the printer instead of sending multiple single strings.
 
Upvote 0
Top