mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 17:27:32 +00:00
fix build on windows
This commit is contained in:
+20
-6
@@ -21,9 +21,10 @@ unit CATSerial;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, SyncObjs,
|
||||
Classes, SysUtils,
|
||||
Serial, // FPC cross-platform serial unit
|
||||
{$IFDEF MSWINDOWS}Windows,{$ENDIF}
|
||||
SyncObjs,
|
||||
CATEngine;
|
||||
|
||||
const
|
||||
@@ -120,10 +121,10 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
case cfg.Parity of
|
||||
cspNone: par := NoneParity;
|
||||
cspOdd: par := OddParity;
|
||||
cspEven: par := EvenParity;
|
||||
else par := NoneParity;
|
||||
cspNone: par := Serial.NoneParity;
|
||||
cspOdd: par := Serial.OddParity;
|
||||
cspEven: par := Serial.EvenParity;
|
||||
else par := Serial.NoneParity;
|
||||
end;
|
||||
|
||||
SerSetParams(h, cfg.BaudRate, cfg.DataBits, par, cfg.StopBits, []);
|
||||
@@ -166,7 +167,11 @@ begin
|
||||
end;
|
||||
finally
|
||||
SerClose(FHandle);
|
||||
{$IFDEF MSWINDOWS}
|
||||
FOwner.Handle := INVALID_HANDLE_VALUE;
|
||||
{$ELSE}
|
||||
FOwner.Handle := -1;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -177,7 +182,11 @@ begin
|
||||
inherited Create;
|
||||
FEngine := AEngine;
|
||||
FConfig := ACfg;
|
||||
{$IFDEF MSWINDOWS}
|
||||
FHandle := INVALID_HANDLE_VALUE;
|
||||
{$ELSE}
|
||||
FHandle := -1;
|
||||
{$ENDIF}
|
||||
FLock := TCriticalSection.Create;
|
||||
FActive := False;
|
||||
end;
|
||||
@@ -211,11 +220,16 @@ end;
|
||||
procedure TCATSerialPort.SendStr(const S: string);
|
||||
var buf: AnsiString;
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
if FHandle = INVALID_HANDLE_VALUE then Exit;
|
||||
{$ELSE}
|
||||
if FHandle < 0 then Exit;
|
||||
{$ENDIF}
|
||||
FLock.Acquire;
|
||||
try
|
||||
buf := AnsiString(S);
|
||||
SerWrite(FHandle, buf[1], Length(buf));
|
||||
if Length(buf) > 0 then
|
||||
SerWrite(FHandle, buf[1], Length(buf));
|
||||
except
|
||||
// ignore write errors (port may have been closed)
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user