[fpc-pascal] The fpOpen call on a serial port blocks on a Mac. Why?

Bruce Tulloch bruce at causal.com
Thu Aug 11 06:00:44 CEST 2011


I am using the latest synaser (007.005.002) from the synapse library
which works just fine with (USB) serial ports on Linux and Windows but
Mac OSX 10.6 it is proving problematic.

The call which opens the port (synaser.pas:946) is:

  FHandle := THandle(fpOpen(FDevice, O_RDWR or O_SYNC));

where in my case, FDevice is /dev/tty.usbserial.DCUIYCH4.

This fpOpen call blocks indefinitely (i.e. it never returns).

The device is present, working and requires no flow control:

My-Mac:~ admin$ stty -f /dev/tty.usbserial-DCUIYCH4 -a
speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
	-echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
	-nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
	-ignbrk -brkint -inpck -ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts
        -dsrflow -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
	eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
	min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
	stop = ^S; susp = ^Z; time = 0; werase = ^W;

and the screen command opens and communicates via this port just fine so
I don't believe there is anything wrong with the device, the driver or
the state of any port flags when fpOpen is attempted.

Can anyone tell me what I might be doing wrong here?

Note that adding the O_NONBLOCK flag allows the fpOpen to succeed but
all subsequent attempts to talk to the port return ENOTTY which is of
course wrong as it is a real (USB) serial (TTY) device.

I'm building with FPC 2.4.2 binaries and sources (for Mac) and it's an
FTDI serial device I'm dealing with. Any and all advice most welcome.

Cheers, Bruce.



More information about the fpc-pascal mailing list