synaser.pas - GetSerialPortNames (Linux) - repaired and compatible with Windows variant.

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@157 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2012-06-13 13:43:32 +00:00
parent b3ee5380c7
commit 09bac07010

View File

@ -1,9 +1,9 @@
{==============================================================================| {==============================================================================|
| Project : Ararat Synapse | 007.005.002 | | Project : Ararat Synapse | 007.005.003 |
|==============================================================================| |==============================================================================|
| Content: Serial port support | | Content: Serial port support |
|==============================================================================| |==============================================================================|
| Copyright (c)2001-2011, Lukas Gebauer | | Copyright (c)2001-2012, Lukas Gebauer |
| All rights reserved. | | All rights reserved. |
| | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. | | DAMAGE. |
|==============================================================================| |==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2001-2011. | | Portions created by Lukas Gebauer are Copyright (c)2001-2012. |
| All Rights Reserved. | | All Rights Reserved. |
|==============================================================================| |==============================================================================|
| Contributor(s): | | Contributor(s): |
@ -2309,30 +2309,21 @@ end;
{$IFNDEF MSWINDOWS} {$IFNDEF MSWINDOWS}
function GetSerialPortNames: string; function GetSerialPortNames: string;
var var
Index: Integer;
Data: string;
TmpPorts: String;
sr : TSearchRec; sr : TSearchRec;
begin begin
try Result := '';
TmpPorts := ''; if FindFirst('/dev/ttyS*', $FFFFFFFF, sr) = 0 then
if FindFirst('/dev/ttyS*', $FFFFFFFF, sr) = 0 then begin
begin repeat
repeat if (sr.Attr and $FFFFFFFF) = Sr.Attr then
if (sr.Attr and $FFFFFFFF) = Sr.Attr then begin
begin if Result <> '' then
data := sr.Name; Result := Result + ',';
index := length(data); Result := Result + sr.Name;
while (index > 1) and (data[index] <> '/') do end;
index := index - 1; until FindNext(sr) <> 0;
TmpPorts := TmpPorts + ' ' + copy(data, 1, index + 1);
end;
until FindNext(sr) <> 0;
end;
FindClose(sr);
finally
Result:=TmpPorts;
end; end;
FindClose(sr);
end; end;
{$ENDIF} {$ENDIF}