[Mono-osx] IOKit Enumeration

Joshua Perry josh at 6bit.com
Mon Apr 14 20:20:59 EDT 2008


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 OSX 
on Mono.

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?

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?

Thanks for any feedback,

Josh


More information about the Mono-osx mailing list