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

Libusb printer backend back channel does not honour 250ms timing on success #5583

Closed
chriscz opened this issue May 17, 2019 · 1 comment
Closed
Assignees

Comments

@chriscz
Copy link

chriscz commented May 17, 2019

Hi there

I'm busy implementing back-channel support for the Star Micronics thermal printer, the STAR TSP 700II. I've been investigating the problem for a while now as printer & CUPS development are fairly new to me so please excuse any misunderstandings :).

I've managed to get the backchannel read working in my filter implementation, but the reads on the device USB was happening every 1ms because each read succeeds, this brought my printing speed to a crawl, I temporarily enforced the hard 250ms limit and the problem went away. I've experimented and successfully brought the read frequency down to 20ms with no significant impact on my printing speed.

I'd like to know is if there's an appropriate place to add a backchannel reading speed hard-limit? If so, I wouldn't mind creating a pull-request for the functionality.

I'd prefer making the USB backend marginally more configurable as the change is so small and forking the backend wouldn't benefit the CUPS community.

The section in question is in the file backend/usb-libusb.c

   /*
    * Make sure this loop executes no more than once every 250 miliseconds...
    */
    // XXX HERE only enforces throttle if reading fails
    if ((readstatus != LIBUSB_SUCCESS || rbytes == 0) &&
        (g.wait_eof || !g.read_thread_stop))
    {
      gettimeofday(&now, NULL);
      if (timercmp(&now, &end, <))
      {
	timersub(&end, &now, &timeleft);
	usleep(1000000 * timeleft.tv_sec + timeleft.tv_usec);
      }
    }
  } while (g.wait_eof || !g.read_thread_stop);
@michaelrsweet
Copy link
Collaborator

I think we should limit reads to once every 250ms. That will likely limit the number of unidir quirks we use as well...

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

2 participants