auctifera-josed / starprnt

Cordova plugin for the Star micronics printers
MIT License
40 stars 39 forks source link

printing to TSP100iiiBI via StarGraphic fails with large byte array #32

Open daniellizik opened 5 years ago

daniellizik commented 5 years ago

I'm trying to send a large byte array to .print with the appendRawBytes print command (it's a decoded base64 string). The size of the array is 1335297 bytes (~1335.3 kB). On smaller arrays the TSP100iiiBI prints fine, but for larger arrays my app crashes and I get an error report on crashlytics:

StarPRNT.m line 1226
-[StarPRNT appendCommands:printCommands:]

Anyone else seen this problem? Here's the byte array I'm sending.

I could probably solve this by breaking up the raster into chunks and printing those, then on the final chunk cutting the paper but if there's some configuration I'm missing that'd be great.

daniellizik commented 5 years ago

Testing printing just a really long black line from safari technology preview console

(() => {
  const n = 550000;
  const arr = [
    98,
    n,
    0,
    ...(new Array(n).fill(255))
  ];
  window.starprnt.print(
    'BT:TSP100',
    'StarGraphic',
    [{ appendRawBytes: arr }],
    (e) => alert(JSON.stringify(e)),
    (e) => alert(JSON.stringify(e))
  );
})();

this crashes iOS, but around n = 525000 seems to be the limit but at that size it takes maybe 10 seconds for my TSP100iiiBI to receive the data

daniellizik commented 5 years ago

Experimenting with setting the raster page length

screen shot 2019-03-05 at 13 02 21

(() => {
  const n = 525000;
  const arr = [
    27, 42, 114, 80, 0, 0,
    98,
    n,
    0,
    ...(new Array(n).fill(200))
  ];
  window.starprnt.print(
    'BT:TSP100',
    'StarGraphic',
    [{ appendRawBytes: arr }],
    (e) => alert(JSON.stringify(e)),
    (e) => alert(JSON.stringify(e))
  );
})();

This doesn't seem to do anything different, neither does setting raster page length to 64000

thomasImagefields commented 3 years ago

Hi @daniellizik,

Is it possible to share the complete code, i also generate receipt with Imagick without success. If I can reproduce maybe I can help you.

daniellizik commented 3 years ago

Hi @daniellizik,

Is it possible to share the complete code, i also generate receipt with Imagick without success. If I can reproduce maybe I can help you.

I never figured it out. Seems to be an issue in iOS, not this lib. Anyway, I am just chunking the payload which works fine but is a a bit slower (especially on bluetooth) since each payload needs to be transmitted sequentially.

thomasImagefields commented 3 years ago

Hi @daniellizik, Is it possible to share the complete code, i also generate receipt with Imagick without success. If I can reproduce maybe I can help you.

I never figured it out. Seems to be an issue in iOS, not this lib. Anyway, I am just chunking the payload which works fine but is a a bit slower (especially on bluetooth) since each payload needs to be transmitted sequentially.

Thanks for you response. Personally I still have some problems with the structure of the data which is sent in the appendRawBytes parameter, if you have a complete example I would be the happiest of men.