[Lazarus] How to list available serial orts on Ubuuntu?
Carlos E. R.
robin.listas at telefonica.net
Mon Nov 28 12:00:17 CET 2022
On 2022-11-28 11:31, Bo Berglund via lazarus wrote:
> 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.
...
>
> 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...
I think they are /dev/ttyS*, but also /dev/ttyUSB* or /dev/ttyACM*,
which is not all /dev/tty* :-D
>
> What can I do to get a selector for real serial ports on Ubuntu.
Maybe (googled for "name of serial port in linux"):
https://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/
What it says does not work in my machine (which has a true serial port)
dmesg | grep tty
because the log buffer has rotated out the boot section. But:
Telcontar:~ # zgrep -i 'ttyS' /var/log/messages-20221126.xz
<0.6> 2022-11-17T18:18:26.555284+01:00 Telcontar kernel - - - [
1.072472] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a
16550A
<0.6> 2022-11-19T11:58:45.529903+01:00 Telcontar kernel - - - [
1.082125] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a
16550A
Telcontar:~ #
But that is too complicated for your code, it is rather for a user to do
manually.
This other method works:
Telcontar:~ # setserial -g /dev/ttyS[0123]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
Telcontar:~ #
But it doesn't find *any* serial port. Not USB based ones unless you
tell it to check those. Maybe you better ask the user to name the port,
and you test to find out if it is true.
--
Cheers / Saludos,
Carlos E. R.
(from 15.3 x86_64 at Telcontar)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20221128/e2727450/attachment.sig>
More information about the lazarus
mailing list