Closed Klikini closed 1 year ago
Not sure why, but you can try to print the devices
variable here:
Perhaps you didn't have the same version of RADEX ONE, perhaps the baud rate is not working... Perhaps also that like RADEX RD1212, v1 use usb+serial, v2 use usb only.
I added print(list(devices))
at line 80 and it printed []
.
My Radex One is orange, and I think it might be a newer version than the white ones pictured. Maybe they stopped offering a serial port over USB?
I don't know, we can try the following. Replace:
# RADEX ONE v1
# search usb device (ABBA/A011)
self.usb = usb.core.find(idVendor=0xabba, idProduct=0xa011, backend=backend)
if self.usb is not None:
self.com = 'ONEv1'
# search usb serial device (https://stackoverflow.com/a/25112066/2980105)
devices = serial.tools.list_ports.grep('RADEX')
for device in devices:
self.serial = serial.Serial(port = device.device, baudrate = 9600, timeout = 0.5)
return # device found
if self.serial is None:
raise ValueError('Error: RADEX ONE (serial) not found')
by:
# RADEX ONE v1
# search usb device (ABBA/A011)
self.usb = usb.core.find(idVendor=0xabba, idProduct=0xa011, backend=backend)
if self.usb is not None:
self.com = 'RD1212v2'
# usb reset
self.usb.reset()
if sys.platform != 'win32' and sys.platform != 'cygwin' and self.usb.is_kernel_driver_active(0):
self.usb.detach_kernel_driver(0)
self.usb.set_configuration()
return # device found
Is this your device?
Yes, that's my device.
Trying that code lets the constructor succeed, but now read(last=True)
fails with:
Traceback (most recent call last):
File "/home/andy/PycharmProjects/libradex/main.py", line 5, in <module>
reading = reader.read(last=True)
File "/home/andy/.local/share/virtualenvs/libradex-l8hJUGoj/lib/python3.9/site-packages/radexreader/__init__.py", line 183, in read
self.hid_set_report((0x12, 0x12, 0x01, 0x02, key, 0, 0, 0, 0, 0, 0, 0, 0x3c, 0x84))
File "/home/andy/.local/share/virtualenvs/libradex-l8hJUGoj/lib/python3.9/site-packages/radexreader/__init__.py", line 144, in hid_set_report
self.usb.ctrl_transfer(
File "/home/andy/.local/share/virtualenvs/libradex-l8hJUGoj/lib/python3.9/site-packages/usb/core.py", line 1082, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File "/home/andy/.local/share/virtualenvs/libradex-l8hJUGoj/lib/python3.9/site-packages/usb/backend/libusb1.py", line 893, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File "/home/andy/.local/share/virtualenvs/libradex-l8hJUGoj/lib/python3.9/site-packages/usb/backend/libusb1.py", line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 32] Pipe error
Process finished with exit code 1
That enters libusb code at https://github.com/luigifab/python-radexreader/blob/master/src/radexreader/__init__.py#L145
I get also a Pipe error
with my RD1212v2 when the report
data used by hid_set_report
are wrong.
I suggest to you to install Wireshark or something similar and official tool of QuartaRad, to capture packets.
I also see in gist that it uses different addresses. Perhaps you can try them here: https://github.com/luigifab/python-radexreader/blob/fd77d6900155618d6ed189b0c7ddd0d48ff309a2/src/radexreader/__init__.py#L184
For example something like 0x7b, 0xff, 0x20, 0...
for 7BFF 2000 0600 1800 ____ 4600 0008 0C00 F3F7
, I don't remember how it's work exactly.
What are the functionalities of your device? instant µSv/h? history of µSv/h? date/hour?
I wanted to use this library to create a Home Assistant integration for RADEX devices, but it seems my RADEX ONE does not offer a serial port.
radexreader recognizes my device but cannot find a serial port to open, and prints:
OS: OpenSUSE Leap 15.3
Relevant lsusb line:
Relevant dmesg lines:
I attempted to create a library like this on my own before I found this one, and during that process I stumbled across https://gist.github.com/mwwhited/2491b47c3483f1ac319c227f0dd3a814, so maybe these devices just don't offer a serial port anymore?
Please let me know if there's any other information I could provide or testing I could do that would be helpful :)