Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, have you checked if you can borrow a solution from <a href="https://github.com/clokey/PublicCode/tree/master/MacOSXVirtualSerialPort" rel="nofollow">this app?</a> It's not obvious from the website if they've managed to get their virtual serial ports fully integrated into the system.</p> <p>If there is a way to do it from user space, I'm not aware of it. The user-space IOKit API generally doesn't let you create class instances, let alone new device driver classes. Maybe you can somehow otherwise persuade the Cocoa libraries to find it despite not being registered in the kernel.</p> <p>I don't know if you could get away with creating a "dummy" serial port in the kernel and then move your tty into its place in /dev from your userspace daemon. Maybe that's an option.</p> <p><strong>In case you do have to do it all in the kernel:</strong></p> <p>The virtual driver itself shouldn't be <em>too</em> much work, at least, though it will require some time to get up to speed with kernel dev. Unfortunately, the documentation is pretty thin for serial port drivers - the key is subclassing the <code>IOSerialDriverSync</code> abstract class. Just about the only description I've seen is in Ole Henry Halvorsen's <em>OSX and iOS Kernel Programming</em> book. It also has a fragment of an example for the reading &amp; writing operations. (<strong>disclosure:</strong> I was one of the tech reviewers for this book; I don't receive any incentives for recommending it - in this case it's literally the only documentation I know of) You can find the source for a complete serial port driver in <a href="http://opensource.apple.com/source/AppleUSBCDCDriver/AppleUSBCDCDriver-4115.4.1/AppleUSBCDCDMM/" rel="nofollow">Apple's USBCDC driver</a>, <code>AppleUSBCDCDMM</code> is the class that actually represents the serial port node.</p> <p>It's relatively straightforward to open a so-called <a href="http://developer.apple.com/documentation/Darwin/Conceptual/NKEConceptual/control/control.html" rel="nofollow">"kernel control"</a> socket in the kernel, the individual APIs are <a href="http://developer.apple.com/documentation/Darwin/Reference/KernelIOKitFramework/kern_control_h/index.html" rel="nofollow">documented here</a>; from user space you use the normal BSD socket <code>send</code>/<code>recv</code> APIs. (this is also described in the aforementioned book) Your daemon can then connect to that, and all you'd need to do is push the data between the socket and the virtual serial port device. You'll need to handle disconnect events and such correctly of course.</p> <p>Still, I think this is achievable as a first kernel project for an experienced C programmer (with some C++).</p> <p>I hope that helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload