glucometerutils icon indicating copy to clipboard operation
glucometerutils copied to clipboard

Unable to connect to TaiDoc/TD-4235B/td42xx

Open mrfloppy42 opened this issue 1 year ago • 10 comments

I have a "GlucoRx Q". Digging about and it seems this is a rebrand of TD-4235B. Following the instructions in the README.md (confirmed all deps installed), and I get:

# ./glucometer.py --driver td42xx info
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/serial/urlhandler/protocol_cp2110.py", line 86, in open
    self._hid_handle.open_path(portpath)
  File "hid.pyx", line 142, in hid.device.open_path
OSError: open failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/Icecream/GIT/glucometerutils/./glucometer.py", line 10, in <module>
    glucometer.main()
  File "/home/Icecream/GIT/glucometerutils/glucometerutils/glucometer.py", line 118, in main
    device = requested_driver.device(args.device)
  File "/home/Icecream/GIT/glucometerutils/glucometerutils/drivers/td42xx.py", line 148, in __init__
    super().__init__(f"cp2110://{device}")
  File "/home/Icecream/GIT/glucometerutils/glucometerutils/support/serial.py", line 60, in __init__
    self.serial_ = serial.serial_for_url(
  File "/usr/local/lib/python3.10/dist-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.10/dist-packages/serial/urlhandler/protocol_cp2110.py", line 88, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno None] could not open port cp2110://None: open failed

I've also tried with all devices (using --device) that it creates (mainly /dev/hidraw0 but it generates some UID-based usb things under dev also - anything I add replaces "None" in: cp2110://None)

Syslog of plugging in the device:

Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4743.908653] usb 1-2: new full-speed USB device number 88 using xhci_hcd
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060228] usb 1-2: New USB device found, idVendor=10c4, idProduct=ea80, bcdDevice= 1.00
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060243] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060249] usb 1-2: Product: CP2110 HID USB-to-UART Bridge
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060254] usb 1-2: Manufacturer: Silicon Laboratories
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060258] usb 1-2: SerialNumber: 00DBA102
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.071839] hid-generic 0003:10C4:EA80.000C: hiddev0,hidraw0: USB HID v1.11 Device [Silicon Laboratories CP2110 HID USB-to-UART Bridge] on usb-0000:00:14.0-2/input0
Sep 15 15:13:15 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4745.038021] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:16 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4746.004747] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:16 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4746.004888] usb usb1-port8: attempt power cycle
Sep 15 15:13:17 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4747.288447] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4748.256727] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4748.256877] usb usb1-port8: unable to enumerate USB device
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: checking bus 1, device 88: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: bus: 1, device: 88 was not an MTP device
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: checking bus 1, device 88: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: bus: 1, device: 88 was not an MTP device
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4743.908653] usb 1-2: new full-speed USB device number 88 using xhci_hcd
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060228] usb 1-2: New USB device found, idVendor=10c4, idProduct=ea80, bcdDevice= 1.00
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060243] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060249] usb 1-2: Product: CP2110 HID USB-to-UART Bridge
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060254] usb 1-2: Manufacturer: Silicon Laboratories
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.060258] usb 1-2: SerialNumber: 00DBA102
Sep 15 15:13:14 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4744.071839] hid-generic 0003:10C4:EA80.000C: hiddev0,hidraw0: USB HID v1.11 Device [Silicon Laboratories CP2110 HID USB-to-UART Bridge] on usb-0000:00:14.0-2/input0
Sep 15 15:13:15 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4745.038021] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:16 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4746.004747] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:16 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4746.004888] usb usb1-port8: attempt power cycle
Sep 15 15:13:17 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4747.288447] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4748.256727] usb usb1-port8: Cannot enable. Maybe the USB cable is bad?
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th kernel: [ 4748.256877] usb usb1-port8: unable to enumerate USB device
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: checking bus 1, device 88: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: bus: 1, device: 88 was not an MTP device
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: checking bus 1, device 88: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 15:13:18 Icecream-ThinkPad-X1-Carbon-6th mtp-probe: bus: 1, device: 88 was not an MTP device

system info:

pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

let me know if there's anythign else I can provide?

mrfloppy42 avatar Sep 15 '22 14:09 mrfloppy42

some more info from another PC - those USB errors in the original look bad, but are normal for that laptop. following is the same from another PC to the device created on USB plugin:

