[Lazarus] How to list available serial orts on Ubuuntu?
Bo Berglund
bo.berglund at gmail.com
Mon Nov 28 11:31:30 CET 2022
I haved a debugging tool program created on Windows and I am orting it to Linux
Ubuntu.
It seems to build just fine except for a combobox fill function which uses the
Windows way of populating the selectoer box with the serial ports available on
the system.
This is the code I use on Windows:
function THanSimulatorMain.ListSerialPorts(LS: TStrings): integer;
var
I:integer;
{$ifdef MSWINDOWS}
Reg:tregistry;
{$endif}
begin
{$ifdef MSWINDOWS}
//List available serial ports on Windows:
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly('HARDWARE\DEVICEMAP\SERIALCOMM') then
begin
LS.Clear;
Reg.GetValueNames(LS);
for I := 0 to LS.Count - 1 do
LS[i] := Reg.ReadString(LS[i]);
end;
Result := LS.Count;
finally
Reg.Free;
end;
{$endif}
{$ifdef UNIX}
//List available serial ports on Linux:
//What do I put here?
{$endif}
end;
I have looked at /dev/tty* but it lists a large number of items which makes it
impossible for me. I do not belive all of´them are real serial ports...
What can I do to get a selector for real serial ports on Ubuntu.
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list