hmijail / customsw-UNI-T-UT81B

Custom software for multimeters UNI-T UT81B
GNU General Public License v3.0
1 stars 1 forks source link

Python TypeError: returned a generator instead of a list #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

Not sure what I'm doing wrong here. I can probably fix it but I figured I should probably leave a bug report.


Python 2.7.14 (default, Sep 16 2017, 17:49:51)
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/mnt/data/egyetem2/6felev/labs/env/customsw-UNI-T-UT81B/mm.py in <module>()
    577
    578 if __name__ == "__main__":
--> 579         identify_multimeters()

/mnt/data/egyetem2/6felev/labs/env/customsw-UNI-T-UT81B/mm.py in identify_multimeters()
    485                 }
    486         bs=usb.busses()
--> 487         print len(bs), " busses found"
    488
    489         for b in bs:

TypeError: object of type 'generator' has no len()```
ghost commented 6 years ago

Actually I'm running into so many errors I'm surprised this is supposed to run at all. :(

I'm trying to write a python3 port using hidapi now, it might be simpler and not need messing with drivers, I'm not sure though.

hmijail commented 6 years ago

I'm sorry that it didn't work for you, but (FWIW) I can say it did work beautifully for me - about 5-6 years ago, on Windows XP. So, worlds ago.

The len(bs) error you report is a clear sign that things have changed in the module. Unfortunately I see now that I didn't even take note of the exact python module I used; given the release dates of libusb1 it probably was a pre-1.0.0 version, and given its changelog there were big reworkings going on by then. (I'm assuming it was libusb1 ;P)

Anyway, I'd say that the value of this project is mostly in the protocol decoding, and secondarily on how to drive the native libusb through Python. If you fix the language errors, the value should still be there.

No idea about hidapi; sounds like it will totally substitute the libusb1 role, so of course you will have to introduce more changes. Maybe then it will be useful for you to check directly the sketchy official protocol docs, as mentioned in https://hmijailblog.blogspot.com/2011/12/custom-software-for-interfacing-via-usb.html?showComment=1412671872601#c3144263078800538924 .

Then again, note that those official docs are incomplete. As mentioned there, this project does fix problems not mentioned in those docs.

hmijail commented 6 years ago

After rechecking the blog post where I introduced this project, turns out that this was done around 2010, and the first release of the Python module in Github is 0.2.1 from 2012. So I had to use some version previous to that.

So... yeah, surely it has changed since then.

Luckily, in 2014 a commenter in my blog reworked the code and reported to have it working. I'd start there, he even has his own GitHub repo: http://www.lowlevel.cz/log/cats/hardware/Python%20software%20for%20scopemeter%20UT81B.html

I'll be updating the project's readme to redirect people to that code.

Thank you for reporting, and good luck!

ghost commented 6 years ago

Ah, I see! I should have read the comments. :)

Thanks a bunch.