Skip to content

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

@chriscz

Description

@chriscz

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);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions