[fpc-devel] serial under linux, SerOpen blocks

Armin Diehl ad at ardiehl.de
Thu Aug 18 13:00:14 CEST 2011

Hi Marco,

minicom calls open with O_NONBLOCK and resets O_NONBLOCK directly after 
the open call:

open("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3
fcntl(3, F_GETFL)                       = 0x8802 (flags 
fcntl(3, F_SETFL, O_RDWR|O_LARGEFILE)   = 0

doing the same in serial.pp should not change the blocking behaviour of 

function SerOpen(const DeviceName: String): TSerialHandle;
   Result := fpopen(DeviceName, O_RDWR or O_NOCTTY or O_NONBLOCK);  // 
AD: O_NONBLOCK was missing
   if result > -1 then
     fpfcntl(Result,F_SETFL,O_RDWR or O_NOCTTY);                    
//AD: non blocking off again

On 08/18/2011 12:21 PM, Marco van de Voort wrote:
> In our previous episode, Armin Diehl said:
>> should that be changed in the standard serial.pp ?
> I'm not sure, since this leaves nonblocking behaviour on by default,
> moreover serial is pan unix, and non linuxes might react differently.
> Btw do you see minicom do a sequence of "opening in nonblock, setting params and
> reopening without nonblock" ?
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

More information about the fpc-devel mailing list