glucometerutils icon indicating copy to clipboard operation
glucometerutils copied to clipboard

Problem with otverio2015 driver

Open velimsky opened this issue 6 years ago • 8 comments

Hi,

I'm trying to read from my Verio meter via USB, but fail with following report;

$ glucometer --driver otverio2015 --device /dev/sdb dump Traceback (most recent call last): File "/usr/local/bin/glucometer", line 11, in <module> load_entry_point('glucometerutils==1', 'console_scripts', 'glucometer')() File "/usr/local/lib/python3.5/dist-packages/glucometerutils-1-py3.5.egg/glucometerutils/glucometer.py", line 86, in main File "/usr/local/lib/python3.5/dist-packages/glucometerutils-1-py3.5.egg/glucometerutils/drivers/otverio2015.py", line 123, in __init__ File "/usr/local/lib/python3.5/dist-packages/pyscsi/pyscsi/scsi_device.py", line 67, in __init__ self.open() File "/usr/local/lib/python3.5/dist-packages/pyscsi/pyscsi/scsi_device.py", line 105, in open self._fd = linux_sgio.open(self._file_name, AttributeError: module 'linux_sgio' has no attribute 'open'

It looks like some problem with python-scsi. Please help, I am ready to try any suggestions.

velimsky avatar Mar 29 '18 21:03 velimsky

Hi sorry for the extreme delay in this reply. Can you provide which operating system this happens on, and how python-scsi was installed?

Flameeyes avatar Jun 04 '18 16:06 Flameeyes

Hello, I am using Linux Mint, kernel 4.13.0-43-generic x86_64. I have installed python-scsi freshly from github, using setup.py install. For glucometerutils, I've either used the same manual approach with the latest github version, or pip3. Same results. Thanks for help.

velimsky avatar Jun 04 '18 16:06 velimsky

Hello, I'm currently having the same issue. This happens both in Debian and Ubuntu virtualbox. Host machine is Windows 10. Was this resolved in any way?

tatanpoker09 avatar Oct 14 '18 18:10 tatanpoker09

I spent a day chasing my tail on this problem. I am using Fedora 29, kernel 4.20.6-200.fc29.x86_64 although none of that really matters. I did not "solve" the problem, just found a work-around as follows:

  • cd into glucometerutils directory
  • . bin/activate
  • pip download PYSCSI
  • pip download LINUX-SGIO
  • tar xzvf PYSCSI-1.0.tar.gz
  • tar xzvf LINUX_SGIO-1.0.tar.gz
  • cd LINUX_SGIO-1.0
  • NOTE: these two packages have interdependencies and will not build correctly if not co-located. The 'setup.py' and 'setup.cfg' files are identical so there is no problem merging the two directories for the purpose of building the libraries. So, just move all the files from PYSCSI-1.0/ into LINUX_SGIO-1.0/
  • mv ../PYSCSI-1.0/* .
  • Now you can successfully build and install the pyscsi and linux_sgio libraries and they should work
  • python3 setup.py build
  • python3 setup.py install Now when I ran "glucometer.py --driver otverio2015 --device /dev/sg3 info" I got an error "linux_sgio.SGIOError: Failed to open device /dev/sg3; Permission denied." For a quick and dirty test, I opened the permission on /dev/sg3 with "sudo chmod o+rw /dev/sg3" Finally I ran "glucometer.py --driver otverio2015 --device /dev/sg3 info" again and got the following: OneTouch Verio Flex glucometer Serial Number: ZFKVSQFP Version Information: Software version: RI_01.07.01 Native Unit: mg/dL Time: 2019-02-10 23:03:08

SUCCESS!! I hope this is helpful to someone.

pycoder-adc avatar Feb 11 '19 18:02 pycoder-adc

Hi pycoder-adc,

I can confirm that it works! At least on my office machine, kernel 4.4.0-142-generic, Ubuntu Trusty. Kudos to you!

Jakub

velimsky avatar Feb 12 '19 10:02 velimsky

Hi pycoder-adc,

I can also confirm that it works on Linux Mint 19.1, kernel 4.18.0-14-generic, Python 3.7.2

But first I had to remove (from glucometerutils-venv/lib/python3.7/site-packages/) previously installed PYSCSI-1.0 and LINUX_SGIO-1.0. So it is better to do it on freshly created venv.

furas avatar Feb 14 '19 17:02 furas

I tried to install python-scsi in python 3.x using code from github

git clone https://github.com/rosjat/python-scsi
cd python-scsi
python3 setup.py build
python3 setup.py install 

and I get the same message: 'linux_sgio' has no attribute 'open'

I found that problem is missing "dot" in linux_sgio/__init__.py in line

from .linux_sgio import *

Code on github doesn't have this dot but code from LINUX_SGIO-1.0.tar.gz have dot.

Maybe it worked in Python 2 without dot but Python 3 needs this dot.

You can add this dot manually before running setup.py or using sed

git clone https://github.com/rosjat/python-scsi
cd python-scsi

sed -i 's/ linux_sgio/ .linux_sgio/' linux_sgio/__init__.py

python3 setup.py build
python3 setup.py install 

Finnaly I have script which

#!/bin/bash

# create venv

python3 -m venv ./glucometerutils-venv
cd glucometerutils-venv
. bin/activate

# install pyscsi and linux_sgio

git clone https://github.com/rosjat/python-scsi
cd python-scsi
sed -i 's/ linux_sgio/ .linux_sgio/' linux_sgio/__init__.py
python3 setup.py build
python3 setup.py install
cd ..

# install other modules

# `construct` needs `wheel`
pip install attrs wheel construct

# download glucometerutils

git clone git://github.com/Flameeyes/glucometerutils.git
cd glucometerutils
python3 setup.py build
python3 setup.py install

# and run it

sudo chmod o+rw /dev/sdc
./glucometer.py --driver otverio2015 --device /dev/sdc info

By the way: I found device name /dev/sdc using lsscsi - see LifeScan

$ apt install lsscsi
$ lsscsi

[0:0:0:0]    disk    ATA      ADATA SU800      1A    /dev/sda
[4:0:0:0]    cd/dvd  TSSTcorp CDDVDW TS-L633C  AC01  /dev/sr0
[5:0:0:0]    disk    ASMT     2115             0     /dev/sdb
[6:0:0:0]    disk    LifeScan                        /dev/sdc

but using

$ ls -l -d --sort time /dev/s*

and looking for device with the newest date and time I see device may have two names at the same time - ie. /dev/sdc and /dev/sg3 (first is "block device" and second is "character device" but both work for me the same way)

brw-rw----  1 root disk   8,  32 Feb 14 19:11 /dev/sdc
crw-rw----  1 root disk  21,   3 Feb 14 19:11 /dev/sg3

furas avatar Feb 14 '19 21:02 furas

Thanks furas, script above worked perfectly for me. Block device as identified by lsscsi is the way to go.

pycoder-adc avatar Feb 17 '19 00:02 pycoder-adc