Python 3.4 + pyUSB 1.0 + libusb-win32 1.2.6.0, what happens?

2015-12-05 Thread jfong
I am new to python. I had a USB HID device which behavior is that the host send 
a 64 bytes commands to it, after complete the execution of this commands it 
send back a 64 bytes status to the host, so the host can check the status and 
decide the next step.

When I run it under Win7 with SwiftForth 3.5.9 (a Forth system) and 
libusb-win32 1.2.6.0, it performs well. But when I test it under the same PC 
with python 3.4, pyUSB 1.0 and libusb-win32 1.2.6.0, it performs a little 
strange. The status read back always fail at the first time (return zero 
length) and success at the second time.

>>> dev.write(0x02, cmdBuf)
64
>>> dev.read(0x81, 64, 5000)
array('B')# no data returned
>>> dev.read(0x81, 64, 5000)
array('B', [165, 0, ])# this one is correct, totally 64 bytes

another "strange" thing is that I had a 5000 timeout in the read but I see no 
delay at the first read. It returns immediately. I suppose it should wait for 5 
seconds long before it returns. Right?

Any hint?

Best Regards,
Jach Fong

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyUSB available for current versions of Windows?

2012-03-10 Thread Dietmar Schwertberger

Am 09.03.2012 18:18, schrieb John Nagle:

