Configuring the serial port
Configuring the serial port
- Subject: Configuring the serial port
- From: Jens Bauer <email@hidden>
- Date: Tue, 2 Jul 2002 02:37:31 +0200
Hi all,
On the page...
<
http://developer.apple.com/techpubs/mac/Devices/Devices-325.html>
...I find the following text...
"Set Baud Rate [control code 13]
csCode = 13 csParam = word
This control routine provides an additional method (besides the SerReset
function) of setting the baud rate. You specify the baud rate value as an
integer in the csParam field (for example, 9600). The Serial Driver
attempts to set the serial port to the specified baud rate, or the
closest baud rate supported by the hardware. The actual baud rate
selected is returned in the csParam field."
I found out that I should use OpenPort, Control and ClosePort in the
header file Devices.h.
Reading the last sentence of the above quote, it says that the actual
baud rate is returned in the csParam field.
I can't get that to happen. Here's my test-code:
{
OSErr err;
short refNum;
UInt16 rate;
/* {snip} */
rate = 9601;
err = OpenDriver("\p.aOut", &refNum);
if(noErr == err)
{
err = Control(refNum, kSERDBaudRate, (void *) &rate);
printf("output port baudrate change returned: %d\n", err);
if(noErr == err)
{
printf("Baudrate chosen: %d", rate); /* always shows the
'requested' baudrate */
}
CloseDriver(refNum);
}
}
I'd expect giving a baudrate such as 299 or 9601 would "snap" it to 300
or 9600, am I wrong here ? :)
(Bonus question: Something I've often wondered about.. Since you can now
supply the integer value of the baudrate you want, why isn't this at
least 32bit, so we could avoid kSERD115KBaud and kSERD230KBaud ?)
Love,
Jens
--
I've developed software that changed the history, but that does not
entitle me to rule the World.
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.