[Errno 32] Pipe Error using PyUSB; SLM-25 Decibel Meter Connected to Laptop #411
-
Hi, I am having trouble trying to obtain data from a SLM-25 sound level meter from Gain Express using PyUSB. Laptop OS is Windows 10, PyUSB version 1.2.1, and Python version 3.9.10. I have used Zadig to replace the drivers with WinUSB. It seems like there is a Pipe error, but not sure how to fix it. I have been stuck for 3 weeks and am very desperate. Any help would be greatly appreciated, thank you! I have the Code, Output, and Error posted below: Code: #!/usr/bin/python
import sys
import usb.core
import usb.util
import time
import unittest
import usb.core
import usb._interop
from usb._debug import methodtrace
import usb.util
import usb.backend.libusb0 as libusb0
import usb.backend.libusb1 as libusb1
import usb.backend.openusb as openusb
dev=usb.core.find(idVendor=0x10c4,idProduct=0x82cd)
assert dev is not None
print (dev)
print (hex(dev.idVendor)+','+hex(dev.idProduct))
dev.set_configuration()
while True:
time.sleep(1)
try:
#ret = dev.read(0x81, 200, 100) #results in USBTimeoutError
ret = dev.ctrl_transfer(bmRequestType=0xC0,bRequest=0x04,wValue=0,wIndex=0,data_or_wLength=200)
dB = (ret[0]+((ret[1]&3)*256))*0.1+30
print (dB)
finally:
print("success") Output:
Error:
The error occurs at the line ret = dev.ctrl_transfer(bmRequestType=0xC0, bRequest=0x04, wValue=0, wIndex=0, data_or_wLength=200) ANY HELP WILL BE APPRECIATED! MAHALOS! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
One way to look at a problem like this is to go to the backend documentation for the call and the error. You haven't mentioned, but I'm going to assume for now that the backend is libusb 1.0. Under that assumption, the error is That said, another thing to note is the #ret = dev.read(0x81, 200, 100) #results in USBTimeoutError This might be relevant because P.S. In the future, posting the complete exception and backtrace is preferable, as there might be something there that is meaningful to me or others. And, when debugging errors, you should also run your example with P.P.S. Moving this to the Discussions tab, Q/A. |
Beta Was this translation helpful? Give feedback.
-
@808reefer , did you ever get the USB reading of the decibel working from python? |
Beta Was this translation helpful? Give feedback.
One way to look at a problem like this is to go to the backend documentation for the call and the error. You haven't mentioned, but I'm going to assume for now that the backend is libusb 1.0.
Under that assumption, the error is
LIBUSB_ERROR_PIPE
, andlibusb_control_transfer()
is documented to return it "if the control request was not supported by the device."That said, another thing to note is the
dev.set_configuration()
call, and the commented out line:#ret = dev.read(0x81, 200, 100) #results in USBTimeoutError
This might be relevant because
dev.set_configuration()
can act as a soft-reset in some cases, and that could explain the mentioned timeout. More information about this can be f…