I want to enumerate the available USB devices. All I really
need is the serial number of the USB devices available to PySerial.
(When you plug in a USB device on Windows, it's assigned the next
available COM port number. On a reboot, the numbers are reassigned.
So if you have multiple USB serial ports, there's a problem.)


You can get the required information using Windows Management
Instrumentation (WMI).

See e.g. here for serial port information:
http://www.activexperts.com/admin/scripts/wmi/python/0358/


I'm using code like this to find my USB CDC devices from the device
description:

import win32com.client
strComputer = .
objWMIService = win32com.client.Dispatch(WbemScripting.SWbemLocator)
objSWbemServices = objWMIService.ConnectServer(strComputer,root\cimv2)
colItems = objSWbemServices.ExecQuery(SELECT Description,DeviceID FROM 
Win32_SerialPort)


COM_ports = []
for objItem in colItems:
print objItem.Description,objItem.DeviceID
if objItem.Description == USB CDC Simple IO HC9S08JSxx:
COM_ports.append( objItem.DeviceID )


On some PCs the query took some seconds.


Regards,

Dietmar
--
http://mail.python.org/mailman/listinfo/python-list


PyUSB available for current versions of Windows?

2012-03-09 Thread John Nagle

   I want to enumerate the available USB devices.  All I really
need is the serial number of the USB devices available to PySerial.
(When you plug in a USB device on Windows, it's assigned the next
available COM port number.  On a reboot, the numbers are reassigned.
So if you have multiple USB serial ports, there's a problem.)

   PyUSB can supposedly do this, but the documentation is misleading.
It makes a big point of being 100% Python, but that's because it's
just glue code to a platform-specific back end provided by someone
else.

   There's an old Windows back-end at 
http://www.craftedge.com/products/libusb.html;, but it was written for 
Windows XP, and can supposedly be run in compatibility mode on Windows 
Vista. Current versions of Windows, who knows? It's not open source, and 
it comes from someone who sells paper-cutting machines for crafters.


   There's another Windows back end at

https://sourceforge.net/apps/trac/libusb-win32/wiki

but it involves installing a low-level driver in Windows.
I especially like the instruction Close all applications which use USB 
devices before installing.  Does this include the keyboard and mouse?
They also warn The device driver can not be easily removed from the 
system.


John Nagle
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyUSB available for current versions of Windows?

2012-03-09 Thread Tim Roberts
John Nagle na...@animats.com wrote:

I want to enumerate the available USB devices.  All I really
need is the serial number of the USB devices available to PySerial.
...
(When you plug in a USB device on Windows, it's assigned the next
available COM port number.  On a reboot, the numbers are reassigned.
So if you have multiple USB serial ports, there's a problem.)

You can use the SetupDi APIs to enumerate the list of USB devices, but that
won't tell you what COM port they were assigned to.

You can look at the source code for USBView, which is available in the
Windows driver kit.  It can enumerate the hubs and ports and even fetch
their descriptors (by talking to the USB hub and host controller drivers),
but again it won't tell you what COM port was assigned.

PyUSB can supposedly do this, but the documentation is misleading.
It makes a big point of being 100% Python, but that's because it's
just glue code to a platform-specific back end provided by someone
else.

Of course it is.  You can't access devices in Windows without a kernel
driver.

There's an old Windows back-end at 
http://www.craftedge.com/products/libusb.html;, but it was written for 
Windows XP, and can supposedly be run in compatibility mode on Windows 
Vista. Current versions of Windows, who knows? It's not open source, and 
it comes from someone who sells paper-cutting machines for crafters.

It IS open source.  They are shipping libusb-win32 -- exactly the same
library you reference below.  Until Microsoft released WinUSB, libusb-win32
was the ONLY generic USB driver available on Windows.  It runs just fine on
Windows 7.

There's another Windows back end at
   https://sourceforge.net/apps/trac/libusb-win32/wiki
but it involves installing a low-level driver in Windows.

It's the same backend.  A driver is required in order to access devices on
Windows.  It's required on Linux as well, but Linux happens to include a
generic USB driver in the kernel.

A more modern generic USB driver and library is available at
http://www.libusb.org.  There is a Python binding for it.

I especially like the instruction Close all applications which use USB 
devices before installing.  Does this include the keyboard and mouse?

No, that's just being overly cautious.  Libusb-Win32 can act as a filter
driver, inserting itself into an existing USB stack, but to do so the
device stack you are filtering must be idle.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyusb and microchip mcp2210 interface

2012-02-29 Thread Tim Roberts
jobattle jobat...@gmail.com wrote:

Has anybody out there had any experience in using the PYUSB library with
the new Microchip MCP2210 USB to SPI chip?

It appears to the system as a HID device.  You don't need to use PyUSB --
it already has a driver.

Check libhid -- it has a Python binding.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Examples of Programming with PyUSB 1.0?

2011-03-04 Thread Aldo Ceccarelli
Hello All,
I will need to write a manager for acquiring barcodes from a USB
reader with

PyUSB 1.0  http://pyusb.sourceforge.net on libusb http://www.libusb.org/

but unfortunately I have no USB protocol background at the moment. Is
there any PyUSB 1.0 reporistory of examples to learn? Thank you All in
advance - KR Aldo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Examples of Programming with PyUSB 1.0?

2011-03-04 Thread Aldo Ceccarelli
On 4 Mar, 14:54, Aldo Ceccarelli ceccarelli.a...@gmail.com wrote:
 Hello All,
 I will need to write a manager for acquiring barcodes from a USB
 reader with

 PyUSB 1.0  http://pyusb.sourceforge.neton libusbhttp://www.libusb.org/

 but unfortunately I have no USB protocol background at the moment. Is
 there any PyUSB 1.0 reporistory of examples to learn? Thank you All in
 advance - KR Aldo

Currently studying this example Read a MagTek USB HID Swipe Reader in
Linux at http://www.micahcarrick.com/credit-card-reader-pyusb.html by
Micah Carrick: thanks! PS You must be using the new PyUSB 1.0 branch
and not the 0.x branch.

-- 
http://mail.python.org/mailman/listinfo/python-list


PyUSB 1.0.0 alpha 1 release

2010-12-29 Thread wander.lairson
Dear all,

PyUSB 1.0.0 alpha 1 is out. Since alpha 0, this version :

- Standard control requests through usb.control module.
- String descriptors through usb.util module.
- Complete PyUSB 0.4 API emulation.
- Working libusb 1.0 support under Windows.

For details check the ReleaseNotes.txt and ChangeLog files.

This version can be download through sourceforge:
https://sourceforge.net/projects/pyusb/files/PyUSB%201.0/1.0.0-alpha-1/
For further information about PyUSB visit the project website:
http://pyusb.sourceforge.net

-- 
Best Regards,
Wander Lairson Costa
LCoN - Laboratório de Computação Natural - Natural Computing Laboratory
(http://www.mackenzie.com.br/lcon.html)
Programa de Pós-Graduação em Engenharia Elétrica (PPGEE)
Faculdade de Computação e Informática (FCI)
Universidade Presbiteriana Mackenzie - SP - Brazil
-- 
http://mail.python.org/mailman/listinfo/python-list


Pyusb

2009-10-14 Thread Ronn Ross
I'm running Python 2.6 on windows. I'm install Pyusb and I'm having trouble
including the library in my script. Can someone point me in the right
direction to get this working or know of a good tutorial to help me out.
Best regards
-- 
http://mail.python.org/mailman/listinfo/python-list


Pyusb

2009-10-14 Thread Ronn Ross
Does anyone know where I can download a copy of PyUSB 1.0? I can only find
0.x versions on sourceforge. I'm following a tutorial that requires 1.0.
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pyusb

2009-10-14 Thread Chris Withers

Ronn Ross wrote:
Does anyone know where I can download a copy of PyUSB 1.0? I can only 
find 0.x versions on sourceforge. I'm following a tutorial that requires 
1.0. Thanks


Googling pyusb gives me loads of hits and the newer versions appear to 
be on about the 3rd link down...


Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-21 Thread Dr Mephesto
On Mar 20, 6:23 pm, Philip Semanchuk phi...@semanchuk.com wrote:
 On Mar 20, 2009, at 12:36 PM, Dr Mephesto wrote:

  windows? well, I thought that maybe the location of the usb.h thing
  was relevant, and I didnt see it mentioned on the linux instructions.

 Oh, OK. Windows is a pretty different animal from Unix/Linux so it's  
 not likely to be of much help here.



  find /usr -name usb.h -ls   gives me:
  3545683       24 -rw-r--r--    1 root     wheel        8360 Mar 20
  16:37 /usr/include/usb.h
  3538549       24 -rw-rw-r--    1 root     wheel        8360 Feb 22
  11:28 /usr/local/include/usb.h

 Looks good.

  sudo python setup.py install         this gives me:
  pcfr147:pyusb-0.4.1 david$ sudo python setup.py install
  Password:
  running install
  running build
  running build_ext
  building 'usb' extension
  gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
  fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
  fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/
  Python.framework/Versions/4.1.30101/include/python2.5 -c pyusb.c -o
  build/temp.macosx-10.3-i386-2.5/pyusb.o
  In file included from pyusb.c:11:
  pyusb.h:6:17: error: usb.h: No such file or directory

 OK, I think I see what's going wrong, but I don't understand it. I  
 think I was wrong; setup.py doesn't automatically add /usr/include  
 and /usr/local/include to the include path when compiling. I'm basing  
 this on the documentation here, which states that these paths have to  
 be added 
 explicitly:http://docs.python.org/distutils/setupscript.html#preprocessor-options

 However, the two C extensions I distribute compile just fine without  
 that, and they certainly rely on /usr/include and /usr/local/include.  
 Strange...

 But nevermind that. Looking in the setup.py for PyUSB, I see this  
 special code added for OS X (a.k.a. Darwin):

 elif -1 != platform.find(darwin):
      extra_link_args = ['-framework',
                         'CoreFoundation',
                         '-framework',
                         'IOKit',
                         '-L/sw/lib']
      extra_compile_args = ['-I/sw/include']

 The ['-I/sw/include'] tells the compiler what directories to search  
 for include files. The /sw/ tree is specific to Fink, so if you'd used  
 Fink to install libusb then the PyUSB setup would have found it. But  
 you didn't use Fink (nothing wrong with that; I don't either) and so  
 your usb.h landed in /usr/local/include. What you need to do, then, is  
 add that directory to the list.

 So change line 32 in the PyUSB setup.py from this:
      extra_compile_args = ['-I/sw/include']
 to this:
      extra_compile_args = ['-I/sw/include', '-I/usr/local/include']

 The same assumption is made about the linker path. Note the '-L/sw/
 lib'. You'll need to track down your copy of libusb (it's probably in /
 usr/local/lib) and add that to the extra_link_args like so:

      extra_link_args = ['-framework',
                         'CoreFoundation',
                         '-framework',
                         'IOKit',
                         '-L/sw/lib',
                         '-L/usr/local/lib']

 Run setup again and I bet you'll be off to the races.

 You should certainly report this to the package maintainer, and you  
 might also want to point out that the if block starting on line 17 of  
 setup.py and the if block starting on line 26 are both for OS X, but  
 they lead to different results!

 Let us know how it works out,
 Philip

Great, that did the job perfectly! Very much appreciated!

I will write to the code maintainer to let them know the fix; I'm sure
their are lots of other people out there that will find your
modification useful.

Thanks again,
Dave

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-21 Thread Philip Semanchuk


On Mar 21, 2009, at 2:49 AM, Dr Mephesto wrote:


On Mar 20, 6:23 pm, Philip Semanchuk phi...@semanchuk.com wrote:

So change line 32 in the PyUSB setup.py from this:
 extra_compile_args = ['-I/sw/include']
to this:
 extra_compile_args = ['-I/sw/include', '-I/usr/local/include']

The same assumption is made about the linker path. Note the '-L/sw/
lib'. You'll need to track down your copy of libusb (it's probably  
in /

usr/local/lib) and add that to the extra_link_args like so:

 extra_link_args = ['-framework',
'CoreFoundation',
'-framework',
'IOKit',
'-L/sw/lib',
'-L/usr/local/lib']

Run setup again and I bet you'll be off to the races.

You should certainly report this to the package maintainer, and you
might also want to point out that the if block starting on line 17 of
setup.py and the if block starting on line 26 are both for OS X, but
they lead to different results!

Let us know how it works out,
Philip


Great, that did the job perfectly! Very much appreciated!

I will write to the code maintainer to let them know the fix; I'm sure
their are lots of other people out there that will find your
modification useful.


You're welcome. Glad I could help.

bye
Philip




--
http://mail.python.org/mailman/listinfo/python-list


Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Dr Mephesto
Hi,

I am using Leopard and MacPython, and I would like to access a USB
device. I have installed libusb, and now I have tried to compile PyUSB
from:
http://sourceforge.net/projects/pyusb/

But when I compile I get lots of errors, ie:

pcfr147:pyusb-0.4.1 david$ python setup.py install
running install
running build
running build_ext
building 'usb' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/
Python.framework/Versions/4.1.30101/include/python2.5 -c pyusb.c -o
build/temp.macosx-10.3-i386-2.5/pyusb.o
In file included from pyusb.c:11:
pyusb.h:6:17: error: usb.h: No such file or directory
In file included from pyusb.c:11:
pyusb.h:120: error: syntax error before 'usb_dev_handle'
pyusb.h:120: warning: no semicolon at end of struct or union
pyusb.h:122: error: syntax error before '}' token
pyusb.h:122: warning: data definition has no type or storage class
pyusb.h:131: warning: 'struct usb_endpoint_descriptor' declared inside
parameter list
pyusb.h:131: warning: its scope is only this definition or
declaration, which is probably not what you want
...
...
pyusb.c:2083: error: dereferencing pointer to incomplete type
pyusb.c:2084: warning: passing argument 1 of 'new_Bus' from
incompatible pointer type
lipo: can't figure out the architecture type of: /var/folders/xt/
xtY5vvWXEUyZv0KZrwtRzTI/-Tmp-//ccYg0qka.out
error: command 'gcc' failed with exit status 1


A long time googling found this similar problem:
http://ubuntuforums.org/archive/index.php/t-325241.html
The suggested answer was to first do:

sudo apt-get install python-dev

But that was for a debian machine. I dont use fink, and I prefer to
use a standard osx python install if possible.   I am still a python
novice, and I'm not sure if I am using the python setup.py install
command wrongly, or if I need this python-dev package, or something
completely different.

Has anyone had this problem, or know a solution? Thanks in Advance!



--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Philip Semanchuk


On Mar 20, 2009, at 9:48 AM, Dr Mephesto wrote:


Hi,

I am using Leopard and MacPython, and I would like to access a USB
device. I have installed libusb, and now I have tried to compile PyUSB
from:
http://sourceforge.net/projects/pyusb/

But when I compile I get lots of errors, ie:


Hi Dr. M.,
The first error you get is that the compiler can't find usb.h:


pyusb.h:6:17: error: usb.h: No such file or directory



It's not surprising that a compile produces lots of errors when it  
can't find a header file.


This project is looking for a header file that's not on your system  
because PyUSB is Linux-specific. That doesn't mean it can't be made to  
run on OS X, but the amount of effort required to make that happen  
might range anywhere from trivial to difficult.


PyUSB deals with hardware, and I wouldn't be surprised to find that a  
hardware interface varies from OS to OS. Since an entire header file  
is missing here, my guess is that making it work on OS X would be  
closer to difficult than trivial. It's also possible (likely?) that  
the author doesn't even have a Mac or access to one, and so can't  
experiment under OS X.


You need to contact the package author to ask if he has considered OS  
X support. If not, you'll need to find another package. Google for  
something like this:

python usb os x

That should help you to find packages that will work under OS X. Be  
aware that there might not be such a package. :-/



Hope this helps
Philip

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Dr Mephesto
Thanks.

I found some more info that might help, if I understood it :)From the
main PyUSB page, at http://pyusb.berlios.de/ , its says:

PyUSB uses the libusb to do its work, so, any system which has Python
and libusb should work for PyUSB.

I have installed the OSX version of libusb, and it puts the missing
file usb.h in the directory: usr/local/include/usb.h
In the instruction for installing PyUSB on windows, it says:

2) libusb-win32: a Windows version of the libusb C library available
from http://libusb-win32.sourceforge.net.
From within a Cygwin terminal, copy the libusb.a file from the
libusb-win32 lib/ directory to $(CYGWINDIR)/usr/lib/, and copy the
usb.h file from the libusb-win32 include/ directory to
$(CYGWINDIR)/usr/include/.  You can build and install PyUSB with the
command:   python setup.py install

As I have the required usb.h file, is there some way to let the
compiler know where is it when I run python setup.py install? I
already tried copying the usb.h file from usr/local/include/ to /usr/
iinclude, but it still didnt find it.

Dave


--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Philip Semanchuk


On Mar 20, 2009, at 11:39 AM, Dr Mephesto wrote:


Thanks.

I found some more info that might help, if I understood it :)From the
main PyUSB page, at http://pyusb.berlios.de/ , its says:

