[Mono-osx] IOKit Enumeration

Geoff Norton gnorton at novell.com
Mon Apr 14 23:21:33 EDT 2008


On 14-Apr-08, at 8:20 PM, Joshua Perry wrote:

> Hey guys,
> I haven't had much time to work on this the last few months, but this
> weekend I was finally able to enumerate RS232 ports using P/Invoke to
> IOKit/CoreFoundation.  This would work for enumerating any items in  
> the
> IOKit database but I want to add support for
> System.IO.Ports.SerialPort.GetPortNames() to Mono for OSX.  This works
> quite well with any FTDI type chips that provide a virtual com-port  
> for
> communication, which is a common method of USB enabling devices.


> I do a lot of embedded development and talking to our hardware is
> important, and in future products we would like to ship software for  
> on Mono.

What do you guys make (for my personal curiousity) ?

> So before I start integrating this code into my local checkout, I  
> wanted
> to ask what the best method is for adding this to the Mono  
> codebase.  Is
> there a define for managed code on OSX builds?  I've noticed that a  
> lot
> of places a runtime check is used against  
> Environment.OSVersion.Platform
> to decide which logic to execute, is this the preferred method in
> managed code as opposed to conditional compilation?

There is a check you can lift in XplatUI.cs from Managed.Windows.Forms.

> Also, I have made some base classes that I use to manage reference
> counting and to make the P/Invoke to CoreFoundation objects and IOKit
> objects easier (e.g. CFString, CFMutableDictionary, IOObject).  Is  
> there
> an OSX helper library similar to PosixHelper that this code would go  
> in?

Generally we'd push stuff like that down into unmanaged code, I'm  
pretty sure the existing serial implementation has some unmanaged code  
so cleaning up the interface to be generic icalls and then  
implementing platform specific stuff in io-layer is (probably)  
better.  Note I havn't looked at the code yet, so this may not hold  


More information about the Mono-osx mailing list