[Python-bugs-list] [ python-Bugs-674574 ] Access to serial devices through Carbon.CF

SourceForge.net noreply@sourceforge.net
Wed, 29 Jan 2003 01:59:36 -0800


Bugs item #674574, was opened at 2003-01-25 15:15
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=674574&group_id=5470

Category: Macintosh
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 3
Submitted By: Pascal Oberndoerfer (pascal_efi)
Assigned to: Jack Jansen (jackjansen)
Summary: Access to serial devices through Carbon.CF

Initial Comment:
There is currently no wrapper to access serial RS232
devices (e.g. Keyspan USB-serial adaptor) through
Carbon.CF on MacOS X.

This was my short and dirty hack to get a list of
currently available (Keyspan) serial devices:

#!/usr/bin/env python

import os
import string

PRE = 'cu'
#PRE = 'tty'

device_list = filter(lambda s: string.count(s,
PRE+'.USA'), os.listdir('/dev/'))
print device_list


But as Jack said:

Anything that is in CF but not wrapped in the Carbon.CF
module 
should be considered a bug. I know there's still quite
a bit missing, 
but if people put bug reports up on sourceforge that
will influence 
the order in which I add stuff to the CF module. It
would help a lot 
if you mentioned the data structure and/or some of the
routines 
you need.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your
revolution -- Emma 
Goldman -


Dan Grassi supposed (slightly paraphrased) to do the
folowing on MacOS X with IORegistryExplorer (inside
/Applications/Utilities)

> Search for IOSerialBSDClient  with a key of 
> IOSerialBSDClientType 
> with a value of IORS232SerialStream.  
> Then get the value of the 
> IODialinDevice (/dev/tty.*) or IOCalloutDevice
(/dev/cu.*) ...


For a single serial device this can result in:

{
    CFBundleIdentifier = com.apple.iokit.IOSerialFamily; 
    IOCalloutDevice = /dev/cu.USA19QW21P1.1; 
    IOClass = IOSerialBSDClient; 
    IODialinDevice = /dev/tty.USA19QW21P1.1; 
    IOMatchCategory = IODefaultMatchCategory; 
    IOPersonalityName = IOSerialBSDClientSync; 
    IOProbeScore = 1000; 
    IOProviderClass = IOSerialStreamSync; 
    IOResourceMatch = IOBSD; 
    IOSerialBSDClientType = IORS232SerialStream; 
    IOTTYBaseName = USA19QW21P1.; 
    IOTTYDevice = USA19QW21P1.1; 
    IOTTYSuffix = 1; 
    ParentKey =
"KEXTBundle?com.apple.iokit.IOSerialFamily"; 
}


So maybe return a list of dictionaries?

Pascal (MacOS X, MacPython 2.3a1 [Framework Install])


----------------------------------------------------------------------

>Comment By: Jack Jansen (jackjansen)
Date: 2003-01-29 10:59

Message:
Logged In: YES 
user_id=45365

I had a look through the documentation you referred to, and you would indeed need an interface to IOKit. I'm closing this report (as the title is misleading), if you really need IOKit file a feature request. But don't expect it to happen soon unless you contribute:-)

----------------------------------------------------------------------

Comment By: Pascal Oberndoerfer (pascal_efi)
Date: 2003-01-26 08:53

Message:
Logged In: YES 
user_id=688343

Jack, (sorry, quite long again)

I was afraid you would ask -- because I don't know. So I
went to the Apple docs and found some information that made
me doubt if it's really Carbon.CF I am looking for.

http://developer.apple.com/techpubs/macosx/Darwin/General/AccessingHardware/AH_Intro

As I need "only" a list of accessible serial devices and the
paths to their device files two chapters sounded interesting
to me:

1. I/O Kit Hardware Access > 
•	Using a Device Interface to Access a Device > 
  	-	Finding Devices

2. Working With Serial I/O > 
•	Working With a Serial Port Modem > 
  	-	Setting Up Your Programming Environment
  	-	Setting Up a Main Function
  	-	Finding All Serial Port Modems
  	-	Getting the Path to the Device File for a Modem

Finding all available serial ports and getting the path(s)
to their respective device files. Opening, working with, and
closing the ports is all done with pyserial. If I only
understood the docs! (have I ever been in the need of an
excellent example why I prefer Python over any other
programming language? ;-)

I found some sample code at Apple as well:

http://developer.apple.com/samplecode/Sample_Code/Devices_and_Hardware/Serial/SerialPortSample.htm

But again: I am not a professional programmer (especially
not C) so I have no idea what it means or what to do with it.

Hmm... Actually, if it is not possible to access this from
CF then -- according to your definition -- it's not a bug
but a feature request I guess.

The reason it would be extremly nice to have this way to
scan for the serial ports is that they disappear completely
with the removal of the USB-adapter. But as there is a
workaround priority is really low, low, low!

Pascal

PS: my motivation behind all this is a small data logging
utility I need to write.


----------------------------------------------------------------------

Comment By: Jack Jansen (jackjansen)
Date: 2003-01-25 23:46

Message:
Logged In: YES 
user_id=45365

Pascal,
could you tell me which bits of CF you need? I asume CFBundle, but would you need all of it, or just a part? Would you need anything more than CFBundle?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=674574&group_id=5470