[fpc-pascal] Non-standard baud rates in OS X | IOSSIOSPEED IOCTL

2011-08-14 Thread Bruce Tulloch
Apple have define an IOCTL (since Tiger) called IOSSIOSPEED which
facilitates non-standard baud rates.

They publish a C example which explains it:

http://developer.apple.com/library/mac/#samplecode/SerialPortSample/Introduction/Intro.html

Attached is a patch for FPC's darwin RTL which adds this IOCTL.

I think it's correct (i.e. it evaluates to the same value, 0x80045402,
as some C I threw together using Apple's headers, see attached).

I've appended this definition in termios.inc as this seems the most
appropriate place for it. Jonas?

Cheers, Bruce.
*** a/rtl/darwin/termios.inc	Mon Aug 15 15:05:10 2011
--- b/rtl/darwin/termios.inc	Mon Aug 15 15:05:10 2011
***
*** 601,605 
--- 601,609 
FIOGETOWN = (IOC_OUT or (sizeof(cint) and IOCPARM_MASK) << 16) or ((ord('f') << 8) or 123);
FIODTYPE = (IOC_OUT or (sizeof(cint) and IOCPARM_MASK) << 16) or ((ord('f') << 8) or 122);
  
+ // from /System/Library/Frameworks/IOKit.framework/Versions/A/Headers/serial/ioss.h
+ 
+   FIOSSIOSPEED = (IOC_IN or (sizeof(culong) and IOCPARM_MASK) << 16) or ((ord('T') << 8) or 2);
+ 
  {$endif}
  
#include 
 
#define	IOCPARM_MASK	0x1fff		/* parameter length, at most 13 bits */
#define	IOC_IN		(unsigned long)0x8000

#define	_IOC(inout,group,num,len) \
	(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
#define	_IOW(g,n,t)	_IOC(IOC_IN,	(g), (n), sizeof(t))

#define IOSSIOSPEED_IOW('T', 2, speed_t)

typedef unsigned long	speed_t;

int main()
{
	printf("IOSSIOSPEED = 0x%x\n",IOSSIOSPEED);
	return 0;
}
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Non-standard baud rates in OS X | IOSSIOSPEED IOCTL

2011-08-14 Thread Bruce Tulloch
I can now confirm that the ioctl definition I used is correct, tested on
a Snow Leopard system with an FT232RL chip USB/Serial chip.

Cheers, Bruce.

On 08/15/11 15:23, Bruce Tulloch wrote:
> Apple have define an IOCTL (since Tiger) called IOSSIOSPEED which
> facilitates non-standard baud rates.
> 
> They publish a C example which explains it:
> 
> http://developer.apple.com/library/mac/#samplecode/SerialPortSample/Introduction/Intro.html
> 
> Attached is a patch for FPC's darwin RTL which adds this IOCTL.
> 
> I think it's correct (i.e. it evaluates to the same value, 0x80045402,
> as some C I threw together using Apple's headers, see attached).
> 
> I've appended this definition in termios.inc as this seems the most
> appropriate place for it. Jonas?
> 
> Cheers, Bruce.
> 
> 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal