Re: [Pyobjc-dev] Wrapping GetLocationID from IOUSBLib
Brought to you by:
ronaldoussoren
From: Brendan S. (eTRIX) <Bre...@eT...> - 2009-06-23 01:06:12
|
Hi Orestis, Thanks for your response. I believe that GetLocationID() -- from the IOUSBLib -- is what I need. It simply takes a usb device handle and returns a unique integer which represents the location of the usb device on the usb busses. I beleive that GetLocationID() interrogates the IO Registry to obtain and/or calculate the information. I have made the assumption that anybody using PyObjC is probably familiar with Objective C and therefore familiar with OS X libraries (as that's the most prevalent ObjC platform) -- possibly an optimistic assumption ??? I had a quick look at ctypes and not sure if it can be used to access ObjC variables, functions, etc. I'm not sure if there is a way to build a C (or C++) wrapper around the ObjC code and then use ctypes. I presume it's possible but it's getting complicated :( What's involved in loading 'the framework' ?? I don't mind loading the framework if it's not overly complicated and there is not a big penalty (eg. too slow). I think the USB stuff is part of the IOKit framework. I've found this: http://pyobjc.sourceforge.net/documentation/pyobjc-core/wrapping.html The section 'the basics' seems to imply that I just need to have a file called 'Myframework.py' and that's it (if no wrappers are required) HUH ??? How does that work ??? Surely there must be some python or PyObjC code to write ??? Again, thanks for any assistance, Regards, Brendan. Orestis Markou wrote: > Hi Brendan, > > I would advise that you first confirm (by reading the apple docs or by > asking at the appropriate apple list) that GetLocationID does indeed do > what you want it to. The I/O Kit documentation should point you to the > right direction. > > You are unlikely to receive answers about such esoteric stuff on this > list, unless you strike gold and one of the members of the audience has > experience with the inner workings of Mac OS X usb libs. > > If you do find out that GetLocationID does what you want, you'd need to > load the framework it's part of in PyObjC, as it's not already there. If > that turns out to be too much of a bother (I think it might be), you can > always try using ctypes, but I think you can't mix ctypes and PyObjC > values together (in case you want to embed your code in a PyObjC app). > > I *think* the above are accurate, but I'd love to be corrected if anyone > has more accurate information. > > Orestis > -- > On 23 Jun 2009, at 00:25, Brendan Simon (eTRIX) wrote: > >> I'm new to PyObjC (and Object C in general). >> >> I have a python application that accesses a USB device, and I want to >> display the LocationID (like System Profiler and ioreg does). >> >> The LocationID seems to be OS X specific and not part of the standard >> USB protocol and thus not part of PyUSB. >> >> So assuming OS X does not provide a python interface to IOUSBLib (please >> let me know if it does), then I have to find a way to access it from >> Python. It would seem that PyObjC would be an appropriate method -- >> yes/no ??? >> >> The header file IOUSBLib.h contains the function GetLocationID. >> >> IOReturn (*GetLocationID)(void *self, UInt32 *locationID); >> >> Am I able to wrap this one function (or is it a method ?) easily with >> PyObjC ?? >> >> If it is easy, could someone provide some skeleton code for me to >> work/play with. >> If not so easy, could someone outline things that need to done and point >> me to some appropriate doucmentation. >> >> Many thanks, Brendan (pyobjc newbie) :) |