[fpc-devel] [PATCH] unix/serial.pp mods for darwin

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Oct 1 20:52:21 CEST 2008

On 01 Oct 2008, at 20:18, Jonas Maebe wrote:

> On 01 Oct 2008, at 08:41, Brad Campbell wrote:
>> This is actually only required on 10.5 on Intel, but it does not  
>> seem to hurt on the other versions.
>> If left in place, this just blocks and stalls the program.
>> -
>>  tcflush(Handle, TCIOFLUSH);
>> -  tcsetattr(Handle, TCSANOW, tios)
>> +{$ENDIF}
>> +  tcsetattr(Handle, TCSANOW, tios);
>> end;
> How about using "TCSADRAIN or TCSAFLUSH" instead of TCSANOW? As far  
> as I can see, that should have the same effect as the  
> "tcflush(Handle, TCIOFLUSH)". Does that hang too?

I've found some other code for setting up a serial port on Darwin at http://www.nabble.com/Patch-for-controlling-Pioneer-via-a-Mac-td6672642.html

The full code is at http://playerstage.svn.sourceforge.net/viewvc/playerstage/code/player/trunk/server/drivers/mixed/p2os/p2os.cc?view=markup 
  (in method P2OS::Setup). Some observations:
* they use the cfsetispeed() and cfsetospeed() functions rather than  
directly writing in the fields. This should probably also be done at  
least for Darwin
* they also "or" the (CLOCAL | CREAD) flags into the c_flag field,  
rather just overwriting it (I guess cfsetispeed()/cfsetospeed() will  
make sure it's set appropriately)
* they also call tcflush() at the end

Since this project seems quite alive, I guess it works fine for them  
on Mac OS X/Intel, so there may be something else going wrong that  
requires you to clear the c_flags and remove the flush.


They also flush before calling tcsetattr, and they do not appear to be  
clearing term. c_cflag

More information about the fpc-devel mailing list