The GetSerialPortNames function does not work properly as is.
Here is what works for Linux, and possibly some of the other unix
flavours should work too if the device string is correct:
{$IFDEF UNIX}
// Only linux tested
{$IfDef Linux}
const SerialDeviceString = '/dev/ttyS*';
{$EndIf} // Linux
{$IfDef Darwin} // Mac OSX, completely untested!
const SerialDeviceString = '/dev/cu.*';
{$EndIf} // Darwin
{$IfDef BSD} // BSD, completely untested! FreeBSD is /dev/cuad* ,
Solaris might be /dev/cu/*
const SerialDeviceString = '/dev/cua*';
{$EndIf} // BSD
function GetSerialPortNames: string;
var
Index: Integer;
Port: string;
PortList: TStringList;
sr : TSearchRec;
begin
PortList:= TStringList.Create;
try
if FindFirst(SerialDeviceString, faAnyFile, sr) = 0 then
begin
repeat
if (sr.Attr and $FFFFFFFF) = Sr.Attr then
begin
Port:= '/dev/'+ExtractFileName(sr.Name);
PortList.Add(Port);
end;
until FindNext(sr) <> 0;
end;
FindClose(sr);
{$IfDef Linux}
// Also add USB serial adaptors
if FindFirst('/dev/ttyUSB*', faAnyFile, sr) = 0 then
begin
repeat
if (sr.Attr and $FFFFFFFF) = Sr.Attr then
begin
Port:= '/dev/'+ExtractFileName(sr.Name);
PortList.Add(Port);
end;
until FindNext(sr) <> 0;
end;
FindClose(sr);
{$EndIf} // Linux
finally
PortList.Sort;
Result:= PortList.CommaText;
PortList.Free;
end;
end;
{$ENDIF} // Unix
Regards,
John Morris.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public