admin管理员组

文章数量:1023138

I'm using React Native to build an app that print tickets. I've been successful in printing with Bluetooth printer 5802 and 5802-LD from Zjiang pany. There is a problem which I don't know exatcly the source but when the Java method doesn't wait the printer to actually print but just write the mand instruction which leads me to a problem that I end up sending all the printing mands at once. Sometimes this leads the printer to be out of paper and I'd like to clear the buffer instead of continue printing.

Here you can find the programming manual where in the end of page 20 of the 76mm there is the mand ESC @ which should clear the buffer and initialize the printer (again) but it doesn't(My printer is 58mm but also makes reference to ESC @ mand).The mand manual has the following instructions: .php/service/manual

There is also a couple android apks ready to build on Android Studio in their website: .php/service/driver I've found on their examples the same mand:

It seems to work when I need to actually initialize the print but after that it doesn't work like the description of the manual. Does anyone have an idea or experience with those bluetooth ESC/POS printers to know how should I proceed?

I'm using React Native to build an app that print tickets. I've been successful in printing with Bluetooth printer 5802 and 5802-LD from Zjiang pany. There is a problem which I don't know exatcly the source but when the Java method doesn't wait the printer to actually print but just write the mand instruction which leads me to a problem that I end up sending all the printing mands at once. Sometimes this leads the printer to be out of paper and I'd like to clear the buffer instead of continue printing.

Here you can find the programming manual where in the end of page 20 of the 76mm there is the mand ESC @ which should clear the buffer and initialize the printer (again) but it doesn't(My printer is 58mm but also makes reference to ESC @ mand).The mand manual has the following instructions: http://www.zjiang./en/init.php/service/manual

There is also a couple android apks ready to build on Android Studio in their website: http://www.zjiang./en/init.php/service/driver I've found on their examples the same mand:

It seems to work when I need to actually initialize the print but after that it doesn't work like the description of the manual. Does anyone have an idea or experience with those bluetooth ESC/POS printers to know how should I proceed?

Share Improve this question asked Oct 8, 2018 at 14:06 Vinícius Pacheco VieiraVinícius Pacheco Vieira 4535 silver badges16 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Its long time since you posted but this might help someone struggling.

I've developed a small mobile application with ionic 3 framework. One of my main problems was with the printing service.

User at the end needed to print a receipt. What i did is to make a uint8Array() and merge all the decimals data in there. I tried also with buffers.

I had a problem when sending all the data at once. Printer was stopping at the same point. I broke apart my variables and calcualted their byte size to see if there is something wrong but nothing came up.

I tried to break apart my final variable data to smaller vars and initialize with ESC @ but also this didnt work.

Searching on the internet some "gurus" said that you can ESC @ with a full package of 4kbytes. I also tried to fill rest of the remaining array with null chars up to 4kb and try to initialize but also nothing.

At the end i did a very "Monkey" solution and I am ashamed for that.

I make a seTimout loop through my smaller uintarrays

setTimeout(() => {
    this.btSerial.write(uint8Array)
      .then(dataz => {
        console.log("WRITE SUCCESS", dataz);
      });
  }, 100 + n *100)

and ofcourse it worked.

I think that the problem is, the bytes android can send natively with bluetooth every some ms but im not sure.

Hope i helped a little.

Ps..

dont try to develop mobile apps that use natively things in crossplatform frameworks. You will end up always trying to learn and write packages to unicate natively..

I'm using React Native to build an app that print tickets. I've been successful in printing with Bluetooth printer 5802 and 5802-LD from Zjiang pany. There is a problem which I don't know exatcly the source but when the Java method doesn't wait the printer to actually print but just write the mand instruction which leads me to a problem that I end up sending all the printing mands at once. Sometimes this leads the printer to be out of paper and I'd like to clear the buffer instead of continue printing.

Here you can find the programming manual where in the end of page 20 of the 76mm there is the mand ESC @ which should clear the buffer and initialize the printer (again) but it doesn't(My printer is 58mm but also makes reference to ESC @ mand).The mand manual has the following instructions: .php/service/manual

There is also a couple android apks ready to build on Android Studio in their website: .php/service/driver I've found on their examples the same mand:

It seems to work when I need to actually initialize the print but after that it doesn't work like the description of the manual. Does anyone have an idea or experience with those bluetooth ESC/POS printers to know how should I proceed?

I'm using React Native to build an app that print tickets. I've been successful in printing with Bluetooth printer 5802 and 5802-LD from Zjiang pany. There is a problem which I don't know exatcly the source but when the Java method doesn't wait the printer to actually print but just write the mand instruction which leads me to a problem that I end up sending all the printing mands at once. Sometimes this leads the printer to be out of paper and I'd like to clear the buffer instead of continue printing.

Here you can find the programming manual where in the end of page 20 of the 76mm there is the mand ESC @ which should clear the buffer and initialize the printer (again) but it doesn't(My printer is 58mm but also makes reference to ESC @ mand).The mand manual has the following instructions: http://www.zjiang./en/init.php/service/manual

There is also a couple android apks ready to build on Android Studio in their website: http://www.zjiang./en/init.php/service/driver I've found on their examples the same mand:

It seems to work when I need to actually initialize the print but after that it doesn't work like the description of the manual. Does anyone have an idea or experience with those bluetooth ESC/POS printers to know how should I proceed?

Share Improve this question asked Oct 8, 2018 at 14:06 Vinícius Pacheco VieiraVinícius Pacheco Vieira 4535 silver badges16 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Its long time since you posted but this might help someone struggling.

I've developed a small mobile application with ionic 3 framework. One of my main problems was with the printing service.

User at the end needed to print a receipt. What i did is to make a uint8Array() and merge all the decimals data in there. I tried also with buffers.

I had a problem when sending all the data at once. Printer was stopping at the same point. I broke apart my variables and calcualted their byte size to see if there is something wrong but nothing came up.

I tried to break apart my final variable data to smaller vars and initialize with ESC @ but also this didnt work.

Searching on the internet some "gurus" said that you can ESC @ with a full package of 4kbytes. I also tried to fill rest of the remaining array with null chars up to 4kb and try to initialize but also nothing.

At the end i did a very "Monkey" solution and I am ashamed for that.

I make a seTimout loop through my smaller uintarrays

setTimeout(() => {
    this.btSerial.write(uint8Array)
      .then(dataz => {
        console.log("WRITE SUCCESS", dataz);
      });
  }, 100 + n *100)

and ofcourse it worked.

I think that the problem is, the bytes android can send natively with bluetooth every some ms but im not sure.

Hope i helped a little.

Ps..

dont try to develop mobile apps that use natively things in crossplatform frameworks. You will end up always trying to learn and write packages to unicate natively..

本文标签: javascriptESC POS bluetooth printer clear BufferStack Overflow