[Pythonmac-SIG] Detecting serial devices

Pascal Oberndoerfer p.oberndoerfer@urheberrecht.org
Mon, 03 Feb 2003 18:08:17 +0100


Hello all.

It's (again) about detecting currently available serial devices (like
modems, IrDA, RS232) on MacOS X.


Dan Grassi at dan@grassi.org:

> The answer is to use the IORegistry to find a  device.  Search for
> IOSerialBSDClient  with a key of IOSerialBSCClientTyle with a value of
> IORS232SerialSteeam.  Then get the value of the IODialinDevice or
> IOCalloutDevice which are respectively (on my system)
> /dev/tty.USA191P1.1 and dev/cu.USA191P1.1.  Play with
> IORegistryExplorer to get a feel for it. :-)

This made me indeed curious. So I finally had a small utility that prints a
list of available devices including a device's name, basename, suffix,
Callout device file, and Dialin device file.

The source is 'SerialPorts.sit' at:

    <http://www.urheberrecht.org/institut/workers/oberndoerfer/>

[It's derived from some Apple sample code. I know it's a mess, but I have
never done any C or Objective-C before. So feel free to flame me about
programming style etc. ;-) Dan: if you would like to improve this, please do
so! Thanks!]

If you run it from outside ProjectBuilder you must open Console
(/Applications/Utilities) first.

My problem is: how can I wrap this snippet so it is accessible from
Mac(ho)Python 2.3?

Or is there any interest in making the complete IORegistry API available in
a systematical way (via bgen, as Jack suggested off list)? Or maybe other
parts of IOKit as well?

Any help very much appreciated,

Pascal

MacOS X 10.1.5, Mac(ho)Python 2.3a1, framework install