如何从 Contour Next One USB 血糖仪中提取数据?

问题描述

我正在尝试构建一个系统,该系统可随时间显示我的健康指标。现在我正在尝试通过 USB 将数据从我的血糖仪(Contour NEXT ONE)提取到 RaspBerry Pi。我正在使用 PyUSB,并且能够获取设备数据(产品 ID、制造商 ID、序列号),但无论我做什么,我似乎都无法访问实际的葡萄糖测量值。

插入设备后,重复发送 ACK(十六进制或十进制 6)应该使仪表以标题记录(逐行)响应,然后是每行测量数据。标题记录只有 3 行,包含有关设备及其设置的信息。标题记录如下所示(请参阅下面 Meter 文档中的 pp14-17):

<STX>1H|\^&||XXXXXX|Contour7800^01.01\01.03\02.00^7801-1234567|
A=1^C=7^R=0^S=0^U=0^V=20600^X=090080140110^a=0^J=0|3|||||P|1
|20210508131000|<CR><ETB>F3<CR><LF>

但是无论我发送 ACK 多少次,我都只能取回标题记录。实际测量数据应该如下所示:

<STX>4R|1|^^^glucose|90|mg/dL^P<CR><ETB>48<CR><LF>

我是否正确发送了 ACK,并正确写入/读取到了正确的端点? 代码

    import usb.core
    import usb.util
    import sys
    import time
    
    dev = usb.core.find(idvendor=0x1a79,idProduct=0x7800)
    
    attempts = 0
    while dev is None:
        print("Device not found on attempt " + str(attempts) + " Trying again...")
        time.sleep(1)
        attempts+=1
        if attempts > 10:
            print("Device Failed to connect. Exiting program.")
            attempts = 0
            exit(1)
    print("Device found!")
    attempts = 0 #reset attempts
    
    print(dev)
    
    productID = dev.product.split("-")[0]
    serialID = dev.product.split("-")[1]
    manufacturerID = dev.manufacturer
    print("Device: " + productID)
    print("SerialNo: " + serialID)
    print("Manufacturer: " + manufacturerID)
    print("......................")
    
    # code to detach kernel's built-in driver
    # so it doesn't interfere
    for cfg in dev:
      for intf in cfg:
        if dev.is_kernel_driver_active(intf.bInterfaceNumber):
          try:
            dev.detach_kernel_driver(intf.bInterfaceNumber)
          except usb.core.USBError as e:
            sys.exit("Could not detatch kernel driver from interface({0}): {1}".format(intf.bInterfaceNumber,str(e)))
    
    dev.set_configuration(1)
    
    #ENDPOINT 0x2: OUT
    #ENDPOINT 0x81: IN
    
    cmd = ' '
    while cmd is not '':
        cmd = str(input('Enter cmd: '))
        dev.write(0x02,cmd,100)
        ret = dev.read(0x81,64,100) #returns a char array
        sret = ''.join([chr(x) for x in ret]) #concatenate char array into string
        print(sret)

显示重复 ACK 的输出仅返回标头记录:https://i.stack.imgur.com/BArmi.png

^两个注释 - 写入 6 或 0x06 或 /x06(作为 cmd)都具有相同的结果。写入端点 0x02 或 0x2 也会产生相同的结果。

仪表的配置信息:https://i.stack.imgur.com/PXbbe.png

仪表文档:https://drive.google.com/file/d/1lplodWDHjIx1PJOYhFdOZMomkD1gOfgM/view?usp=sharing

任何见解将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)