mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-26 20:57:32 +00:00
fix build on windows
This commit is contained in:
+19
-5
@@ -21,9 +21,10 @@ unit CATSerial;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, SyncObjs,
|
Classes, SysUtils,
|
||||||
Serial, // FPC cross-platform serial unit
|
Serial, // FPC cross-platform serial unit
|
||||||
{$IFDEF MSWINDOWS}Windows,{$ENDIF}
|
{$IFDEF MSWINDOWS}Windows,{$ENDIF}
|
||||||
|
SyncObjs,
|
||||||
CATEngine;
|
CATEngine;
|
||||||
|
|
||||||
const
|
const
|
||||||
@@ -120,10 +121,10 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
case cfg.Parity of
|
case cfg.Parity of
|
||||||
cspNone: par := NoneParity;
|
cspNone: par := Serial.NoneParity;
|
||||||
cspOdd: par := OddParity;
|
cspOdd: par := Serial.OddParity;
|
||||||
cspEven: par := EvenParity;
|
cspEven: par := Serial.EvenParity;
|
||||||
else par := NoneParity;
|
else par := Serial.NoneParity;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SerSetParams(h, cfg.BaudRate, cfg.DataBits, par, cfg.StopBits, []);
|
SerSetParams(h, cfg.BaudRate, cfg.DataBits, par, cfg.StopBits, []);
|
||||||
@@ -166,7 +167,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SerClose(FHandle);
|
SerClose(FHandle);
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
FOwner.Handle := INVALID_HANDLE_VALUE;
|
||||||
|
{$ELSE}
|
||||||
FOwner.Handle := -1;
|
FOwner.Handle := -1;
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -177,7 +182,11 @@ begin
|
|||||||
inherited Create;
|
inherited Create;
|
||||||
FEngine := AEngine;
|
FEngine := AEngine;
|
||||||
FConfig := ACfg;
|
FConfig := ACfg;
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
FHandle := INVALID_HANDLE_VALUE;
|
||||||
|
{$ELSE}
|
||||||
FHandle := -1;
|
FHandle := -1;
|
||||||
|
{$ENDIF}
|
||||||
FLock := TCriticalSection.Create;
|
FLock := TCriticalSection.Create;
|
||||||
FActive := False;
|
FActive := False;
|
||||||
end;
|
end;
|
||||||
@@ -211,10 +220,15 @@ end;
|
|||||||
procedure TCATSerialPort.SendStr(const S: string);
|
procedure TCATSerialPort.SendStr(const S: string);
|
||||||
var buf: AnsiString;
|
var buf: AnsiString;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
if FHandle = INVALID_HANDLE_VALUE then Exit;
|
||||||
|
{$ELSE}
|
||||||
if FHandle < 0 then Exit;
|
if FHandle < 0 then Exit;
|
||||||
|
{$ENDIF}
|
||||||
FLock.Acquire;
|
FLock.Acquire;
|
||||||
try
|
try
|
||||||
buf := AnsiString(S);
|
buf := AnsiString(S);
|
||||||
|
if Length(buf) > 0 then
|
||||||
SerWrite(FHandle, buf[1], Length(buf));
|
SerWrite(FHandle, buf[1], Length(buf));
|
||||||
except
|
except
|
||||||
// ignore write errors (port may have been closed)
|
// ignore write errors (port may have been closed)
|
||||||
|
|||||||
+9
-8
@@ -20,13 +20,14 @@ unit CATTcp;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, SyncObjs,
|
Classes, SysUtils,
|
||||||
WebUtils, // SockClose, SockShutdown, SOCK_INVALID
|
WebUtils, // SockClose, SockShutdown, SOCK_INVALID
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
Windows, WinSock2
|
Windows, WinSock2,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
BaseUnix, Sockets
|
BaseUnix, Sockets,
|
||||||
{$ENDIF},
|
{$ENDIF}
|
||||||
|
SyncObjs,
|
||||||
CATEngine;
|
CATEngine;
|
||||||
|
|
||||||
const
|
const
|
||||||
@@ -252,22 +253,22 @@ end;
|
|||||||
procedure TCATTcpClientThread.SendData(const Msg: string; const IdLimit: TStringList);
|
procedure TCATTcpClientThread.SendData(const Msg: string; const IdLimit: TStringList);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
send: Boolean;
|
doSend: Boolean;
|
||||||
begin
|
begin
|
||||||
if IdLimit = nil then begin
|
if IdLimit = nil then begin
|
||||||
SendStr(Msg);
|
SendStr(Msg);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
send := False;
|
doSend := False;
|
||||||
FIdLock.Acquire;
|
FIdLock.Acquire;
|
||||||
try
|
try
|
||||||
for i := 0 to FClientIds.Count-1 do
|
for i := 0 to FClientIds.Count-1 do
|
||||||
if IdLimit.IndexOf(FClientIds[i]) >= 0 then begin
|
if IdLimit.IndexOf(FClientIds[i]) >= 0 then begin
|
||||||
send := True;
|
doSend := True;
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
finally FIdLock.Release; end;
|
finally FIdLock.Release; end;
|
||||||
if send then SendStr(Msg);
|
if doSend then SendStr(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCATTcpClientThread.IsMarkedForDelete: Boolean;
|
function TCATTcpClientThread.IsMarkedForDelete: Boolean;
|
||||||
|
|||||||
+2
-1
@@ -30,7 +30,8 @@ uses
|
|||||||
Settings,
|
Settings,
|
||||||
WebServer,
|
WebServer,
|
||||||
CATEngine, CATSerial, CATTcp,
|
CATEngine, CATSerial, CATTcp,
|
||||||
SpectrumView;
|
SpectrumView,
|
||||||
|
WinFirewall;
|
||||||
|
|
||||||
const
|
const
|
||||||
CLR_BG = TColor($00101010);
|
CLR_BG = TColor($00101010);
|
||||||
|
|||||||
Reference in New Issue
Block a user