PyUSB uses the libusb to do its work, so, any system which has Python
and libusb should work for PyUSB.


OK, great -- that moves your problem from PyUSB to libusb, which is  
useful to know. The PyUSB page lists supported operating systems only  
as Linux which is partly what threw me off.




I have installed the OSX version of libusb, and it puts the missing
file usb.h in the directory: usr/local/include/usb.h
In the instruction for installing PyUSB on windows, it says:

2) libusb-win32: a Windows version of the libusb C library available
from http://libusb-win32.sourceforge.net.

From within a Cygwin terminal, copy the libusb.a file from the

libusb-win32 lib/ directory to $(CYGWINDIR)/usr/lib/, and copy the
usb.h file from the libusb-win32 include/ directory to
$(CYGWINDIR)/usr/include/.  You can build and install PyUSB with the
command:   python setup.py install


Whoa, why are we discussing Windows all of a sudden?



As I have the required usb.h file, is there some way to let the
compiler know where is it when I run python setup.py install? I
already tried copying the usb.h file from usr/local/include/ to / 
usr/

iinclude, but it still didnt find it.


You don't have to do anything special to get the Python compile step  
to look in /usr/include or /usr/local/include.


Can you post the output from this command?
find /usr -name usb.h -ls

Also post the output you get when you run this for PyUSB:
sudo python setup.py install







