Closed dphaas closed 3 years ago
Same behavior is observed when single stepping in debug. Read is seen on USB bus prior to Python statement execution and when Python statement is executed on USB transaction is observed.
What's probably going on is that the kernel has to automatically enqueue incoming HID reports, which means it's always reading from the device, at the device's specified pooling rate.
You may be able to override this behavior at the kernel level (either by disabling this queue or by changing the pooling rate), but maybe the device shouldn't present itself as a HID if it doesn't expect to be used according to the HID specification without too many quirks.
Like said above, this seems like the issue of a hardware you are using, not the library.
What kind of device are you using? Is that some kind of DIY device? If yes and refreshing every 1 ms is not what you want, you should increase the polling interval in the USB endpoint descriptor. See bInterval
in https://www.beyondlogic.org/usbnutshell/usb5.shtml#EndpointDescriptors
Hey Guys thanks for the prompt responses. You guys are absolutely right. After digging in to HID descriptions (thanks for the link) and underlying USB interrupt functions it is clear the system side, including the library, is doing everything it should with very little latency. Sorry to bother you!
As background, I am trying to get https://github.com/nonNoise/PyMCP2221A to work with a PICKit serial adaptor (Microchip MCP2221A) connected to PMBus power supply. This involves USB HID > I2C Bus > SMBus > PMBus. PyMCP2221A has some "may want to add sleep() time" comments, so obviously there has been some issues that have not been resolved. hipapi library is not the cause.
I'm curious, is this power supply with a PIC-based bridge to PMBus an off-the-shelve product?
The power supply is Advanced Energy Coolx600 with PMBus (slave). The PMBus master is a PICKit Serial (MCP2221A).
Cool! And thanks for humoring my curiosity : )
I have a simple write, delay, read sequence: self.mcp2221a.write(buf) time.sleep(1) rbuf = self.mcp2221a.read(PACKET_SIZE) The hardware I'm communicating with needs the delay to accomplish a task but I keep getting command completion error. What I see on Wireshark is the read immediately follows, within 1 ms, the write which does not allow the command to complete. It's as if hidapi anticipates the USB read and executes prior to the Python statement. Wireshark capture: