On 31 Oct 2012, at 13:29, Giuliano Colla wrote:

In Linux environment the following code:

 try
   USBOut := FileOpen(UsbDev,fmOpenWrite);
 except
   result := True;
 end;

is used in a Lazarus application to get a handle to write to an USB device, and did work fine in fpc 2.4.

I migrated the application to Lazarus 1.0 wich uses fpc 2.6, and it stopped working. FileOpen returns -1, without rising an exception, which made me struggle to find out what was happening.

FPC 2.6 added support for file locking on Unix platforms. You probably should use

  USBOut := FileOpen(UsbDev,fmOpenWrite or fmShareDenyNone);

Otherwise FileOpen will try to get an exclusive (write) lock on that device, which may well not be possible.

Moreover I don't understand why the call returns a -1, meaning that the Open failed, without rising an exception.

Does FileOpen raise an exception in Delphi when locking fails?


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to