CDC and OSX

Does anyone knows how to make CDC class works on a OSX host ?

OSX detects the CDC buy not install any tty device…

It seems there is no one using a Mac…

I am not sure how it is done with MAC. With windows driver there is the inf file that tells the OS the required information to enumerate the device as CDC in addition to the VID and PID.

Hi Pablo, I plan on using a Mac as “controller” for a FEZ too.

I have zero experience with USB programing, but here is what I found out so far:

  1. USB CDC:
    CDC seems to be a standardized protocol that enables USB to create virtual COM ports, network interfaces etc. OSX seems not to ship with a kernel extension for CDC devices. But, Apple published a set of CDC drivers (open source). See here: http://www.opensource.apple.com/source/AppleUSBCDCDriver/AppleUSBCDCDriver-4005.4.2/

I downloaded the driver but actually I didn’t even bother to try it out. CDC is not what I am looking for, I dislike the idea of creating a COM port on the users Mac to access the FEZ. Also, the CDC driver requires deployment of a kernel extension, meaning it requires admin rights. I am actually after something simpler.

  1. USB HID
    I saw some awesome posts about users experimenting on how to configure the FEZ to be a HID device. Now, as far as I understand, this has some drawbacks too: HID devices/protocols are standardized (AFAIK), so the message length etc might have to follow the standard for things to work. Another drawback is it seems OS X (the kernel) will always take control of HID devices (since there are expected to be controlled by the system, eg mouse, pen etc). So that might cause problems accessing the device from an app.

  2. Custom USB communication
    Now, last option is to just create a custom USB device, with two endpoints on the FEZ. This option is a bit painfull for Windows users, since you have to create a Driver INF to tell Windows how to access the device. I found an excelent article how to do this: Communicating with your MicroFramework Application over USB | GuruCE

Now, and this is the great part, what is so hard under WIndows, turns out to be fairly easy under OS X (at least in theory): if no custom driver (KEXT) is defined for a device, OS X will load a system default driver. It looks like it is fairly easy to use IOKIT functions to get a USB devices interface, enumerate its endpoints, communicate with it’s pipes. All this can be done entirely on user land - no kernel driver required.

This Apple document describes the basics of USB/IOKIT programing (has sample code that does mostly what is needed)
http://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/USBBook/USBIntro/USBIntro.html%23//apple_ref/doc/uid/TP40002643-TPXREF101

On the FEZ I am starting the USB Client as demoed in the last sample in
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/Index.html

Cheers
mark

One more thing… so far I have mostly done some research, I have no working code.
Please share your thoughts - if I am terribly mistaken (not unusual) I’d like to get some feedback.

I’ll try to put some code together about option #3. If it works, I’ll share…

Cheers mark

I got it working. The USB sample from Apple shows all that’s needed.

With the FEZ acting as USB loopback, I get around 25KB send & receive (totaling 50KB throughput) per second.

Not really that fast.
For my immediate needs fast enough.

I’ll clean up the code a bit (I really can’t show this to anybody) and then post it on the code.tinyclr.com

Cheers
mark

:clap:

Sorry for taking too long to reply, I had a busy weekend…

I asked about CDC because it seems that GHI implementation of CDC does not fully comply the USB CDC specification. Windows and Linux doesnt care about that and took the standard CDC driver.

Apple took the hard way of not allow anything that not satisfy the USB specs.

It seems there are a lot of CDC devices that dont work on OSX because of this…

I’ll try to get a better understanding to see if it can be fixed.

Mali,

Thanks for your suggestion, I will try it next time I’ll have time…

Sample was posted on tinyclr-code.
Have fun and let me know what you think. If you optimize it, and are able to share, I’d be very interested…

For me it was important to try this out so I can decide wether to use USB or rather use ethernet. Both have pros and cons - in my case, not requiring the end user to deal with IP configuration is a big pro.

The code is really sample quality. Ultimately I’d like to wrap it up into a generic, reusable “generic USB client controller”, written in Cocoa, supporting device plug/unplug notifications, background or blocking reads, etc.

But it’l take some time for me to pursue this, right now I’d rather get to know the FEZ better :slight_smile:

Cheers
mark