niimprint icon indicating copy to clipboard operation
niimprint copied to clipboard

Fixed image being cut off by adding longer timeout delay.

Open jhnnyb opened this issue 1 year ago • 5 comments

fix(printer): Fixed images not being able to print fully.

This change "fixes" an issue of images not being able to print fully. This is what I've done to allow my printer to print 50x80mm labels with a fair amount of detail and density. Only drawback is that it increases print time. This might be more of a patch job than a fix, but I figured I share what I did to make consistent prints.

Issue: #3

jhnnyb avatar May 28 '24 04:05 jhnnyb

@jhnnyb I'm ok to merge this as a temporary fix, if it helps at least some people. Can you please clarify some things:

  • Which printer / OS / connection method you're using
  • How bad is printing time affected?
  • Why do you think it helps? As far as I know, timeout param is only used for reading the data, so it's a little unclear why it works

AndBondStyle avatar May 28 '24 14:05 AndBondStyle

  • Niimbot B1, Fedora Linux 40, USB
  • I see around a 5-8s increase, I'm assuming it is taking time to process the image/buffer alongside increasing the timeout time.
  • I'm assuming that somehow the connection times out while it is downloading data, which explains the cut off. Playing around with the timeout param makes it so it cuts out at different parts of the image. This is both based on time of timeout, and the density/complexity of the image.

If this is something that is seen a a viable solution for now, I have ideas on how to parameterize the wait time, so you would not need to wait the full duration if you're printing on a small label. I will work on this sometime this week and update the PR.

Is the data being sent to the Niimbot in some sort of standard protocol, or something that was reverse engineered?

jhnnyb avatar May 29 '24 04:05 jhnnyb

  • I see around a 5-8s increase

That doesn't sound good...

  • the timeout param makes it so it cuts out at different parts of the image

Sounds like it's roughly equivalent to increasing the sleep delay before end_print (did you try playing around with this?). Except if it's actually not the timing problem, but rather overflowing the internal printer buffer.

standard protocol, or something that was reverse engineered

Mostly reverse engineered, but I also have some decompiled info from the official java app, but haven't looked at it in detail yet

AndBondStyle avatar May 29 '24 08:05 AndBondStyle

I'm tested out timeout for 0.9, it works pretty good

joeripper avatar Jun 12 '24 11:06 joeripper

Hi all sorry for being MIA. I hope to have some time this weekend to look at the root cause for this. The quick fix outlined in this PR has been enough for me and my purposes, but it would be nice to see the route cause. I'll update with my findings sometime later this weekend.

jhnnyb avatar Jul 12 '24 02:07 jhnnyb