Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Serial family IOkit questions



I have some questions regarding the I/O kit Serial family.

I wanted to port some OBD-II (automotive on-board diagnostic) software to my powerbook using a Keystone USB to serial adapter connected to a protocol converter.
One thing this software will have to do is switch between non-standard baud rates, specifically 5 baud and 10400 baud.

POSIX doesn't state what happens when you request a non-POSIX defined baud rate using cfsetspeed(). In both FreeBSD and Darwin, the symbolic defines match the actual speed, i.e., B9600 == 9600. FreeBSD returns an error only if it can't provide a baud rate that matches the requested baud rate within 3%.

In Darwin, IOSerialBSDClient.cpp will permit a baud rate only if it is defined in an internal table, and also only if the user-requested input and output speed match.

That's just the first part, though, if it isn't in the table, or the input and output speeds differ, and the requested TERMIOS output speed is odd, then it treats this not as a baud rate request, but as a change for an externally clocked MIDI device. Huh?

The first thing I observe is I can posixly legally write a program to set the input speed to 9600 and the output speed to 75 and go off on a weird code branch. Yes, no one is likely to need to do that in real life, but where's this MIDI stuff documented? Did they REALLY mean c_ospeed odd? There is a doubling of the baud rate before passing it down, it would make some sense if that is the special odd thing.

The second thing I observe is that this locks out the clean FreeBSD behavior, which is too bad. You can only support non-standard baudrates by modifying the table (and being sure to have the input speed and output speed the same, or all bets are off), or by adding strange non-standard extensions as in Linux.

Finally, going further, when I look at the sample serial drivers I can find, I see that they assert that the baud rate must be greater than 50 baud, and they reject lower settings. I don't have the source for the Keystone driver, but if they were following the examples they probably would have done the same thing. Is there a reason for this assertion? Granted, "0" is special, but it must be handled that way now.

Peter

Peter Dufault
HD Associates, Inc.
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.