$ glucometer --driver td42xx --device /dev/hidraw1 info
Traceback (most recent call last):
  File "/home/blah/.local/lib/python3.10/site-packages/serial/urlhandler/protocol_cp2110.py", line 86, in open
    self._hid_handle.open_path(portpath)
  File "hid.pyx", line 142, in hid.device.open_path
OSError: open failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/blah/.local/bin/glucometer", line 8, in <module>
    sys.exit(main())
  File "/home/blah/.local/lib/python3.10/site-packages/glucometerutils/glucometer.py", line 118, in main
    device = requested_driver.device(args.device)
  File "/home/blah/.local/lib/python3.10/site-packages/glucometerutils/drivers/td42xx.py", line 148, in __init__
    super().__init__(f"cp2110://{device}")
  File "/home/blah/.local/lib/python3.10/site-packages/glucometerutils/support/serial.py", line 60, in __init__
    self.serial_ = serial.serial_for_url(
  File "/home/blah/.local/lib/python3.10/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/home/blah/.local/lib/python3.10/site-packages/serial/urlhandler/protocol_cp2110.py", line 88, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno None] could not open port cp2110:///dev/hidraw1: open failed

syslog during device plugin:

Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.742957] usb 1-2: new full-speed USB device number 9 using xhci_hcd
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.894091] usb 1-2: New USB device found, idVendor=10c4, idProduct=ea80, bcdDevice= 1.00
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.894103] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.894108] usb 1-2: Product: CP2110 HID USB-to-UART Bridge
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.894112] usb 1-2: Manufacturer: Silicon Laboratories
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.894115] usb 1-2: SerialNumber: 00DBA102
Sep 15 18:25:31 icecream-latitude-5310-the2nd kernel: [ 1084.907144] hid-generic 0003:10C4:EA80.0007: hiddev0,hidraw1: USB HID v1.11 Device [Silicon Laboratories CP2110 HID USB-to-UART Bridge] on usb-0000:00:14.0-2/input0
Sep 15 18:25:31 icecream-latitude-5310-the2nd mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 18:25:31 icecream-latitude-5310-the2nd mtp-probe: bus: 1, device: 9 was not an MTP device
Sep 15 18:25:31 icecream-latitude-5310-the2nd mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2"
Sep 15 18:25:31 icecream-latitude-5310-the2nd mtp-probe: bus: 1, device: 9 was not an MTP device

system:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

mrfloppy42 avatar Sep 15 '22 17:09 mrfloppy42

That device should be working fine, as I do have one somewhere for testing and the driver was developed with it (https://flameeyes.blog/2021/03/16/glucometer-notes-glucorx-q/).

Did you copy the udev rules into /etc/udev/rules.d ? It might be as simple as your user not having permission to access the device itself.

Flameeyes avatar Sep 17 '22 18:09 Flameeyes

Thanks for the reply - this has come full circle in that your research is what I found before this repo!

Didn't see instructions on the udev rules. have added them now, but unsure they are being picked up for this device? Tested all again with the same results - normal and root users.

re-confirm all dependencies satisfied.

tested on both of the newly created devices when it gets plugged in - /dev/hidraw0 + /dev/usb/hiddev0 - both show the same output

I'm not thinking there's an issue on your side, more likely in my understanding!

mrfloppy42 avatar Sep 18 '22 07:09 mrfloppy42

Can you check ls -l /dev/hidraw0 /dev/bus/usb/* to see if the device nodes are accessible by your user?

I'm a bit at a loss because I can't reproduce this on my setup, but it might be a Ubuntu specific problem… I need to set up a Ubuntu VM at some point anyway, but I haven't had time to look into most of my FLOSS work lately…

Flameeyes avatar Sep 19 '22 14:09 Flameeyes

thanks for looking into it - I'm a sysadmin by trade so happy to help out with anything I can do on my end?

Requested outputs are: before device plugin

/dev/bus/usb/001:
total 0
crw-rw-r-- 1 root root 189, 0 Sep 19 15:05 001
crw-rw-r-- 1 root root 189, 1 Sep 19 15:34 002
crw-rw-r-- 1 root root 189, 6 Sep 19 15:34 007

/dev/bus/usb/002:
total 0
crw-rw-r-- 1 root root 189, 128 Sep 19 15:05 001
crw-rw-r-- 1 root root 189, 129 Sep 19 15:34 002

after device plugin

crw------- 1 root root 240, 0 Sep 19 15:44 /dev/hidraw0

/dev/bus/usb/001:
total 0
crw-rw-r-- 1 root root 189,  0 Sep 19 15:05 001
crw-rw-r-- 1 root root 189,  1 Sep 19 15:34 002
crw-rw-r-- 1 root root 189,  6 Sep 19 15:34 007
crw-rw-r-- 1 root root 189, 37 Sep 19 15:44 038

/dev/bus/usb/002:
total 0
crw-rw-r-- 1 root root 189, 128 Sep 19 15:05 001
crw-rw-r-- 1 root root 189, 129 Sep 19 15:34 002

Tested as root + with sudo, same outputs as before. Did a chmod a+rwx /dev/hidraw0 and tried with my user, same output. Having a dig about on the wider internets, this talks about permissions etc and using groups to set things up properly (like in the redhat-a-likes). Unsure if it's permissions at this point given even root can't get it working?

BTW, I've confirmed hardware/cable on a windows box using the proprietary legacy software from glucorx. Will test on another machine ASAHP, but it's the same version of ubuntu (but will further rule out hardware issues)

mrfloppy42 avatar Sep 19 '22 14:09 mrfloppy42

Tested on another box with same outcomes. Pretty sure it's not hardware.

mrfloppy42 avatar Sep 19 '22 15:09 mrfloppy42

I have the same issues as those outlines by mrfloppy42, 22.04.1 LTS (Jammy Jellyfish). Any pointers welcome, happy to help with debugging/coming up with a fix.

patrickomatik avatar Feb 06 '23 15:02 patrickomatik

I too have what to me looks like same issues as mrfloppy42, 22.04.1 LTS (Jammy Jellyfish). Except I am pretty much a Newbie. It’s been a very steep learning curve for me. I have enjoyed the journey so far, but am now approaching hair tearing stage. My attempt with this is using a Pi Zero W. Running Raspian Bullseye. My glucometer is GlucoRx Q which shows up apparently correct id etc information with lsusb, so it seems to be connected. If I can get this working, I hope to pass the CSV data to a Googlesheets spreadsheet. I already set this up to display CSV data from the original Windows GlucoRx Q software. Anyone got this working with GlucoRx Q or equivalent?

Notmuchofaclue avatar Mar 05 '24 14:03 Notmuchofaclue

So I found the fix for this - it is to do with a braille reader that uses the same chipset as many glucose meters and other devices too, a CH340. It monopolises the device. The quick and dirty solution is to remove the associated braille packages: sudo apt purge brltty brltty-x11 libbrlapi0.6 python3-brlapi xbrlapi

patrickomatik avatar Mar 05 '24 14:03 patrickomatik

Thanks patrickomatik for responding. I read up on the CH340 etc and brltty. I found this- missing port on Linux caused by interference from BRLTTY #155 in GitHub help. I tried a couple of tests: ps -C brltty Response was: PID TTY TIME CMD This seems to indicate that my Raspian setup does not include brltty. When I ran your suggested: sudo apt purge brltty brltty-x11 libbrlapi0.6 python3-brlapi xbrlapi Response: E: Unable to locate package libbrlapi0.6 E: Couldn’t find any package by glob ‘libbrlapi0.6’

The brltty issue should show the glucometer disconnected but when I dmesg, I get:

[ 1105.883713] usb 1-1.1: new full-speed USB device number 5 using dwc_otg [ 1106.118357] usb 1-1.1: New USB device found, idVendor=10c4, idProduct=ea80, bcdDevice= 1.00 [ 1106.118429] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1106.118456] usb 1-1.1: Product: C8051F34x Development Board [ 1106.118476] usb 1-1.1: Manufacturer: Silicon Laboratories [ 1106.118496] usb 1-1.1: SerialNumber: 0079876543210 [ 1106.205055] hid-generic 0003:10C4:EA80.0004: hiddev97,hidraw2: USB HID v1.11 Device [Silicon Laboratories C8051F34x Development Board] on usb-20980000.usb-1.1/input0

Which seems to me correct., and therefore I am getting same error results from glucometerutils for a different unknown reason. Something is blocking the glucometer software from seeing the USB port. Is this correct?

Just in case this has to do with Udev rules. I included the 69-glucometer rules but I am not sure about what they mean. The first 2 lines in the file end in a goto label.which jumps to the end of the file. The result (if I understand correctly ) is that after the line ACTION!= …..etc the rest of the rules in the file are ignored. I suspect that sometimes the first line might need to be commented out to enable the second line to take effect. I experimented with doing this, but it made no difference. Did you have to alter the Udev file for your setup?

Notmuchofaclue avatar Mar 09 '24 21:03 Notmuchofaclue