You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
|
2008 |
Jan
(1) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(8) |
Jun
(4) |
Jul
|
Aug
|
Sep
(11) |
Oct
|
Nov
|
Dec
(20) |
2009 |
Jan
(16) |
Feb
(7) |
Mar
(9) |
Apr
(4) |
May
(6) |
Jun
(17) |
Jul
(3) |
Aug
(4) |
Sep
(5) |
Oct
(10) |
Nov
(16) |
Dec
|
2010 |
Jan
(22) |
Feb
(18) |
Mar
(9) |
Apr
(102) |
May
(29) |
Jun
(40) |
Jul
(80) |
Aug
(21) |
Sep
(47) |
Oct
(13) |
Nov
(19) |
Dec
(45) |
2011 |
Jan
(82) |
Feb
(20) |
Mar
(47) |
Apr
(25) |
May
(18) |
Jun
(24) |
Jul
(24) |
Aug
(47) |
Sep
(23) |
Oct
(22) |
Nov
(69) |
Dec
(20) |
2012 |
Jan
(56) |
Feb
(42) |
Mar
(43) |
Apr
(27) |
May
(18) |
Jun
(11) |
Jul
(61) |
Aug
(19) |
Sep
(13) |
Oct
(49) |
Nov
(32) |
Dec
(37) |
2013 |
Jan
(46) |
Feb
(14) |
Mar
(13) |
Apr
(20) |
May
(20) |
Jun
(3) |
Jul
(19) |
Aug
(7) |
Sep
(4) |
Oct
(33) |
Nov
(7) |
Dec
(15) |
2014 |
Jan
(5) |
Feb
(21) |
Mar
(3) |
Apr
(3) |
May
(30) |
Jun
(1) |
Jul
(30) |
Aug
(2) |
Sep
(22) |
Oct
(14) |
Nov
(22) |
Dec
(6) |
2015 |
Jan
(7) |
Feb
(4) |
Mar
(16) |
Apr
(9) |
May
(17) |
Jun
(28) |
Jul
(3) |
Aug
(18) |
Sep
(3) |
Oct
|
Nov
(6) |
Dec
(3) |
2016 |
Jan
(15) |
Feb
(18) |
Mar
(12) |
Apr
(14) |
May
(15) |
Jun
(3) |
Jul
(3) |
Aug
(42) |
Sep
(24) |
Oct
(6) |
Nov
(5) |
Dec
(6) |
2017 |
Jan
(6) |
Feb
(2) |
Mar
(12) |
Apr
|
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(5) |
Dec
(7) |
2018 |
Jan
|
Feb
(9) |
Mar
(7) |
Apr
|
May
(10) |
Jun
(20) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(9) |
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
(8) |
Dec
(2) |
2021 |
Jan
(16) |
Feb
(1) |
Mar
|
Apr
(9) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2022 |
Jan
|
Feb
(7) |
Mar
|
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Wander L. C. <wan...@gm...> - 2015-03-29 16:47:12
|
2015-03-29 12:42 GMT-03:00 Kyle Dotter <kd...@lt...>: > Currently I have a program that takes the serial number from an android > phone automatically and saves it to a certain list. However, I don't want > this process to be automated. There's an android app being written to go > with this program and we want there to be a button that the user has to > press in order for it to continue with the program. I'm confused about how > I am actually receiving messages from the phone, however. I've looked at the > tutorial and I'm wondering if it'd be as easy as just having a read command? > Something like > > message = <read device USB> > if message = <whatever I'm expecting, defined by the app> > <continue if good, keep waiting and checking if not> > > Is this doable? I'm not the best with python and this usb communication Hi, If you are talking about the USB serial number, the device object has a property called 'serial_number' that returns what you want. > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, > sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for > all > things parallel software development, from weekly thought leadership blogs > to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > -- Best Regards, Wander Lairson Costa |
From: Kyle D. <kd...@lt...> - 2015-03-29 16:13:27
|
Currently I have a program that takes the serial number from an android phone automatically and saves it to a certain list. However, I don't want this process to be automated. There's an android app being written to go with this program and we want there to be a button that the user has to press in order for it to continue with the program. I'm confused about how I am actually receiving messages from the phone, however. I've looked at the tutorial and I'm wondering if it'd be as easy as just having a read command? Something like message = <read device USB> if message = <whatever I'm expecting, defined by the app> <continue if good, keep waiting and checking if not> Is this doable? I'm not the best with python and this usb communication |
From: Michel A. <mic...@vi...> - 2015-03-18 23:11:53
|
Hi I had a simple answer for Kevin Bullman sudo python3 setup.py install I am a retired engineer so I have time to learn. So I am learning Raspberry Pi, Python and Linux. On top of that I can surely learn Pip My best regards Michel Allaire -----Message d'origine----- De : Steven Michalske [mailto:smi...@gm...] Envoyé : 18 mars 2015 15:45 À : pyu...@li... Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi I strongly suggest you read up on pip and also you may want to look into virtualenv Steve > On Mar 18, 2015, at 12:37 PM, Michel Allaire <mic...@vi...> wrote: > > Thank you > > I have installed pyusb with the following command as shown in the readme file of pyusb: > > sudo python setup.py install > > I am not familiar with the pip concept. > > Regards > > Michel > > > > > -----Message d'origine----- > De : Jim Easterbrook [mailto:ji...@ji...] > Envoyé : 18 mars 2015 08:42 > À : pyu...@li... > Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi > >> On 18/03/15 12:18, Michel Allaire wrote: >> >> I want to use pyusb in a Raspberry pi which come with two >> installations of Python: 2.x and 3.x. >> >> The problem is that pyusb installs in a way that it is only working >> in version 2.X and not in version 3.x in which I have the following >> error message cd pi > >> >> Is there a way to change the behavior of pyusb installer. > > How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' > -- > Jim Easterbrook <http://www.jim-easterbrook.me.uk/> > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ pyusb-users mailing list pyu...@li... https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Michel A. <mic...@vi...> - 2015-03-18 23:09:07
|
Merci beaucoup. It was so simple. I am a retired engineer so I have time to learn. So I am learning Raspberry Pi, Python and Linux. On top of that I can surely learn Pip My best regards Michel Allaire -----Message d'origine----- De : Kevin Bullmann [mailto:ke...@kb...] Envoyé : 18 mars 2015 16:30 À : pyu...@li... Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi Hi, Well if you want pyusb to be available in python3 you can just change your command to: sudo python3 setup.py install Using pip is the better solution though. Pip is a package manager for python and can download packages for you and can also do some dependency resolution. Parallel installations of python2 and python3 are actually the standard in most linux distributions. Since python2 was considered the default all commands related to python3 have the "3" attached to them. This is also true for pip so that pip is the installation command for python2 and pip3 is the command for python3. have fun Kevin On 18.03.2015 20:37, Michel Allaire wrote: > Thank you > > I have installed pyusb with the following command as shown in the readme file of pyusb: > > sudo python setup.py install > > I am not familiar with the pip concept. > > Regards > > Michel > > > > > -----Message d'origine----- > De : Jim Easterbrook [mailto:ji...@ji...] > Envoyé : 18 mars 2015 08:42 > À : pyu...@li... > Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi > > On 18/03/15 12:18, Michel Allaire wrote: >> I want to use pyusb in a Raspberry pi which come with two >> installations of Python: 2.x and 3.x. >> >> The problem is that pyusb installs in a way that it is only working >> in version 2.X and not in version 3.x in which I have the following >> error message cd pi Is there a way to change the behavior of pyusb >> installer. > How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ pyusb-users mailing list pyu...@li... https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Kevin B. <ke...@kb...> - 2015-03-18 20:42:54
|
Hi, Well if you want pyusb to be available in python3 you can just change your command to: sudo python3 setup.py install Using pip is the better solution though. Pip is a package manager for python and can download packages for you and can also do some dependency resolution. Parallel installations of python2 and python3 are actually the standard in most linux distributions. Since python2 was considered the default all commands related to python3 have the "3" attached to them. This is also true for pip so that pip is the installation command for python2 and pip3 is the command for python3. have fun Kevin On 18.03.2015 20:37, Michel Allaire wrote: > Thank you > > I have installed pyusb with the following command as shown in the readme file of pyusb: > > sudo python setup.py install > > I am not familiar with the pip concept. > > Regards > > Michel > > > > > -----Message d'origine----- > De : Jim Easterbrook [mailto:ji...@ji...] > Envoyé : 18 mars 2015 08:42 > À : pyu...@li... > Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi > > On 18/03/15 12:18, Michel Allaire wrote: >> I want to use pyusb in a Raspberry pi which come with two >> installations of Python: 2.x and 3.x. >> >> The problem is that pyusb installs in a way that it is only working >> in version 2.X and not in version 3.x in which I have the following >> error message >> cd pi >> Is there a way to change the behavior of pyusb installer. > How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' |
From: Steven M. <smi...@gm...> - 2015-03-18 19:44:49
|
I strongly suggest you read up on pip and also you may want to look into virtualenv Steve > On Mar 18, 2015, at 12:37 PM, Michel Allaire <mic...@vi...> wrote: > > Thank you > > I have installed pyusb with the following command as shown in the readme file of pyusb: > > sudo python setup.py install > > I am not familiar with the pip concept. > > Regards > > Michel > > > > > -----Message d'origine----- > De : Jim Easterbrook [mailto:ji...@ji...] > Envoyé : 18 mars 2015 08:42 > À : pyu...@li... > Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi > >> On 18/03/15 12:18, Michel Allaire wrote: >> >> I want to use pyusb in a Raspberry pi which come with two >> installations of Python: 2.x and 3.x. >> >> The problem is that pyusb installs in a way that it is only working >> in version 2.X and not in version 3.x in which I have the following >> error message >> cd pi > >> >> Is there a way to change the behavior of pyusb installer. > > How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' > -- > Jim Easterbrook <http://www.jim-easterbrook.me.uk/> > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Michel A. <mic...@vi...> - 2015-03-18 19:37:21
|
Thank you I have installed pyusb with the following command as shown in the readme file of pyusb: sudo python setup.py install I am not familiar with the pip concept. Regards Michel -----Message d'origine----- De : Jim Easterbrook [mailto:ji...@ji...] Envoyé : 18 mars 2015 08:42 À : pyu...@li... Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi On 18/03/15 12:18, Michel Allaire wrote: > > I want to use pyusb in a Raspberry pi which come with two > installations of Python: 2.x and 3.x. > > The problem is that pyusb installs in a way that it is only working > in version 2.X and not in version 3.x in which I have the following > error message > cd pi > > Is there a way to change the behavior of pyusb installer. How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' -- Jim Easterbrook <http://www.jim-easterbrook.me.uk/> ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ pyusb-users mailing list pyu...@li... https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Jim E. <ji...@ji...> - 2015-03-18 12:42:27
|
On 18/03/15 12:18, Michel Allaire wrote: > > I want to use pyusb in a Raspberry pi which come with two installations > of Python: 2.x and 3.x. > > The problem is that pyusb installs in a way that it is only working in > version 2.X and not in version 3.x in which I have the following error > message > > “No module named core”. > > Is there a way to change the behavior of pyusb installer. How are you installing pyusb? If you use pip to install from PyPI you just need to run the python3 version of pip: 'sudo pip3 install pyusb' -- Jim Easterbrook <http://www.jim-easterbrook.me.uk/> |
From: Michel A. <mic...@vi...> - 2015-03-18 12:18:28
|
Hi, I want to use pyusb in a Raspberry pi which come with two installations of Python: 2.x and 3.x. The problem is that pyusb installs in a way that it is only working in version 2.X and not in version 3.x in which I have the following error message "No module named core". Is there a way to change the behavior of pyusb installer. Or, if there is no registration process involved in this installation is it sufficient to simply copy the pyusb files in the Python 3.x directory? Thank you Michel Allaire |
From: Michel A. <mic...@vi...> - 2015-03-04 02:22:07
|
Thank you very much and my best regards Michel Allaire -----Message d'origine----- De : Xiaofan Chen [mailto:xia...@gm...] Envoyé : 2 mars 2015 20:20 À : pyu...@li... Objet : Re: [pyusb-users] No backend available with windows 7 On Tue, Mar 3, 2015 at 2:40 AM, Michel Allaire <mic...@vi...> wrote: > But it seems that I can't access the list devices on the bus with the > following script: > > import usb.core > import usb.util > > list_dev = usb.core.find(find_all=True) n = 0 for dev in list_dev: > n = n+1 > print (n, " " , dev) > > > Could it be because I did not specified any filter or .INF file since > I want to scan the bus myself to connect to microcontrollers in a > arbitrary number and USB ready Yes. If you use libusb-win32 under Windows, you have to have one supported device with libusb0.sys driver. If you use libusb-1.0 backend (libusb Windows backend), then you do not need to have a device with a supported driver (eg WinUSB) to find the device, but then you need to have such a device if you want to do more than that (read/write endpoint, etc). > Will this behavior also exists on my target operating system with will > be Linux running on à Raspberry PI. No. Linux is different since libusb uses usbfs under Linux (you do need to detach non-usbfs driver first). -- Xiaofan ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ pyusb-users mailing list pyu...@li... https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Xiaofan C. <xia...@gm...> - 2015-03-03 01:20:13
|
On Tue, Mar 3, 2015 at 2:40 AM, Michel Allaire <mic...@vi...> wrote: > But it seems that I can't access the list devices on the bus with the > following script: > > import usb.core > import usb.util > > list_dev = usb.core.find(find_all=True) > n = 0 > for dev in list_dev: > n = n+1 > print (n, " " , dev) > > > Could it be because I did not specified any filter or .INF file since I want > to scan the bus myself to connect to microcontrollers in a arbitrary number > and USB ready Yes. If you use libusb-win32 under Windows, you have to have one supported device with libusb0.sys driver. If you use libusb-1.0 backend (libusb Windows backend), then you do not need to have a device with a supported driver (eg WinUSB) to find the device, but then you need to have such a device if you want to do more than that (read/write endpoint, etc). > Will this behavior also exists on my target operating system with will be > Linux running on à Raspberry PI. No. Linux is different since libusb uses usbfs under Linux (you do need to detach non-usbfs driver first). -- Xiaofan |
From: Michel A. <mic...@vi...> - 2015-03-02 18:40:25
|
Thank you for your fast response. Before receiving your response, I had tried this: I was working initially with Python 3.4.3 so I uninstalled it and installed version 2.7.9. Then the "No backend available" error disappeared. I uninstalled Python 2.27.9 and came back to Python 3.4.3 and still no error. Puzzling! But it seems that I can't access the list devices on the bus with the following script: import usb.core import usb.util list_dev = usb.core.find(find_all=True) n = 0 for dev in list_dev: n = n+1 print (n, " " , dev) Could it be because I did not specified any filter or .INF file since I want to scan the bus myself to connect to microcontrollers in a arbitrary number and USB ready Will this behavior also exists on my target operating system with will be Linux running on à Raspberry PI. Best regards Michel Allaire -----Message d'origine----- De : Xiaofan Chen [mailto:xia...@gm...] Envoyé : 2 mars 2015 08:06 À : pyu...@li... Objet : Re: [pyusb-users] No backend available with windows 7 On Mon, Mar 2, 2015 at 1:06 PM, Michel Allaire <mic...@vi...> wrote: > 2015-02-27 22:41:37,979 ERROR:usb.libloader:Libusb 0 > (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded You probably want to delete this file and try again. C:\WinAVR-20100110\bin\libusb0.dll -- Xiaofan ---------------------------------------------------------------------------- -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ pyusb-users mailing list pyu...@li... https://lists.sourceforge.net/lists/listinfo/pyusb-users |
From: Xiaofan C. <xia...@gm...> - 2015-03-02 13:05:37
|
On Mon, Mar 2, 2015 at 1:06 PM, Michel Allaire <mic...@vi...> wrote: > 2015-02-27 22:41:37,979 ERROR:usb.libloader:Libusb 0 > (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded You probably want to delete this file and try again. C:\WinAVR-20100110\bin\libusb0.dll -- Xiaofan |
From: Guillaume S. <Gui...@po...> - 2015-03-02 09:16:48
|
I am out of the office until 04.03.2015. I'll respond to your email when I return. Best regards, Guillaume Note: This is an automated response to your message "[pyusb-users] No backend available with windows 7" sent on 02.03.2015 06:06:05. This is the only notification you will receive while this person is away. |
From: Michel A. <mic...@vi...> - 2015-03-02 05:06:11
|
Hi, In my current project I must communicate through the USB bus with several micro controllers which are USB ready. I want to do this in Python running on Windows 7-64bits. PyUSB 1.0.0b2 is installed as well as libusb-win32 ( libusb-win32-devel-filter-1.2.6.0.exe was used without adding a filter for a particular device) The file libusb0.dll is present in C:\Windows\System32\ and the file libusb0.sys is present in C:\Windows\System32\drivers\. My test script is the following import os os.environ['PYUSB_DEBUG']='debug' os.environ['PYUSB_LOG_FILENAME']="D:\LOG_ERR_TEST.txt" import usb.core import usb.util dev = usb.core.find(find_all = True) And it produces the following error: Traceback (most recent call last): File "C:\Python34\Test PYUSB.py", line 13, in <module> dev = usb.core.find(find_all = True) File "C:\Python34\usb\core.py", line 1219, in find raise ValueError('No backend available') ValueError: No backend available The error log file goes like this: 2015-02-27 22:22:24,995 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:22:24,996 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:22:25,000 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:22:25,001 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:22:25,012 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-27 22:22:25,013 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-27 22:25:16,570 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:25:16,571 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:25:16,575 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:25:16,576 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:25:16,586 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-27 22:25:16,588 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-27 22:35:31,821 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:35:31,822 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:35:31,827 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:35:31,827 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:35:31,838 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-27 22:35:31,840 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-27 22:40:53,266 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:40:53,267 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:40:53,272 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:40:53,272 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:40:53,282 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide 2015-02-27 22:40:53,284 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-27 22:41:37,963 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:41:37,964 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:41:37,969 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:41:37,969 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:41:37,979 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-27 22:41:37,981 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-27 22:42:38,367 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-27 22:42:38,368 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-27 22:42:38,372 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-27 22:42:38,373 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-27 22:42:38,383 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide 2015-02-27 22:42:38,384 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-28 12:23:20,858 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-28 12:23:20,858 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-28 12:23:20,858 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-28 12:23:20,858 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-28 12:23:20,858 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-28 12:23:20,878 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend 2015-02-28 16:51:36,357 ERROR:usb.libloader:'Libusb 1' could not be found 2015-02-28 16:51:36,367 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend 2015-02-28 16:51:36,367 ERROR:usb.libloader:'OpenUSB library' could not be found 2015-02-28 16:51:36,367 ERROR:usb.backend.openusb:Error loading OpenUSB backend 2015-02-28 16:51:36,367 ERROR:usb.libloader:Libusb 0 (C:\WinAVR-20100110\bin\libusb0.dll) could not be loaded Traceback (most recent call last): File "C:\Python34\usb\libloader.py", line 116, in load_library return ctypes.CDLL(lib) File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 n'est pas une application Win32 valide (in English : "not a valid Win32 application") 2015-02-28 16:51:36,367 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend Can you help me solve this problem? Thanking you in advance Michel Allaire |
From: Xiaofan C. <xia...@gm...> - 2015-02-12 01:43:17
|
On Thu, Feb 12, 2015 at 6:55 AM, Sean Kitko <se...@gm...> wrote: > However, I'm running into some problems implementing the test script > provided at the tutorial here: > > https://github.com/walac/pyusb/blob/master/docs/tutorial.rst > > I brought the test script into an editor, and changed the vendor and product > id, as well as the test string sent (I changed 'test' to 'V L', which will > light an LED on my development board). > > When I run the script via powershell (Windows 7 64bit), Firstly, did you install a supported driver and supported backend for your device under Windows? (either using libusb-win32 with libusb-win32 device driver or using libusb Windows backend with WinUSB driver). The recommendation is to use Zadig to install the device driver. If you use libusb Windows backend, then you also need the correct libusb-1.0.dll (32bit or 64bit depending on your Python installation) from libusb project. > I get the following traceback error: > > PS C:\...\PyUSB Dev> python simpletestscript.py > Traceback (most recent call last): > File "simpletestscript.py", line 27, in <module> > assert ep is not None > AssertionError > PS C:\...\PyUSB Dev> > > I don't understand enough about the library to really understand why I would > be receiving that error. Does your device have an OUT Endpoint? You can use USBview to dump the USB descriptor and post the result here. USBView: http://www.ftdichip.com/Support/Utilities.htm -- Xiaofan |
From: Sean K. <se...@gm...> - 2015-02-11 22:55:38
|
Hi all, I apologize for my last email, I accidentally sent it without finishing. I am currently trying to use PyUSB to interface with microcontroller in order to automate some functionality. There is firmware written and working for the micro. However, I'm running into some problems implementing the test script provided at the tutorial here: https://github.com/walac/pyusb/blob/master/docs/tutorial.rst I brought the test script into an editor, and changed the vendor and product id, as well as the test string sent (I changed 'test' to 'V L', which will light an LED on my development board). When I run the script via powershell (Windows 7 64bit), I get the following traceback error: PS C:\...\PyUSB Dev> python simpletestscript.py Traceback (most recent call last): File "simpletestscript.py", line 27, in <module> assert ep is not None AssertionError PS C:\...\PyUSB Dev> I don't understand enough about the library to really understand why I would be receiving that error. If anyone has any idea what might be causing the issue, or a direction to point me in, I would greatly appreciate the help. Thanks. -Sean |
From: Sean K. <se...@gm...> - 2015-02-11 22:52:48
|
Hi all, I am currently trying to use PyUSB to interface with microcontroller in order to automate some functionality. There is firmware written and working for the micro. However, I'm running into some problems implementing the test script provided at the tutorial here: https://github.com/walac/pyusb/blob/master/docs/tutorial.rst I brought the test script into an editor, and changed the vendor and product id, as well as the test string sent (I changed 'test' to 'V L', which will light an LED on my development board). When I run the script via powershell (Windows 7 64bit), I get the following traceback error: PS C:\...\PyUSB Dev> python simpletestscript.py Traceback (most recent call last): |
From: Wander L. C. <wan...@gm...> - 2015-02-01 11:01:31
|
Hey Gerry, I think I found the problem. In your Python configuration, you set_configuration and then reset the device. Besides the fact the device looses the configuration information, this will cause a reenumeration, and the device driver will be attached again. Try to comment the dev.reset line and report the results, please. 2015-01-20 9:24 GMT-02:00 Gerry <gb...@ge...>: > Sorry for the late reply but I had sent this to the pyusb-users-owner > list instead of this list. I had originally included the files as > attachments but the list stripped them off so now I am including them in > this email. > > Hopefully someone can find a solution to this problem. > > > -------- Forwarded Message -------- Subject: My Python source code and > another's C code Date: Wed, 14 Jan 2015 19:09:35 +0800 From: Gerry > <gb...@ge...> <gb...@ge...> To: > pyu...@li... > > Here is my Python code: > > "#!/usr/bin/python > """ > Read a MagTek USB HID Swipe Reader in Linux. A description of this > code can be found at: > http://www.micahcarrick.com/credit-card-reader-pyusb.html > > You must be using the new PyUSB 1.0 branch and not the 0.x branch. > > Copyright (c) 2010 - Micah Carrick > """ > import sys > import usb.core > #import usb.backend.libusb1 as libusb1 > import usb.util > > VENDOR_ID = 0x24c0 > PRODUCT_ID = 0x0003 > DATA_SIZE = 50 > > # find the Acurite Weather Station > > device = usb.core.find(idVendor=0x24c0, idProduct=0x0003) > > if device is None: > sys.exit("Could not find Acurite weatherstation.") > #else: > # print("Device FOUND!!", device) > # fout = open('device.txt', 'w') > # d1 = str(device) > # fout.write(d1) > # fout.close > > # make sure the hiddev kernel driver is not active > > if device.is_kernel_driver_active(0): > try: > device.detach_kernel_driver(0) > except usb.core.USBError as e: > sys.exit("Could not detatch kernel driver: %s" % str(e)) > > # set configuration > > try: > device.set_configuration() > device.reset() > except usb.core.USBError as e: > sys.exit("Could not set configuration: %s" % str(e)) > > endpoint = device[0][(0,0)][0] > > #print ("Endpoint = ", endpoint) > #epa = endpoint.bEndpointAddress > #mps = endpoint.wMaxPacketSize > #print ("EPA = ", epa, "MPS= ", mps) > > > data = [] > print ("Now starting to read...") > *This is where I am getting the errors. I originally had it as "d1 = > device.read(..." but after looking at the Pyusb.core code it said it should > be "d1 = read(device..." Both ways give the same errors. Hopefully you can > find the problem so I can read my weather station...* > d1 = read(device, endpoint.bEndpointAddress, endpoint.wMaxPacketSize) > print ("D1 =",d1) > > '''while 1: > try: > #data += device.read(endpoint.bEndpointAddress, > endpoint.wMaxPacketSize) > #print("Data = ",data) > data += device.read(0x81, 8) > print ("Reading...") > except usb.core.USBError as e: > if e.args == ('Operation timed out',): #and swiped: > if len(data) < DATA_SIZE: > print ("Bad swipe, try again. (%d bytes)") % len(data) > print ("Data: %s" % ''.join(map(chr, data))) > data = [] > continue > else: > print ("Data = ",data) > break # we got it! > ''' > > The other person's C code: > > "/* > Documentation at desert-home.com > > Experimentation with a USB interface to the Acu-Rite 5 in 1 > Weatherstation > specifically for the Raspberry Pi. The code may work on other > systems, but I > don't have one of those. Contrary to other folk's thinking, I don't > care if > this ever runs on a Windows PC or an Apple anything. > > I specifically used a model 2032 display with the sensor that I picked > up at one of those warehouse stores. The display has a usb plug on it > and > I thought it might be possible to read the usb port and massage the > data myself. > > This code represents the result of that effort. > > I gathered ideas from all over the web. I use the latest (for this > second) > libusb and about a thousand examples of various things that other > people have > done and posted about. Frankly, I simply can't remember all of them, > so please, > don't be offended if you see your ideas somewhere in here and it isn't > attributed. > > I simply lost track of where I found what. > > This module relies on libusb version 1.0.19 which, at this time, can > only be > compiled from source on the raspberry pi. > > Because there likely to be a version of libusb and the associated > header file > on a Pi, use the command line below to build it since the build of > libusb-1.0.19 > places things in /usr/local > > cc -o weatherstation weatherstation.c -L/usr/local/lib -lusb-1.0 > * > use ldd weatherstation to check which libraries are linked in. > If you still have trouble with compilation, remember that cc has a -v > parameter that can help you unwind what is happening. > */ > > #include <stdio.h> > #include <stdlib.h> > #include <signal.h> > #include <time.h> > #include <unistd.h> > #include <sys/time.h> > #include <libusb-1.0/libusb.h> > > // The vendor id and product number for the AcuRite 5 in 1 weather head. > #define VENDOR 0x24c0 > #define PRODUCT 0x0003 > > // I store things about the weather device USB connection here. > struct { > libusb_device *device; > libusb_device_handle *handle; > int verbose; > } weatherStation; > // These are the sensors the the 5 in 1 weather head provides > struct { > float windSpeed; > time_t wsTime; > int windDirection; > time_t wdTime; > float temperature; > time_t tTime; > int humidity; > time_t hTime; > int rainCounter; > time_t rcTime; > } weatherData; > > // This is just a function prototype for the compiler > void closeUpAndLeave(); > > // I want to catch control-C and close down gracefully > void sig_handler(int signo) > { > if (signo == SIGINT) > fprintf(stderr,"Shutting down ...\n"); > closeUpAndLeave(); > } > > /* > This tiny thing simply takes the data and prints it so we can see it > */ > // Array to translate the integer direction provided to text > > char *Direction[] = { > "NNW", > "NW ", > "WNW", > "W ", > "WSW", > "SW ", > "SSW", > "S ", > "SSE", > "SE ", > "ESE", > "E ", > "ENE", > "NE ", > "NNE", > "N " }; > > void showit(){ > > fprintf(stdout, "{\"windSpeed\":{\"WS\":\"%.1f\",\"t\":\"%d\"}," > "\"windDirection\":{\"WD\":\"%s\",\"t\":\"%d\"}," > "\"temperature\":{\"T\":\"%.1f\",\"t\":\"%d\"}," > "\"humidity\":{\"H\":\"%d\",\"t\":\"%d\"}," > "\"rainCounter\":{\"RC\":\"%d\",\"t\":\"%d\"}}\n", > weatherData.windSpeed, weatherData.wsTime, > Direction[weatherData.windDirection],weatherData.wdTime, > weatherData.temperature, weatherData.tTime, > weatherData.humidity, weatherData.hTime, > weatherData.rainCounter, weatherData.rcTime); > fflush(stdout); > } > /* > This code translates the data from the 5 in 1 sensors to something > that can be used by a human. > */ > > float getWindSpeed(char *data){ > int leftSide = (data[3] & 0x1f) << 3; > int rightSide = data[4] & 0x70 >> 4; > // Yes, I use mph, never got used to kilometers. > return((float)(leftSide | rightSide) * 0.62); > } > int getWindDirection(char *data){ > return(data[4] & 0x0f); > } > float getTemp(char *data){ > // This item spans bytes, have to reconstruct it > int leftSide = (data[4] & 0x0f) << 7; > int rightSide = data[5] & 0x7f; > float combined = leftSide | rightSide; > return((combined - 400) / 10.0); > } > int getHumidity(char *data){ > int howWet = data[6] &0x7f; > return(howWet); > } > int getRainCount(char *data){ > int count = data[6] &0x7f; > return(count); > } > // Now that I have the data from the station, do something useful with it. > > void decode(char *data, int length, int noisy){ > //int i; > //for(i=0; i<length; i++){ > // fprintf(stderr,"%0.2X ",data[i]); > //} > //fprintf(stderr,"\n"); > > time_t seconds = time (NULL); > > //There are two varieties of data, both of them have wind speed > // first variety of the data > > if ((data[2] & 0x0f) == 1){ // this has wind speed, direction and > rainfall > if(noisy) > fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); > weatherData.windSpeed = getWindSpeed(data); > weatherData.wsTime = seconds; > if(noisy) > fprintf(stderr,"Wind Direction: %s > ",Direction[getWindDirection(data)]); > weatherData.wdTime = seconds; > weatherData.windDirection = getWindDirection(data); > if(noisy){ > fprintf(stderr,"Rain Counter: %d ",getRainCount(data)); > fprintf(stderr,"\n"); > } > weatherData.rainCounter = getRainCount(data); > weatherData.rcTime = seconds; > } > // this is the other variety > > if ((data[2] & 0x0f) == 8){ // this has wind speed, temp and relative > humidity > if(noisy) > fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); > weatherData.windSpeed = getWindSpeed(data); > weatherData.wsTime = seconds; > if(noisy) > fprintf(stderr,"Temperature: %.1f ",getTemp(data)); > weatherData.temperature = getTemp(data); > weatherData.tTime = seconds; > if(noisy){ > fprintf(stderr,"Humidity: %d ", getHumidity(data)); > fprintf(stderr,"\n"); > } > weatherData.humidity = getHumidity(data); > weatherData.hTime = seconds; > } > } > /* > This code is related to dealing with the USB device > */ > > // This searches the USB bus tree to find the device > > int findDevice(libusb_device **devs) > { > libusb_device *dev; > int err = 0, i = 0, j = 0; > uint8_t path[8]; > > while ((dev = devs[i++]) != NULL) { > struct libusb_device_descriptor desc; > int r = libusb_get_device_descriptor(dev, &desc); > if (r < 0) { > fprintf(stderr,"Couldn't get device descriptor, %s\n", > libusb_strerror(err)); > return(1); > } > > fprintf(stderr,"%04x:%04x (bus %d, device %d)", > desc.idVendor, desc.idProduct, > libusb_get_bus_number(dev), libusb_get_device_address(dev)); > > //r = libusb_get_port_numbers(dev, path, sizeof(path)); > //if (r > 0) { > // fprintf(stderr," path: %d", path[0]); > // for (j = 1; j < r; j++) > // fprintf(stderr,".%d", path[j]); > //} > //fprintf(stderr,"\n"); > > if (desc.idVendor == VENDOR && desc.idProduct == PRODUCT){ > fprintf(stderr,"Found the one I want\n"); > weatherStation.device = dev; > return (1); > } > } > return(0); > } > > // to handle testing and try to be clean about closing the USB device, > // I'll catch the signal and close off. > > void closeUpAndLeave(){ > //OK, done with it, close off and let it go. > fprintf(stderr,"Done with device, release and close it\n"); > int err = libusb_release_interface(weatherStation.handle, 0); > //release the claimed interface > if(err) { > fprintf(stderr,"Couldn't release interface, %s\n", > libusb_strerror(err)); > exit(1); > } > libusb_close(weatherStation.handle); > libusb_exit(NULL); > exit(0); > } > > // This is where I read the USB device to get the latest data. > unsigned char data[50]; // where we want the data to go > > int getit(int whichOne, int noisy){ > int actual; // how many bytes were actually read > > // The second parameter is bmRequestType and is a bitfield > // See http://www.beyondlogic.org/usbnutshell/usb6.shtml > > // for the definitions of the various bits. With libusb, the > // #defines for these are at: > // > http://libusb.sourceforge.net/api-1.0/group__misc.html#gga0b0933ae70744726cde11254c39fac91a20eca62c34d2d25be7e1776510184209 > > *This is where the data is being read from the device.* > actual = libusb_control_transfer(weatherStation.handle, > LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE > | LIBUSB_ENDPOINT_IN, > //These bytes were stolen with a USB sniffer > 0x01,0x0100+whichOne,0, > data, 50, 10000); > if (actual < 0){ > fprintf(stderr,"Read didn't work for report %d, %s\n", whichOne, > libusb_strerror(actual)); > } > else { > // If you want both of the reports that the station provides, > // just allow for it. Right this second, I've found every thing > // I need in report 1. When I look further at report 2, this will > // change > > /*fprintf(stderr,"R%d:%d:", whichOne, actual); > int i; > for(i=0; i<actual; i++){ > fprintf(stderr,"%0.2X ",data[i]); > } > fprintf(stderr,"\n"); */ > > if (whichOne == 1) > > // The actual data starts after the first byte > // The first byte is the report number returned by > // the usb read. > > decode(&data[1], actual-1, noisy); > } > } > // I do several things here that aren't strictly necessary. As I learned > about > // libusb, I tried things and also used various techniques to learn about > the > // weatherstation's implementation. I left a lot of it in here in case I > needed to > // use it later. Someone may find it useful to hack into some other > device. > > int main(int argc, char **argv) > { > char *usage = {"usage: %s -u -n\n"}; > int libusbDebug = 0; //This will turn on the DEBUG for libusb > int noisy = 0; //This will print the packets as they come in > libusb_device **devs; > int r, err, c; > ssize_t cnt; > > while ((c = getopt (argc, argv, "unh")) != -1) > switch (c){ > case 'u': > libusbDebug = 1; > break; > case 'n': > noisy = 1; > break; > case 'h': > fprintf(stderr, usage, argv[0]); > case '?': > exit(1); > default: > exit(1); > } > fprintf (stderr,"libusbDebug = %d, noisy = %d\n", libusbDebug, noisy); > > if (signal(SIGINT, sig_handler) == SIG_ERR) > fprintf(stderr,"Couldn't set up signal handler\n"); > err = libusb_init(NULL); > if (err < 0){ > fprintf(stderr,"Couldn't init usblib, %s\n", libusb_strerror(err)); > exit(1); > } > // This is where you can get debug output from libusb. > // just set it to LIBUSB_LOG_LEVEL_DEBUG > > if (libusbDebug) > libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG); > else > libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); > > > cnt = libusb_get_device_list(NULL, &devs); > if (cnt < 0){ > fprintf(stderr,"Couldn't get device list, %s\n", > libusb_strerror(err)); > exit(1); > } > // got get the device; the device handle is saved in weatherStation > struct. > if (!findDevice(devs)){ > fprintf(stderr,"Couldn't find the device\n"); > exit(1); > } > // Now I've found the weather station and can start to try stuff > // So, I'll get the device descriptor > > struct libusb_device_descriptor deviceDesc; > err = libusb_get_device_descriptor(weatherStation.device, &deviceDesc); > if (err){ > fprintf(stderr,"Couldn't get device descriptor, %s\n", > libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"Got the device descriptor back\n"); > > // Open the device and save the handle in the weatherStation struct > err = libusb_open(weatherStation.device, &weatherStation.handle); > if (err){ > fprintf(stderr,"Open failed, %s\n", libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"I was able to open it\n"); > > // There's a bug in either the usb library, the linux driver or the > // device itself. I suspect the usb driver, but don't know for sure. > // If you plug and unplug the weather station a few times, it will stop > // responding to reads. It also exhibits some strange behaviour to > // getting the configuration. I found out after a couple of days of > // experimenting that doing a clear-halt on the device while before it > // was opened it would clear the problem. So, I have one here and a > // little further down after it has been opened. > > fprintf(stderr,"trying clear halt on endpoint %X ... ", 0x81); > // err = libusb_clear_halt(weatherStation.handle, 0x81); > if (err){ > fprintf(stderr,"clear halt crapped, %s Bug Detector\n", > libusb_strerror(err));; > } > else { > fprintf(stderr,"OK\n"); > } > > // Now that it's opened, I can free the list of all devices > libusb_free_device_list(devs, 1); // Documentation says to get rid of > the list > // Once I have the device I need > fprintf(stderr,"Released the device list\n"); > > // Now I have to check to see if the kernal using udev has attached > // a driver to the device. If it has, it has to be detached so I can > // use the device. > > if(libusb_kernel_driver_active(weatherStation.handle, 0) == 1) { > //find out if kernel driver is attached > fprintf(stderr,"Kernal driver active\n"); > if(libusb_detach_kernel_driver(weatherStation.handle, 0) == 0) > //detach it > fprintf(stderr,"Kernel Driver Detached!\n"); > } > > int activeConfig; > err =libusb_get_configuration (weatherStation.handle, &activeConfig); > if (err){ > fprintf(stderr,"Can't get current active configuration, %s\n", > libusb_strerror(err));; > exit(1); > } > fprintf(stderr,"Currently active configuration is %d\n", activeConfig); > > if(activeConfig != 1){ > err = libusb_set_configuration (weatherStation.handle, 1); > if (err){ > fprintf(stderr,"Cannot set configuration, %s\n", > libusb_strerror(err));; > exit(1); > } > fprintf(stderr,"Just did the set configuration\n"); > } > > err = libusb_claim_interface(weatherStation.handle, 0); //claim > interface 0 (the first) of device (mine had jsut 1) > if(err) { > fprintf(stderr,"Cannot claim interface, %s\n", > libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"Claimed Interface\n"); > fprintf(stderr,"Number of configurations: > %d\n",deviceDesc.bNumConfigurations); > struct libusb_config_descriptor *config; > libusb_get_config_descriptor(weatherStation.device, 0, &config); > fprintf(stderr,"Number of Interfaces: > %d\n",(int)config->bNumInterfaces); > > // I know, the device only has one interface, but I wanted this code > // to serve as a reference for some future hack into some other device, > // so I put this loop to show the other interfaces that may > // be there. And, like most of this module, I stole the ideas from > // somewhere, but I can't remember where (I guess it's google overload) > > const struct libusb_interface *inter; > const struct libusb_interface_descriptor *interdesc; > const struct libusb_endpoint_descriptor *epdesc; > int i, j, k; > for(i=0; i<(int)config->bNumInterfaces; i++) { > inter = &config->interface[i]; > fprintf(stderr,"Number of alternate settings: %d\n", > inter->num_altsetting); > for(j=0; j < inter->num_altsetting; j++) { > interdesc = &inter->altsetting[j]; > fprintf(stderr,"Interface Number: %d\n", > (int)interdesc->bInterfaceNumber); > fprintf(stderr,"Number of endpoints: %d\n", > (int)interdesc->bNumEndpoints); > for(k=0; k < (int)interdesc->bNumEndpoints; k++) { > epdesc = &interdesc->endpoint[k]; > fprintf(stderr,"Descriptor Type: > %d\n",(int)epdesc->bDescriptorType); > fprintf(stderr,"Endpoint Address: > 0x%0.2X\n",(int)epdesc->bEndpointAddress); > // Below is how to tell which direction the > // endpoint is supposed to work. It's the high order bit > // in the endpoint address. I guess they wanted to hide > it. > fprintf(stderr," Direction is "); > if ((int)epdesc->bEndpointAddress & LIBUSB_ENDPOINT_IN != > 0) > fprintf(stderr," In (device to host)"); > else > fprintf(stderr," Out (host to device)"); > fprintf(stderr,"\n"); > } > } > } > fprintf(stderr,"trying clear halt on endpoint %X ... ", > (int)epdesc->bEndpointAddress); > // err = libusb_clear_halt(weatherStation.handle, > (int)epdesc->bEndpointAddress); > if (err){ > fprintf(stderr,"clear halt crapped, %s SHUCKS\n", > libusb_strerror(err));; > closeUpAndLeave(); > } > else { > fprintf(stderr,"OK\n"); > } > > // So, for the weather station we now know it has one endpoint and it > is set to > // send data to the host. Now we can experiment with that. > // > // I don't want to just hang up and read the reports as fast as I can, > so > // I'll space them out a bit. It's weather, and it doesn't change > very fast. > > int tickcounter= 0; > while(1){ > sleep(1); > if(tickcounter++ % 10 == 0){ > getit(1, noisy); > } > if(tickcounter % 30 == 0){ > getit(2, noisy); > } > if (tickcounter % 15 == 0){ > showit(); > } > } > }" > > > > > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > -- Best Regards, Wander Lairson Costa |
From: Wander L. C. <wan...@gm...> - 2015-01-28 17:34:39
|
Hi Gerry, I didn't forget you, but I didn't find free time yet to look deep at your code, sorry. 2015-01-20 9:24 GMT-02:00 Gerry <gb...@ge...>: > Sorry for the late reply but I had sent this to the pyusb-users-owner > list instead of this list. I had originally included the files as > attachments but the list stripped them off so now I am including them in > this email. > > Hopefully someone can find a solution to this problem. > > > -------- Forwarded Message -------- Subject: My Python source code and > another's C code Date: Wed, 14 Jan 2015 19:09:35 +0800 From: Gerry > <gb...@ge...> <gb...@ge...> To: > pyu...@li... > > Here is my Python code: > > "#!/usr/bin/python > """ > Read a MagTek USB HID Swipe Reader in Linux. A description of this > code can be found at: > http://www.micahcarrick.com/credit-card-reader-pyusb.html > > You must be using the new PyUSB 1.0 branch and not the 0.x branch. > > Copyright (c) 2010 - Micah Carrick > """ > import sys > import usb.core > #import usb.backend.libusb1 as libusb1 > import usb.util > > VENDOR_ID = 0x24c0 > PRODUCT_ID = 0x0003 > DATA_SIZE = 50 > > # find the Acurite Weather Station > > device = usb.core.find(idVendor=0x24c0, idProduct=0x0003) > > if device is None: > sys.exit("Could not find Acurite weatherstation.") > #else: > # print("Device FOUND!!", device) > # fout = open('device.txt', 'w') > # d1 = str(device) > # fout.write(d1) > # fout.close > > # make sure the hiddev kernel driver is not active > > if device.is_kernel_driver_active(0): > try: > device.detach_kernel_driver(0) > except usb.core.USBError as e: > sys.exit("Could not detatch kernel driver: %s" % str(e)) > > # set configuration > > try: > device.set_configuration() > device.reset() > except usb.core.USBError as e: > sys.exit("Could not set configuration: %s" % str(e)) > > endpoint = device[0][(0,0)][0] > > #print ("Endpoint = ", endpoint) > #epa = endpoint.bEndpointAddress > #mps = endpoint.wMaxPacketSize > #print ("EPA = ", epa, "MPS= ", mps) > > > data = [] > print ("Now starting to read...") > *This is where I am getting the errors. I originally had it as "d1 = > device.read(..." but after looking at the Pyusb.core code it said it should > be "d1 = read(device..." Both ways give the same errors. Hopefully you can > find the problem so I can read my weather station...* > d1 = read(device, endpoint.bEndpointAddress, endpoint.wMaxPacketSize) > print ("D1 =",d1) > > '''while 1: > try: > #data += device.read(endpoint.bEndpointAddress, > endpoint.wMaxPacketSize) > #print("Data = ",data) > data += device.read(0x81, 8) > print ("Reading...") > except usb.core.USBError as e: > if e.args == ('Operation timed out',): #and swiped: > if len(data) < DATA_SIZE: > print ("Bad swipe, try again. (%d bytes)") % len(data) > print ("Data: %s" % ''.join(map(chr, data))) > data = [] > continue > else: > print ("Data = ",data) > break # we got it! > ''' > > The other person's C code: > > "/* > Documentation at desert-home.com > > Experimentation with a USB interface to the Acu-Rite 5 in 1 > Weatherstation > specifically for the Raspberry Pi. The code may work on other > systems, but I > don't have one of those. Contrary to other folk's thinking, I don't > care if > this ever runs on a Windows PC or an Apple anything. > > I specifically used a model 2032 display with the sensor that I picked > up at one of those warehouse stores. The display has a usb plug on it > and > I thought it might be possible to read the usb port and massage the > data myself. > > This code represents the result of that effort. > > I gathered ideas from all over the web. I use the latest (for this > second) > libusb and about a thousand examples of various things that other > people have > done and posted about. Frankly, I simply can't remember all of them, > so please, > don't be offended if you see your ideas somewhere in here and it isn't > attributed. > > I simply lost track of where I found what. > > This module relies on libusb version 1.0.19 which, at this time, can > only be > compiled from source on the raspberry pi. > > Because there likely to be a version of libusb and the associated > header file > on a Pi, use the command line below to build it since the build of > libusb-1.0.19 > places things in /usr/local > > cc -o weatherstation weatherstation.c -L/usr/local/lib -lusb-1.0 > * > use ldd weatherstation to check which libraries are linked in. > If you still have trouble with compilation, remember that cc has a -v > parameter that can help you unwind what is happening. > */ > > #include <stdio.h> > #include <stdlib.h> > #include <signal.h> > #include <time.h> > #include <unistd.h> > #include <sys/time.h> > #include <libusb-1.0/libusb.h> > > // The vendor id and product number for the AcuRite 5 in 1 weather head. > #define VENDOR 0x24c0 > #define PRODUCT 0x0003 > > // I store things about the weather device USB connection here. > struct { > libusb_device *device; > libusb_device_handle *handle; > int verbose; > } weatherStation; > // These are the sensors the the 5 in 1 weather head provides > struct { > float windSpeed; > time_t wsTime; > int windDirection; > time_t wdTime; > float temperature; > time_t tTime; > int humidity; > time_t hTime; > int rainCounter; > time_t rcTime; > } weatherData; > > // This is just a function prototype for the compiler > void closeUpAndLeave(); > > // I want to catch control-C and close down gracefully > void sig_handler(int signo) > { > if (signo == SIGINT) > fprintf(stderr,"Shutting down ...\n"); > closeUpAndLeave(); > } > > /* > This tiny thing simply takes the data and prints it so we can see it > */ > // Array to translate the integer direction provided to text > > char *Direction[] = { > "NNW", > "NW ", > "WNW", > "W ", > "WSW", > "SW ", > "SSW", > "S ", > "SSE", > "SE ", > "ESE", > "E ", > "ENE", > "NE ", > "NNE", > "N " }; > > void showit(){ > > fprintf(stdout, "{\"windSpeed\":{\"WS\":\"%.1f\",\"t\":\"%d\"}," > "\"windDirection\":{\"WD\":\"%s\",\"t\":\"%d\"}," > "\"temperature\":{\"T\":\"%.1f\",\"t\":\"%d\"}," > "\"humidity\":{\"H\":\"%d\",\"t\":\"%d\"}," > "\"rainCounter\":{\"RC\":\"%d\",\"t\":\"%d\"}}\n", > weatherData.windSpeed, weatherData.wsTime, > Direction[weatherData.windDirection],weatherData.wdTime, > weatherData.temperature, weatherData.tTime, > weatherData.humidity, weatherData.hTime, > weatherData.rainCounter, weatherData.rcTime); > fflush(stdout); > } > /* > This code translates the data from the 5 in 1 sensors to something > that can be used by a human. > */ > > float getWindSpeed(char *data){ > int leftSide = (data[3] & 0x1f) << 3; > int rightSide = data[4] & 0x70 >> 4; > // Yes, I use mph, never got used to kilometers. > return((float)(leftSide | rightSide) * 0.62); > } > int getWindDirection(char *data){ > return(data[4] & 0x0f); > } > float getTemp(char *data){ > // This item spans bytes, have to reconstruct it > int leftSide = (data[4] & 0x0f) << 7; > int rightSide = data[5] & 0x7f; > float combined = leftSide | rightSide; > return((combined - 400) / 10.0); > } > int getHumidity(char *data){ > int howWet = data[6] &0x7f; > return(howWet); > } > int getRainCount(char *data){ > int count = data[6] &0x7f; > return(count); > } > // Now that I have the data from the station, do something useful with it. > > void decode(char *data, int length, int noisy){ > //int i; > //for(i=0; i<length; i++){ > // fprintf(stderr,"%0.2X ",data[i]); > //} > //fprintf(stderr,"\n"); > > time_t seconds = time (NULL); > > //There are two varieties of data, both of them have wind speed > // first variety of the data > > if ((data[2] & 0x0f) == 1){ // this has wind speed, direction and > rainfall > if(noisy) > fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); > weatherData.windSpeed = getWindSpeed(data); > weatherData.wsTime = seconds; > if(noisy) > fprintf(stderr,"Wind Direction: %s > ",Direction[getWindDirection(data)]); > weatherData.wdTime = seconds; > weatherData.windDirection = getWindDirection(data); > if(noisy){ > fprintf(stderr,"Rain Counter: %d ",getRainCount(data)); > fprintf(stderr,"\n"); > } > weatherData.rainCounter = getRainCount(data); > weatherData.rcTime = seconds; > } > // this is the other variety > > if ((data[2] & 0x0f) == 8){ // this has wind speed, temp and relative > humidity > if(noisy) > fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); > weatherData.windSpeed = getWindSpeed(data); > weatherData.wsTime = seconds; > if(noisy) > fprintf(stderr,"Temperature: %.1f ",getTemp(data)); > weatherData.temperature = getTemp(data); > weatherData.tTime = seconds; > if(noisy){ > fprintf(stderr,"Humidity: %d ", getHumidity(data)); > fprintf(stderr,"\n"); > } > weatherData.humidity = getHumidity(data); > weatherData.hTime = seconds; > } > } > /* > This code is related to dealing with the USB device > */ > > // This searches the USB bus tree to find the device > > int findDevice(libusb_device **devs) > { > libusb_device *dev; > int err = 0, i = 0, j = 0; > uint8_t path[8]; > > while ((dev = devs[i++]) != NULL) { > struct libusb_device_descriptor desc; > int r = libusb_get_device_descriptor(dev, &desc); > if (r < 0) { > fprintf(stderr,"Couldn't get device descriptor, %s\n", > libusb_strerror(err)); > return(1); > } > > fprintf(stderr,"%04x:%04x (bus %d, device %d)", > desc.idVendor, desc.idProduct, > libusb_get_bus_number(dev), libusb_get_device_address(dev)); > > //r = libusb_get_port_numbers(dev, path, sizeof(path)); > //if (r > 0) { > // fprintf(stderr," path: %d", path[0]); > // for (j = 1; j < r; j++) > // fprintf(stderr,".%d", path[j]); > //} > //fprintf(stderr,"\n"); > > if (desc.idVendor == VENDOR && desc.idProduct == PRODUCT){ > fprintf(stderr,"Found the one I want\n"); > weatherStation.device = dev; > return (1); > } > } > return(0); > } > > // to handle testing and try to be clean about closing the USB device, > // I'll catch the signal and close off. > > void closeUpAndLeave(){ > //OK, done with it, close off and let it go. > fprintf(stderr,"Done with device, release and close it\n"); > int err = libusb_release_interface(weatherStation.handle, 0); > //release the claimed interface > if(err) { > fprintf(stderr,"Couldn't release interface, %s\n", > libusb_strerror(err)); > exit(1); > } > libusb_close(weatherStation.handle); > libusb_exit(NULL); > exit(0); > } > > // This is where I read the USB device to get the latest data. > unsigned char data[50]; // where we want the data to go > > int getit(int whichOne, int noisy){ > int actual; // how many bytes were actually read > > // The second parameter is bmRequestType and is a bitfield > // See http://www.beyondlogic.org/usbnutshell/usb6.shtml > > // for the definitions of the various bits. With libusb, the > // #defines for these are at: > // > http://libusb.sourceforge.net/api-1.0/group__misc.html#gga0b0933ae70744726cde11254c39fac91a20eca62c34d2d25be7e1776510184209 > > *This is where the data is being read from the device.* > actual = libusb_control_transfer(weatherStation.handle, > LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE > | LIBUSB_ENDPOINT_IN, > //These bytes were stolen with a USB sniffer > 0x01,0x0100+whichOne,0, > data, 50, 10000); > if (actual < 0){ > fprintf(stderr,"Read didn't work for report %d, %s\n", whichOne, > libusb_strerror(actual)); > } > else { > // If you want both of the reports that the station provides, > // just allow for it. Right this second, I've found every thing > // I need in report 1. When I look further at report 2, this will > // change > > /*fprintf(stderr,"R%d:%d:", whichOne, actual); > int i; > for(i=0; i<actual; i++){ > fprintf(stderr,"%0.2X ",data[i]); > } > fprintf(stderr,"\n"); */ > > if (whichOne == 1) > > // The actual data starts after the first byte > // The first byte is the report number returned by > // the usb read. > > decode(&data[1], actual-1, noisy); > } > } > // I do several things here that aren't strictly necessary. As I learned > about > // libusb, I tried things and also used various techniques to learn about > the > // weatherstation's implementation. I left a lot of it in here in case I > needed to > // use it later. Someone may find it useful to hack into some other > device. > > int main(int argc, char **argv) > { > char *usage = {"usage: %s -u -n\n"}; > int libusbDebug = 0; //This will turn on the DEBUG for libusb > int noisy = 0; //This will print the packets as they come in > libusb_device **devs; > int r, err, c; > ssize_t cnt; > > while ((c = getopt (argc, argv, "unh")) != -1) > switch (c){ > case 'u': > libusbDebug = 1; > break; > case 'n': > noisy = 1; > break; > case 'h': > fprintf(stderr, usage, argv[0]); > case '?': > exit(1); > default: > exit(1); > } > fprintf (stderr,"libusbDebug = %d, noisy = %d\n", libusbDebug, noisy); > > if (signal(SIGINT, sig_handler) == SIG_ERR) > fprintf(stderr,"Couldn't set up signal handler\n"); > err = libusb_init(NULL); > if (err < 0){ > fprintf(stderr,"Couldn't init usblib, %s\n", libusb_strerror(err)); > exit(1); > } > // This is where you can get debug output from libusb. > // just set it to LIBUSB_LOG_LEVEL_DEBUG > > if (libusbDebug) > libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG); > else > libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); > > > cnt = libusb_get_device_list(NULL, &devs); > if (cnt < 0){ > fprintf(stderr,"Couldn't get device list, %s\n", > libusb_strerror(err)); > exit(1); > } > // got get the device; the device handle is saved in weatherStation > struct. > if (!findDevice(devs)){ > fprintf(stderr,"Couldn't find the device\n"); > exit(1); > } > // Now I've found the weather station and can start to try stuff > // So, I'll get the device descriptor > > struct libusb_device_descriptor deviceDesc; > err = libusb_get_device_descriptor(weatherStation.device, &deviceDesc); > if (err){ > fprintf(stderr,"Couldn't get device descriptor, %s\n", > libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"Got the device descriptor back\n"); > > // Open the device and save the handle in the weatherStation struct > err = libusb_open(weatherStation.device, &weatherStation.handle); > if (err){ > fprintf(stderr,"Open failed, %s\n", libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"I was able to open it\n"); > > // There's a bug in either the usb library, the linux driver or the > // device itself. I suspect the usb driver, but don't know for sure. > // If you plug and unplug the weather station a few times, it will stop > // responding to reads. It also exhibits some strange behaviour to > // getting the configuration. I found out after a couple of days of > // experimenting that doing a clear-halt on the device while before it > // was opened it would clear the problem. So, I have one here and a > // little further down after it has been opened. > > fprintf(stderr,"trying clear halt on endpoint %X ... ", 0x81); > // err = libusb_clear_halt(weatherStation.handle, 0x81); > if (err){ > fprintf(stderr,"clear halt crapped, %s Bug Detector\n", > libusb_strerror(err));; > } > else { > fprintf(stderr,"OK\n"); > } > > // Now that it's opened, I can free the list of all devices > libusb_free_device_list(devs, 1); // Documentation says to get rid of > the list > // Once I have the device I need > fprintf(stderr,"Released the device list\n"); > > // Now I have to check to see if the kernal using udev has attached > // a driver to the device. If it has, it has to be detached so I can > // use the device. > > if(libusb_kernel_driver_active(weatherStation.handle, 0) == 1) { > //find out if kernel driver is attached > fprintf(stderr,"Kernal driver active\n"); > if(libusb_detach_kernel_driver(weatherStation.handle, 0) == 0) > //detach it > fprintf(stderr,"Kernel Driver Detached!\n"); > } > > int activeConfig; > err =libusb_get_configuration (weatherStation.handle, &activeConfig); > if (err){ > fprintf(stderr,"Can't get current active configuration, %s\n", > libusb_strerror(err));; > exit(1); > } > fprintf(stderr,"Currently active configuration is %d\n", activeConfig); > > if(activeConfig != 1){ > err = libusb_set_configuration (weatherStation.handle, 1); > if (err){ > fprintf(stderr,"Cannot set configuration, %s\n", > libusb_strerror(err));; > exit(1); > } > fprintf(stderr,"Just did the set configuration\n"); > } > > err = libusb_claim_interface(weatherStation.handle, 0); //claim > interface 0 (the first) of device (mine had jsut 1) > if(err) { > fprintf(stderr,"Cannot claim interface, %s\n", > libusb_strerror(err)); > exit(1); > } > fprintf(stderr,"Claimed Interface\n"); > fprintf(stderr,"Number of configurations: > %d\n",deviceDesc.bNumConfigurations); > struct libusb_config_descriptor *config; > libusb_get_config_descriptor(weatherStation.device, 0, &config); > fprintf(stderr,"Number of Interfaces: > %d\n",(int)config->bNumInterfaces); > > // I know, the device only has one interface, but I wanted this code > // to serve as a reference for some future hack into some other device, > // so I put this loop to show the other interfaces that may > // be there. And, like most of this module, I stole the ideas from > // somewhere, but I can't remember where (I guess it's google overload) > > const struct libusb_interface *inter; > const struct libusb_interface_descriptor *interdesc; > const struct libusb_endpoint_descriptor *epdesc; > int i, j, k; > for(i=0; i<(int)config->bNumInterfaces; i++) { > inter = &config->interface[i]; > fprintf(stderr,"Number of alternate settings: %d\n", > inter->num_altsetting); > for(j=0; j < inter->num_altsetting; j++) { > interdesc = &inter->altsetting[j]; > fprintf(stderr,"Interface Number: %d\n", > (int)interdesc->bInterfaceNumber); > fprintf(stderr,"Number of endpoints: %d\n", > (int)interdesc->bNumEndpoints); > for(k=0; k < (int)interdesc->bNumEndpoints; k++) { > epdesc = &interdesc->endpoint[k]; > fprintf(stderr,"Descriptor Type: > %d\n",(int)epdesc->bDescriptorType); > fprintf(stderr,"Endpoint Address: > 0x%0.2X\n",(int)epdesc->bEndpointAddress); > // Below is how to tell which direction the > // endpoint is supposed to work. It's the high order bit > // in the endpoint address. I guess they wanted to hide > it. > fprintf(stderr," Direction is "); > if ((int)epdesc->bEndpointAddress & LIBUSB_ENDPOINT_IN != > 0) > fprintf(stderr," In (device to host)"); > else > fprintf(stderr," Out (host to device)"); > fprintf(stderr,"\n"); > } > } > } > fprintf(stderr,"trying clear halt on endpoint %X ... ", > (int)epdesc->bEndpointAddress); > // err = libusb_clear_halt(weatherStation.handle, > (int)epdesc->bEndpointAddress); > if (err){ > fprintf(stderr,"clear halt crapped, %s SHUCKS\n", > libusb_strerror(err));; > closeUpAndLeave(); > } > else { > fprintf(stderr,"OK\n"); > } > > // So, for the weather station we now know it has one endpoint and it > is set to > // send data to the host. Now we can experiment with that. > // > // I don't want to just hang up and read the reports as fast as I can, > so > // I'll space them out a bit. It's weather, and it doesn't change > very fast. > > int tickcounter= 0; > while(1){ > sleep(1); > if(tickcounter++ % 10 == 0){ > getit(1, noisy); > } > if(tickcounter % 30 == 0){ > getit(2, noisy); > } > if (tickcounter % 15 == 0){ > showit(); > } > } > }" > > > > > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > -- Best Regards, Wander Lairson Costa |
From: Gerry <gb...@ge...> - 2015-01-20 11:24:50
|
Sorry for the late reply but I had sent this to the pyusb-users-owner list instead of this list. I had originally included the files as attachments but the list stripped them off so now I am including them in this email. Hopefully someone can find a solution to this problem. -------- Forwarded Message -------- Subject: My Python source code and another's C code Date: Wed, 14 Jan 2015 19:09:35 +0800 From: Gerry <gb...@ge...> To: pyu...@li... Here is my Python code: "#!/usr/bin/python """ Read a MagTek USB HID Swipe Reader in Linux. A description of this code can be found at: http://www.micahcarrick.com/credit-card-reader-pyusb.html You must be using the new PyUSB 1.0 branch and not the 0.x branch. Copyright (c) 2010 - Micah Carrick """ import sys import usb.core #import usb.backend.libusb1 as libusb1 import usb.util VENDOR_ID = 0x24c0 PRODUCT_ID = 0x0003 DATA_SIZE = 50 # find the Acurite Weather Station device = usb.core.find(idVendor=0x24c0, idProduct=0x0003) if device is None: sys.exit("Could not find Acurite weatherstation.") #else: # print("Device FOUND!!", device) # fout = open('device.txt', 'w') # d1 = str(device) # fout.write(d1) # fout.close # make sure the hiddev kernel driver is not active if device.is_kernel_driver_active(0): try: device.detach_kernel_driver(0) except usb.core.USBError as e: sys.exit("Could not detatch kernel driver: %s" % str(e)) # set configuration try: device.set_configuration() device.reset() except usb.core.USBError as e: sys.exit("Could not set configuration: %s" % str(e)) endpoint = device[0][(0,0)][0] #print ("Endpoint = ", endpoint) #epa = endpoint.bEndpointAddress #mps = endpoint.wMaxPacketSize #print ("EPA = ", epa, "MPS= ", mps) data = [] print ("Now starting to read...") *This is where I am getting the errors. I originally had it as "d1 = device.read(..." but after looking at the Pyusb.core code it said it should be "d1 = read(device..." Both ways give the same errors. Hopefully you can find the problem so I can read my weather station...* d1 = read(device, endpoint.bEndpointAddress, endpoint.wMaxPacketSize) print ("D1 =",d1) '''while 1: try: #data += device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) #print("Data = ",data) data += device.read(0x81, 8) print ("Reading...") except usb.core.USBError as e: if e.args == ('Operation timed out',): #and swiped: if len(data) < DATA_SIZE: print ("Bad swipe, try again. (%d bytes)") % len(data) print ("Data: %s" % ''.join(map(chr, data))) data = [] continue else: print ("Data = ",data) break # we got it! ''' The other person's C code: "/* Documentation at desert-home.com Experimentation with a USB interface to the Acu-Rite 5 in 1 Weatherstation specifically for the Raspberry Pi. The code may work on other systems, but I don't have one of those. Contrary to other folk's thinking, I don't care if this ever runs on a Windows PC or an Apple anything. I specifically used a model 2032 display with the sensor that I picked up at one of those warehouse stores. The display has a usb plug on it and I thought it might be possible to read the usb port and massage the data myself. This code represents the result of that effort. I gathered ideas from all over the web. I use the latest (for this second) libusb and about a thousand examples of various things that other people have done and posted about. Frankly, I simply can't remember all of them, so please, don't be offended if you see your ideas somewhere in here and it isn't attributed. I simply lost track of where I found what. This module relies on libusb version 1.0.19 which, at this time, can only be compiled from source on the raspberry pi. Because there likely to be a version of libusb and the associated header file on a Pi, use the command line below to build it since the build of libusb-1.0.19 places things in /usr/local cc -o weatherstation weatherstation.c -L/usr/local/lib -lusb-1.0 * use ldd weatherstation to check which libraries are linked in. If you still have trouble with compilation, remember that cc has a -v parameter that can help you unwind what is happening. */ #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <time.h> #include <unistd.h> #include <sys/time.h> #include <libusb-1.0/libusb.h> // The vendor id and product number for the AcuRite 5 in 1 weather head. #define VENDOR 0x24c0 #define PRODUCT 0x0003 // I store things about the weather device USB connection here. struct { libusb_device *device; libusb_device_handle *handle; int verbose; } weatherStation; // These are the sensors the the 5 in 1 weather head provides struct { float windSpeed; time_t wsTime; int windDirection; time_t wdTime; float temperature; time_t tTime; int humidity; time_t hTime; int rainCounter; time_t rcTime; } weatherData; // This is just a function prototype for the compiler void closeUpAndLeave(); // I want to catch control-C and close down gracefully void sig_handler(int signo) { if (signo == SIGINT) fprintf(stderr,"Shutting down ...\n"); closeUpAndLeave(); } /* This tiny thing simply takes the data and prints it so we can see it */ // Array to translate the integer direction provided to text char *Direction[] = { "NNW", "NW ", "WNW", "W ", "WSW", "SW ", "SSW", "S ", "SSE", "SE ", "ESE", "E ", "ENE", "NE ", "NNE", "N " }; void showit(){ fprintf(stdout, "{\"windSpeed\":{\"WS\":\"%.1f\",\"t\":\"%d\"}," "\"windDirection\":{\"WD\":\"%s\",\"t\":\"%d\"}," "\"temperature\":{\"T\":\"%.1f\",\"t\":\"%d\"}," "\"humidity\":{\"H\":\"%d\",\"t\":\"%d\"}," "\"rainCounter\":{\"RC\":\"%d\",\"t\":\"%d\"}}\n", weatherData.windSpeed, weatherData.wsTime, Direction[weatherData.windDirection],weatherData.wdTime, weatherData.temperature, weatherData.tTime, weatherData.humidity, weatherData.hTime, weatherData.rainCounter, weatherData.rcTime); fflush(stdout); } /* This code translates the data from the 5 in 1 sensors to something that can be used by a human. */ float getWindSpeed(char *data){ int leftSide = (data[3] & 0x1f) << 3; int rightSide = data[4] & 0x70 >> 4; // Yes, I use mph, never got used to kilometers. return((float)(leftSide | rightSide) * 0.62); } int getWindDirection(char *data){ return(data[4] & 0x0f); } float getTemp(char *data){ // This item spans bytes, have to reconstruct it int leftSide = (data[4] & 0x0f) << 7; int rightSide = data[5] & 0x7f; float combined = leftSide | rightSide; return((combined - 400) / 10.0); } int getHumidity(char *data){ int howWet = data[6] &0x7f; return(howWet); } int getRainCount(char *data){ int count = data[6] &0x7f; return(count); } // Now that I have the data from the station, do something useful with it. void decode(char *data, int length, int noisy){ //int i; //for(i=0; i<length; i++){ // fprintf(stderr,"%0.2X ",data[i]); //} //fprintf(stderr,"\n"); time_t seconds = time (NULL); //There are two varieties of data, both of them have wind speed // first variety of the data if ((data[2] & 0x0f) == 1){ // this has wind speed, direction and rainfall if(noisy) fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); weatherData.windSpeed = getWindSpeed(data); weatherData.wsTime = seconds; if(noisy) fprintf(stderr,"Wind Direction: %s ",Direction[getWindDirection(data)]); weatherData.wdTime = seconds; weatherData.windDirection = getWindDirection(data); if(noisy){ fprintf(stderr,"Rain Counter: %d ",getRainCount(data)); fprintf(stderr,"\n"); } weatherData.rainCounter = getRainCount(data); weatherData.rcTime = seconds; } // this is the other variety if ((data[2] & 0x0f) == 8){ // this has wind speed, temp and relative humidity if(noisy) fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data)); weatherData.windSpeed = getWindSpeed(data); weatherData.wsTime = seconds; if(noisy) fprintf(stderr,"Temperature: %.1f ",getTemp(data)); weatherData.temperature = getTemp(data); weatherData.tTime = seconds; if(noisy){ fprintf(stderr,"Humidity: %d ", getHumidity(data)); fprintf(stderr,"\n"); } weatherData.humidity = getHumidity(data); weatherData.hTime = seconds; } } /* This code is related to dealing with the USB device */ // This searches the USB bus tree to find the device int findDevice(libusb_device **devs) { libusb_device *dev; int err = 0, i = 0, j = 0; uint8_t path[8]; while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; int r = libusb_get_device_descriptor(dev, &desc); if (r < 0) { fprintf(stderr,"Couldn't get device descriptor, %s\n", libusb_strerror(err)); return(1); } fprintf(stderr,"%04x:%04x (bus %d, device %d)", desc.idVendor, desc.idProduct, libusb_get_bus_number(dev), libusb_get_device_address(dev)); //r = libusb_get_port_numbers(dev, path, sizeof(path)); //if (r > 0) { // fprintf(stderr," path: %d", path[0]); // for (j = 1; j < r; j++) // fprintf(stderr,".%d", path[j]); //} //fprintf(stderr,"\n"); if (desc.idVendor == VENDOR && desc.idProduct == PRODUCT){ fprintf(stderr,"Found the one I want\n"); weatherStation.device = dev; return (1); } } return(0); } // to handle testing and try to be clean about closing the USB device, // I'll catch the signal and close off. void closeUpAndLeave(){ //OK, done with it, close off and let it go. fprintf(stderr,"Done with device, release and close it\n"); int err = libusb_release_interface(weatherStation.handle, 0); //release the claimed interface if(err) { fprintf(stderr,"Couldn't release interface, %s\n", libusb_strerror(err)); exit(1); } libusb_close(weatherStation.handle); libusb_exit(NULL); exit(0); } // This is where I read the USB device to get the latest data. unsigned char data[50]; // where we want the data to go int getit(int whichOne, int noisy){ int actual; // how many bytes were actually read // The second parameter is bmRequestType and is a bitfield // See http://www.beyondlogic.org/usbnutshell/usb6.shtml // for the definitions of the various bits. With libusb, the // #defines for these are at: //http://libusb.sourceforge.net/api-1.0/group__misc.html#gga0b0933ae70744726cde11254c39fac91a20eca62c34d2d25be7e1776510184209 *This is where the data is being read from the device.* actual = libusb_control_transfer(weatherStation.handle, LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_IN, //These bytes were stolen with a USB sniffer 0x01,0x0100+whichOne,0, data, 50, 10000); if (actual < 0){ fprintf(stderr,"Read didn't work for report %d, %s\n", whichOne, libusb_strerror(actual)); } else { // If you want both of the reports that the station provides, // just allow for it. Right this second, I've found every thing // I need in report 1. When I look further at report 2, this will // change /*fprintf(stderr,"R%d:%d:", whichOne, actual); int i; for(i=0; i<actual; i++){ fprintf(stderr,"%0.2X ",data[i]); } fprintf(stderr,"\n"); */ if (whichOne == 1) // The actual data starts after the first byte // The first byte is the report number returned by // the usb read. decode(&data[1], actual-1, noisy); } } // I do several things here that aren't strictly necessary. As I learned about // libusb, I tried things and also used various techniques to learn about the // weatherstation's implementation. I left a lot of it in here in case I needed to // use it later. Someone may find it useful to hack into some other device. int main(int argc, char **argv) { char *usage = {"usage: %s -u -n\n"}; int libusbDebug = 0; //This will turn on the DEBUG for libusb int noisy = 0; //This will print the packets as they come in libusb_device **devs; int r, err, c; ssize_t cnt; while ((c = getopt (argc, argv, "unh")) != -1) switch (c){ case 'u': libusbDebug = 1; break; case 'n': noisy = 1; break; case 'h': fprintf(stderr, usage, argv[0]); case '?': exit(1); default: exit(1); } fprintf (stderr,"libusbDebug = %d, noisy = %d\n", libusbDebug, noisy); if (signal(SIGINT, sig_handler) == SIG_ERR) fprintf(stderr,"Couldn't set up signal handler\n"); err = libusb_init(NULL); if (err < 0){ fprintf(stderr,"Couldn't init usblib, %s\n", libusb_strerror(err)); exit(1); } // This is where you can get debug output from libusb. // just set it to LIBUSB_LOG_LEVEL_DEBUG if (libusbDebug) libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG); else libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); cnt = libusb_get_device_list(NULL, &devs); if (cnt < 0){ fprintf(stderr,"Couldn't get device list, %s\n", libusb_strerror(err)); exit(1); } // got get the device; the device handle is saved in weatherStation struct. if (!findDevice(devs)){ fprintf(stderr,"Couldn't find the device\n"); exit(1); } // Now I've found the weather station and can start to try stuff // So, I'll get the device descriptor struct libusb_device_descriptor deviceDesc; err = libusb_get_device_descriptor(weatherStation.device, &deviceDesc); if (err){ fprintf(stderr,"Couldn't get device descriptor, %s\n", libusb_strerror(err)); exit(1); } fprintf(stderr,"Got the device descriptor back\n"); // Open the device and save the handle in the weatherStation struct err = libusb_open(weatherStation.device, &weatherStation.handle); if (err){ fprintf(stderr,"Open failed, %s\n", libusb_strerror(err)); exit(1); } fprintf(stderr,"I was able to open it\n"); // There's a bug in either the usb library, the linux driver or the // device itself. I suspect the usb driver, but don't know for sure. // If you plug and unplug the weather station a few times, it will stop // responding to reads. It also exhibits some strange behaviour to // getting the configuration. I found out after a couple of days of // experimenting that doing a clear-halt on the device while before it // was opened it would clear the problem. So, I have one here and a // little further down after it has been opened. fprintf(stderr,"trying clear halt on endpoint %X ... ", 0x81); // err = libusb_clear_halt(weatherStation.handle, 0x81); if (err){ fprintf(stderr,"clear halt crapped, %s Bug Detector\n", libusb_strerror(err));; } else { fprintf(stderr,"OK\n"); } // Now that it's opened, I can free the list of all devices libusb_free_device_list(devs, 1); // Documentation says to get rid of the list // Once I have the device I need fprintf(stderr,"Released the device list\n"); // Now I have to check to see if the kernal using udev has attached // a driver to the device. If it has, it has to be detached so I can // use the device. if(libusb_kernel_driver_active(weatherStation.handle, 0) == 1) { //find out if kernel driver is attached fprintf(stderr,"Kernal driver active\n"); if(libusb_detach_kernel_driver(weatherStation.handle, 0) == 0) //detach it fprintf(stderr,"Kernel Driver Detached!\n"); } int activeConfig; err =libusb_get_configuration (weatherStation.handle, &activeConfig); if (err){ fprintf(stderr,"Can't get current active configuration, %s\n", libusb_strerror(err));; exit(1); } fprintf(stderr,"Currently active configuration is %d\n", activeConfig); if(activeConfig != 1){ err = libusb_set_configuration (weatherStation.handle, 1); if (err){ fprintf(stderr,"Cannot set configuration, %s\n", libusb_strerror(err));; exit(1); } fprintf(stderr,"Just did the set configuration\n"); } err = libusb_claim_interface(weatherStation.handle, 0); //claim interface 0 (the first) of device (mine had jsut 1) if(err) { fprintf(stderr,"Cannot claim interface, %s\n", libusb_strerror(err)); exit(1); } fprintf(stderr,"Claimed Interface\n"); fprintf(stderr,"Number of configurations: %d\n",deviceDesc.bNumConfigurations); struct libusb_config_descriptor *config; libusb_get_config_descriptor(weatherStation.device, 0, &config); fprintf(stderr,"Number of Interfaces: %d\n",(int)config->bNumInterfaces); // I know, the device only has one interface, but I wanted this code // to serve as a reference for some future hack into some other device, // so I put this loop to show the other interfaces that may // be there. And, like most of this module, I stole the ideas from // somewhere, but I can't remember where (I guess it's google overload) const struct libusb_interface *inter; const struct libusb_interface_descriptor *interdesc; const struct libusb_endpoint_descriptor *epdesc; int i, j, k; for(i=0; i<(int)config->bNumInterfaces; i++) { inter = &config->interface[i]; fprintf(stderr,"Number of alternate settings: %d\n", inter->num_altsetting); for(j=0; j < inter->num_altsetting; j++) { interdesc = &inter->altsetting[j]; fprintf(stderr,"Interface Number: %d\n", (int)interdesc->bInterfaceNumber); fprintf(stderr,"Number of endpoints: %d\n", (int)interdesc->bNumEndpoints); for(k=0; k < (int)interdesc->bNumEndpoints; k++) { epdesc = &interdesc->endpoint[k]; fprintf(stderr,"Descriptor Type: %d\n",(int)epdesc->bDescriptorType); fprintf(stderr,"Endpoint Address: 0x%0.2X\n",(int)epdesc->bEndpointAddress); // Below is how to tell which direction the // endpoint is supposed to work. It's the high order bit // in the endpoint address. I guess they wanted to hide it. fprintf(stderr," Direction is "); if ((int)epdesc->bEndpointAddress & LIBUSB_ENDPOINT_IN != 0) fprintf(stderr," In (device to host)"); else fprintf(stderr," Out (host to device)"); fprintf(stderr,"\n"); } } } fprintf(stderr,"trying clear halt on endpoint %X ... ", (int)epdesc->bEndpointAddress); // err = libusb_clear_halt(weatherStation.handle, (int)epdesc->bEndpointAddress); if (err){ fprintf(stderr,"clear halt crapped, %s SHUCKS\n", libusb_strerror(err));; closeUpAndLeave(); } else { fprintf(stderr,"OK\n"); } // So, for the weather station we now know it has one endpoint and it is set to // send data to the host. Now we can experiment with that. // // I don't want to just hang up and read the reports as fast as I can, so // I'll space them out a bit. It's weather, and it doesn't change very fast. int tickcounter= 0; while(1){ sleep(1); if(tickcounter++ % 10 == 0){ getit(1, noisy); } if(tickcounter % 30 == 0){ getit(2, noisy); } if (tickcounter % 15 == 0){ showit(); } } }" |
From: Gerry <gb...@ge...> - 2015-01-14 10:56:19
|
Per your request I am attaching copies of my Python code and another's C code. Thanks, Gerald |
From: Wander L. C. <wan...@gm...> - 2015-01-13 12:04:22
|
Hi, Could you please post the C and Python source codes? 2015-01-12 10:09 GMT-02:00 Gerry <gb...@ge...>: > I have just reinstalled Pyusb on my Raspberry Pi. When I try to run the > application I have created I get the following error messages: > "Traceback (most recent call last): > File "gsbwx.py", line 61, in <module> > d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) > File "/usr/local/lib/python3.2/dist-packages/usb/core.py", line 918, > in read > self.__get_timeout(timeout)) > File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", > line 507, in intr_read > timeout) > File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", > line 562, in __read > timeout > File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", > line 380, in _check > raise USBError(errmsg, ret) > usb.core.USBError: [Errno None] b'No error'" > > I have included the following import statements in my code > "import sys > import usb.core > import usb.backend.libusb1 > import usb.util" > > and all of the error messages are pointing to "libusb0.py" not > "libusb1.py" as in my import statements. > > > I am trying to read an Acurite weather station. I have also tried this > on another computer system and also could not read the device. I have a > program that is written in C and it can read the device so I don't know > why Python can't read it. > > Any suggestions on how to fix the problem will greatly appreciated. > > I sent the above message on Jan 11. I am now getting the following errors: > > "Traceback (most recent call last): > File "gsbwx.py", line 62, in <module> > d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) > File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 905, > in read > intf, ep = self._ctx.setup_request(self, endpoint) > File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 190, > in setup_request > self.managed_claim_interface(device, intf) > File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 146, > in managed_claim_interface > self.backend.claim_interface(self.handle, i) > File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", > line 468, in claim_interface > _check(_lib.usb_claim_interface(dev_handle, intf)) > File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", > line 380, in _check > raise USBError(errmsg, ret) > usb.core.USBError: [Errno None] could not claim interface 0: Device or > resource busy > > Any ideas on why this is NOT WORKING??? Are there any other modules that > work with Python and USB??? > > Thanks, > > Gerry > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > vanity: www.gigenet.com > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users -- Best Regards, Wander Lairson Costa |
From: Gerry <gb...@ge...> - 2015-01-12 13:57:17
|
I have just reinstalled Pyusb on my Raspberry Pi. When I try to run the application I have created I get the following error messages: "Traceback (most recent call last): File "gsbwx.py", line 61, in <module> d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) File "/usr/local/lib/python3.2/dist-packages/usb/core.py", line 918, in read self.__get_timeout(timeout)) File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 507, in intr_read timeout) File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 562, in __read timeout File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 380, in _check raise USBError(errmsg, ret) usb.core.USBError: [Errno None] b'No error'" I have included the following import statements in my code "import sys import usb.core import usb.backend.libusb1 import usb.util" and all of the error messages are pointing to "libusb0.py" not "libusb1.py" as in my import statements. I am trying to read an Acurite weather station. I have also tried this on another computer system and also could not read the device. I have a program that is written in C and it can read the device so I don't know why Python can't read it. Any suggestions on how to fix the problem will greatly appreciated. I sent the above message on Jan 11. I am now getting the following errors: "Traceback (most recent call last): File "gsbwx.py", line 62, in <module> d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 905, in read intf, ep = self._ctx.setup_request(self, endpoint) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 190, in setup_request self.managed_claim_interface(device, intf) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 146, in managed_claim_interface self.backend.claim_interface(self.handle, i) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 468, in claim_interface _check(_lib.usb_claim_interface(dev_handle, intf)) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 380, in _check raise USBError(errmsg, ret) usb.core.USBError: [Errno None] could not claim interface 0: Device or resource busy Any ideas on why this is NOT WORKING??? Are there any other modules that work with Python and USB??? Thanks, Gerry |
From: Gerry <gb...@ge...> - 2015-01-12 13:10:05
|
This message was sent earlier but it never showed up on the mail list. In fact there are no mails showing up from Jan 1 - Jan 11, 2015... All of the errors that show up in PyUSB happen in the PyUSB.core file when I try to read from a device. -------- Forwarded Message -------- Subject: PyUSB problems Date: Mon, 12 Jan 2015 20:09:19 +0800 From: Gerry <gb...@ge...> To: pyu...@li... I have just reinstalled Pyusb on my Raspberry Pi. When I try to run the application I have created I get the following error messages: "Traceback (most recent call last): File "gsbwx.py", line 61, in <module> d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) File "/usr/local/lib/python3.2/dist-packages/usb/core.py", line 918, in read self.__get_timeout(timeout)) File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 507, in intr_read timeout) File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 562, in __read timeout File "/usr/local/lib/python3.2/dist-packages/usb/backend/libusb0.py", line 380, in _check raise USBError(errmsg, ret) usb.core.USBError: [Errno None] b'No error'" I have included the following import statements in my code "import sys import usb.core import usb.backend.libusb1 import usb.util" and all of the error messages are pointing to "libusb0.py" not "libusb1.py" as in my import statements. I am trying to read an Acurite weather station. I have also tried this on another computer system and also could not read the device. I have a program that is written in C and it can read the device so I don't know why Python can't read it. Any suggestions on how to fix the problem will greatly appreciated. I sent the above message on Jan 11. I am now getting the following errors: "Traceback (most recent call last): File "gsbwx.py", line 62, in <module> d1 = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 905, in read intf, ep = self._ctx.setup_request(self, endpoint) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 190, in setup_request self.managed_claim_interface(device, intf) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 146, in managed_claim_interface self.backend.claim_interface(self.handle, i) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 468, in claim_interface _check(_lib.usb_claim_interface(dev_handle, intf)) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 380, in _check raise USBError(errmsg, ret) usb.core.USBError: [Errno None] could not claim interface 0: Device or resource busy Any ideas on why this is NOT WORKING??? Are there any other modules that work with Python and USB??? Thanks, Gerry |