hello,
strange, because the
close procedure of
TLazserial is :
procedure TLazSerial.Close;
begin
Active:=false;
end;
i have no problem to open and close port with the
sertest example of
TLazserial on Ubuntu 14.04 LTS 64 bits Lazarus 1.6 FPC 1.3. Have you the problem with this example ?
What are you doing in your program ?
Have you tried the flush and purge methods before closing the port ? :
procedure Flush; virtual;
Waits until all data to is sent and buffers are emptied. Warning: On Windows systems is this method returns when all buffers are flushed to the serial port controller, before the last byte is sent!
===========================================================
Public procedure Purge; virtual;
Unconditionally empty all buffers. It is good when you need to interrupt communication and for cleanups.
flush is used in the deviceclose procedure (called when you put active to false ) :
procedure TLazSerial.DeviceClose;
begin
// flush device
if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
FSynSer.Flush;
FSynSer.CloseSocket;
// FSynSer.Purge;
end;
// stop capture thread
if ReadThread<>nil then begin
ReadThread.FreeOnTerminate:=false;
ReadThread.MustDie:= true;
while not ReadThread.Terminated do begin
Application.ProcessMessages;
end;
ReadThread.Free;
ReadThread:=nil;
end;
// close device
if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
FSynSer.Flush;
FSynSer.CloseSocket;
end;
end;
Friendly, J.P
Edit : TlazSerial is now in Github
here with a 0.2 version :
V 0.2 01/2017 : BaudRates for UNIX fixed - synaser files units renamed (with laz prefix) to avoid conflict with the original synaser files.
scan port for linux improved