--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Dr Mephesto
windows? well, I thought that maybe the location of the usb.h thing
was relevant, and I didnt see it mentioned on the linux instructions.

find /usr -name usb.h -ls   gives me:
3545683   24 -rw-r--r--1 root wheel8360 Mar 20
16:37 /usr/include/usb.h
3538549   24 -rw-rw-r--1 root wheel8360 Feb 22
11:28 /usr/local/include/usb.h



sudo python setup.py install this gives me:
pcfr147:pyusb-0.4.1 david$ sudo python setup.py install
Password:
running install
running build
running build_ext
building 'usb' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/
Python.framework/Versions/4.1.30101/include/python2.5 -c pyusb.c -o
build/temp.macosx-10.3-i386-2.5/pyusb.o
In file included from pyusb.c:11:
pyusb.h:6:17: error: usb.h: No such file or directory
In file included from pyusb.c:11:
pyusb.h:120: error: syntax error before 'usb_dev_handle'
pyusb.h:120: warning: no semicolon at end of struct or union
pyusb.h:122: error: syntax error before '}' token
pyusb.h:122: warning: data definition has no type or storage class
pyusb.h:131: warning: 'struct usb_endpoint_descriptor' declared inside
parameter list
pyusb.h:131: warning: its scope is only this definition or
declaration, which is probably not what you want
pyusb.h:135: warning: 'struct usb_endpoint_descriptor' declared inside
parameter list
pyusb.h:140: warning: 'struct usb_interface_descriptor' declared
inside parameter list
pyusb.h:144: warning: 'struct usb_interface_descriptor' declared
inside parameter list
pyusb.h:149: warning: 'struct usb_config_descriptor' declared inside
parameter list
pyusb.h:153: warning: 'struct usb_config_descriptor' declared inside
parameter list
pyusb.h:171: warning: 'struct usb_bus' declared inside parameter list
pyusb.h:239: error: syntax error before '*' token
pyusb.h:241: warning: data definition has no type or storage class
pyusb.c: In function 'getBuffer':
pyusb.c:143: warning: passing argument 3 of 'PyString_AsStringAndSize'
from incompatible pointer type
pyusb.c: In function 'installModuleConstants':
pyusb.c:236: error: 'USB_CLASS_PER_INTERFACE' undeclared (first use in
this function)
pyusb.c:236: error: (Each undeclared identifier is reported only once
pyusb.c:236: error: for each function it appears in.)
pyusb.c:237: error: 'USB_CLASS_AUDIO' undeclared (first use in this
function)
pyusb.c:238: error: 'USB_CLASS_COMM' undeclared (first use in this
function)
pyusb.c:239: error: 'USB_CLASS_HID' undeclared (first use in this
function)
pyusb.c:240: error: 'USB_CLASS_PRINTER' undeclared (first use in this
function)
pyusb.c:241: error: 'USB_CLASS_MASS_STORAGE' undeclared (first use in
this function)
pyusb.c:242: error: 'USB_CLASS_HUB' undeclared (first use in this
function)
pyusb.c:243: error: 'USB_CLASS_DATA' undeclared (first use in this
function)
pyusb.c:244: error: 'USB_CLASS_VENDOR_SPEC' undeclared (first use in
this function)
pyusb.c:245: error: 'USB_DT_DEVICE' undeclared (first use in this
function)
pyusb.c:246: error: 'USB_DT_CONFIG' undeclared (first use in this
function)
pyusb.c:247: error: 'USB_DT_STRING' undeclared (first use in this
function)
pyusb.c:248: error: 'USB_DT_INTERFACE' undeclared (first use in this
function)
pyusb.c:249: error: 'USB_DT_ENDPOINT' undeclared (first use in this
function)
pyusb.c:250: error: 'USB_DT_HID' undeclared (first use in this
function)
pyusb.c:251: error: 'USB_DT_REPORT' undeclared (first use in this
function)
pyusb.c:252: error: 'USB_DT_PHYSICAL' undeclared (first use in this
function)
pyusb.c:253: error: 'USB_DT_HUB' undeclared (first use in this
function)
pyusb.c:254: error: 'USB_DT_DEVICE_SIZE' undeclared (first use in this
function)
pyusb.c:255: error: 'USB_DT_CONFIG_SIZE' undeclared (first use in this
function)
pyusb.c:256: error: 'USB_DT_INTERFACE_SIZE' undeclared (first use in
this function)
pyusb.c:257: error: 'USB_DT_ENDPOINT_SIZE' undeclared (first use in
this function)
pyusb.c:258: error: 'USB_DT_ENDPOINT_AUDIO_SIZE' undeclared (first use
in this function)
pyusb.c:259: error: 'USB_DT_HUB_NONVAR_SIZE' undeclared (first use in
this function)
pyusb.c:260: error: 'USB_MAXENDPOINTS' undeclared (first use in this
function)
pyusb.c:261: error: 'USB_ENDPOINT_ADDRESS_MASK' undeclared (first use
in this function)
pyusb.c:262: error: 'USB_ENDPOINT_DIR_MASK' undeclared (first use in
this function)
pyusb.c:263: error: 'USB_ENDPOINT_TYPE_MASK' undeclared (first use in
this function)
...
and lots lots more. do you want the whole lot? It still cant find that
usb.h file.

