PyUSB: reading from a USB device

后端 未结 5 1511
攒了一身酷
攒了一身酷 2021-01-22 10:36

This is an updated and shortened question.

Communicating with a USB-device should be easy via PyUSB. So, I\'m trying to read from a USB-device (oscilloscope) using PyUSB

5条回答
  •  北海茫月
    2021-01-22 11:12

    First note that @igrinis posted a video showing what you want to reach.

    (As stated by @igrinis:) For the second value in read(...), you are right in theory. Good thing is that practically often enough you can request way longer answers. So try e.g. requesting 256 bytes and look if that fixes your current code.

    If that does not solve your issue:

    You can try to have a second PC/Laptop around with software from e.g. the manufacturer that is capable of communicating with the device, and use Wireshark (with USBPcap installed) to read the device communication. The USB bulk data transmitted and received is written in Wiresharks "Leftover Capture Data" field. By looking at that you can compare what your script sends and how it should look like to spot mistakes. You can add it as a column to the list of packets by right-clicking and selecting "Apply as column". Your problem might e.g. be the encoding of your command to big or little endian.

    Documentation for PyUSB:

    • Mainly Python Docstring, so call help(...) on every object/function you get from PyUSB. Alternatively, search the PyUSB source code for every function and object you want to read the Docstring of.

    • https://github.com/pyusb/pyusb/blob/master/README.rst

    • https://github.com/pyusb/pyusb/blob/master/docs/faq.rst

    • https://github.com/pyusb/pyusb/blob/master/docs/tutorial.rst

    • https://github.com/pyusb/pyusb/wiki

    [Update] Added hints to a great comment that already gave some of the answers and more.

提交回复
热议问题