1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| procedure TThreadGPS.Execute;
begin
{$IFDEF WIN32}
PortCOM.Connect('COM21');
{$ENDIF}
{$IFDEF LINUX}
{$IFDEF CPUARM}
PortCOM.Connect('/dev/rfcomm0');
{$ELSE}
PortCOM.Connect('/dev/ttyS21');
{$ENDIF}
{$ENDIF}
tcs.Enter;
Reprendre:= False;
PortCOM.Config(4800, 8, 'N', 1, False, False);
while (not Terminated) and (not Reprendre) do
begin
InfoNMEA:= PortCOM.Recvstring(2000);
if InfoNMEA <> '' then
Synchronize(@Showstatus);
if PortCOM.LastError = ErrTimeout then // sur cette erreur, je vis me déconnecter puis me reconnecter
begin
PortCOM.Purge;
Reprendre:= True;
Inc(Pb); // Nombre de fois où apparaît le problème -> transmis au thread principal par "synchronise"
end;
end;
tcs.Leave;
PortCOM.CloseSocket; // Déconnexion
if Reprendre then
Execute // Reprise de la connexion
else
FreeAndNil(PortCOM);
end; |
Partager