dave
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling modules in OSX, eg PyUSB?

2009-03-20 Thread Philip Semanchuk


On Mar 20, 2009, at 12:36 PM, Dr Mephesto wrote:


windows? well, I thought that maybe the location of the usb.h thing
was relevant, and I didnt see it mentioned on the linux instructions.


Oh, OK. Windows is a pretty different animal from Unix/Linux so it's  
not likely to be of much help here.





find /usr -name usb.h -ls   gives me:
3545683   24 -rw-r--r--1 root wheel8360 Mar 20
16:37 /usr/include/usb.h
3538549   24 -rw-rw-r--1 root wheel8360 Feb 22
11:28 /usr/local/include/usb.h



Looks good.



sudo python setup.py install this gives me:
pcfr147:pyusb-0.4.1 david$ sudo python setup.py install
Password:
running install
running build
running build_ext
building 'usb' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/
Python.framework/Versions/4.1.30101/include/python2.5 -c pyusb.c -o
build/temp.macosx-10.3-i386-2.5/pyusb.o
In file included from pyusb.c:11:
pyusb.h:6:17: error: usb.h: No such file or directory


OK, I think I see what's going wrong, but I don't understand it. I  
think I was wrong; setup.py doesn't automatically add /usr/include  
and /usr/local/include to the include path when compiling. I'm basing  
this on the documentation here, which states that these paths have to  
be added explicitly:

http://docs.python.org/distutils/setupscript.html#preprocessor-options


However, the two C extensions I distribute compile just fine without  
that, and they certainly rely on /usr/include and /usr/local/include.  
Strange...



But nevermind that. Looking in the setup.py for PyUSB, I see this  
special code added for OS X (a.k.a. Darwin):


elif -1 != platform.find(darwin):
extra_link_args = ['-framework',
   'CoreFoundation',
   '-framework',
   'IOKit',
   '-L/sw/lib']
extra_compile_args = ['-I/sw/include']


The ['-I/sw/include'] tells the compiler what directories to search  
for include files. The /sw/ tree is specific to Fink, so if you'd used  
Fink to install libusb then the PyUSB setup would have found it. But  
you didn't use Fink (nothing wrong with that; I don't either) and so  
your usb.h landed in /usr/local/include. What you need to do, then, is  
add that directory to the list.


So change line 32 in the PyUSB setup.py from this:
extra_compile_args = ['-I/sw/include']
to this:
extra_compile_args = ['-I/sw/include', '-I/usr/local/include']


The same assumption is made about the linker path. Note the '-L/sw/ 
lib'. You'll need to track down your copy of libusb (it's probably in / 
usr/local/lib) and add that to the extra_link_args like so:


extra_link_args = ['-framework',
   'CoreFoundation',
   '-framework',
   'IOKit',
   '-L/sw/lib',
   '-L/usr/local/lib']



Run setup again and I bet you'll be off to the races.


You should certainly report this to the package maintainer, and you  
might also want to point out that the if block starting on line 17 of  
setup.py and the if block starting on line 26 are both for OS X, but  
they lead to different results!



Let us know how it works out,
Philip

--
http://mail.python.org/mailman/listinfo/python-list


Enquiry about PyUSB

2008-06-27 Thread Abhishek Wadhava
Hi..
I'm trying to make a Software USB based on AVR309 application note available
at www.atmel.com/dyn/resources/prod_documents/doc2556.pdf
So what basically i'm doing is programming a ATTINY-44 to do functions of a
USB-driver and when connected to USB port, should be automatically detected
by the computer.
Now i'm also making a GUI using Tkinter in Python to read data from the
microcontroller  to write in it.
I basically have to perform digital and analog input-output in
microcontroller through python gui.
I was thinking of using pyUSB for this purpose.
but i'm unable to understand how to read and write from a USB device using
pyUSB.
Please help me in any way in this regard.
Thank U.
--
http://mail.python.org/mailman/listinfo/python-list