Re: [Lazarus] How to list available serial orts on Ubuuntu?
> My solution has been to scan all possible port names, such > as /dev/ttyS*, dev/ttyUSB*, /dev/ttyXR*, etc. and then attempt > to open each one by using SerOpen (in Serial.pp from fpcsrc- add > "Serial" the Uses clause) If successful the port exists, and I add > it to my list, if not, it doesn't exist. If the port is in use (already open in another process), you will get a SerOpen error and incorrectly exclude that port. Some other ways to find Linux serial ports are discussed here: https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
Inviato da iPhone > Il giorno 28 nov 2022, alle ore 17:00, Bo Berglund via lazarus > ha scritto: > > On Mon, 28 Nov 2022 14:48:20 +0100, Giuliano Colla via lazarus > wrote: > >> /dev/tty* is pretty much useless. It's there for historical reasons. >> /dev/ttyS* is the one for actual serial adapters, and, unless you >> override with a command line parameter on boot, it is limited to 0..3 in >> modern kernels. >> > Here is what I get on Ubuntu 20.04.5 LTS: > > $ ll /dev/ttyS* > crw-rw 1 root dialout 4, 64 2022-11-26 08:47 /dev/ttyS0 > crw-rw 1 root dialout 4, 65 2022-11-26 08:47 /dev/ttyS1 > crw-rw 1 root dialout 4, 74 2022-11-26 08:47 /dev/ttyS10 > crw-rw 1 root dialout 4, 75 2022-11-26 08:47 /dev/ttyS11 > crw-rw 1 root dialout 4, 76 2022-11-26 08:47 /dev/ttyS12 > crw-rw 1 root dialout 4, 77 2022-11-26 08:47 /dev/ttyS13 > crw-rw 1 root dialout 4, 78 2022-11-26 08:47 /dev/ttyS14 > crw-rw 1 root dialout 4, 79 2022-11-26 08:47 /dev/ttyS15 > crw-rw 1 root dialout 4, 80 2022-11-26 08:47 /dev/ttyS16 > crw-rw 1 root dialout 4, 81 2022-11-26 08:47 /dev/ttyS17 > crw-rw 1 root dialout 4, 82 2022-11-26 08:47 /dev/ttyS18 > crw-rw 1 root dialout 4, 83 2022-11-26 08:47 /dev/ttyS19 > crw-rw 1 root dialout 4, 66 2022-11-26 08:47 /dev/ttyS2 > crw-rw 1 root dialout 4, 84 2022-11-26 08:47 /dev/ttyS20 > crw-rw 1 root dialout 4, 85 2022-11-26 08:47 /dev/ttyS21 > crw-rw 1 root dialout 4, 86 2022-11-26 08:47 /dev/ttyS22 > crw-rw 1 root dialout 4, 87 2022-11-26 08:47 /dev/ttyS23 > crw-rw 1 root dialout 4, 88 2022-11-26 08:47 /dev/ttyS24 > crw-rw 1 root dialout 4, 89 2022-11-26 08:47 /dev/ttyS25 > crw-rw 1 root dialout 4, 90 2022-11-26 08:47 /dev/ttyS26 > crw-rw 1 root dialout 4, 91 2022-11-26 08:47 /dev/ttyS27 > crw-rw 1 root dialout 4, 92 2022-11-26 08:47 /dev/ttyS28 > crw-rw 1 root dialout 4, 93 2022-11-26 08:47 /dev/ttyS29 > crw-rw 1 root dialout 4, 67 2022-11-26 08:47 /dev/ttyS3 > crw-rw 1 root dialout 4, 94 2022-11-26 08:47 /dev/ttyS30 > crw-rw 1 root dialout 4, 95 2022-11-26 08:47 /dev/ttyS31 > crw-rw 1 root dialout 4, 68 2022-11-26 08:47 /dev/ttyS4 > crw-rw 1 root dialout 4, 69 2022-11-26 08:47 /dev/ttyS5 > crw-rw 1 root dialout 4, 70 2022-11-26 08:47 /dev/ttyS6 > crw-rw 1 root dialout 4, 71 2022-11-26 08:47 /dev/ttyS7 > crw-rw 1 root dialout 4, 72 2022-11-26 08:47 /dev/ttyS8 > crw-rw 1 root dialout 4, 73 2022-11-26 08:47 /dev/ttyS9 > > 32 in all... > > -- > Bo Berglund > Developer in Sweden > > -- > ___ > lazarus mailing list > lazarus@lists.lazarus-ide.org > https://lists.lazarus-ide.org/listinfo/lazarus Yes they’re there but they’re not enabled. If you search for ttyS* in the boot log you’ll see how many are probed for. Typically from ttyS0 to ttyS3. Maybe less, it depends on which ones are enabled in BIOS. I know because I had in a project an extra PCI board with four more ports, and I had to modify the boot parameters to have them properly initialized. Otherways they were completely non existing. Just a dummy entry in the /dev folder. -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
On Mon, 28 Nov 2022 14:48:20 +0100, Giuliano Colla via lazarus wrote: >/dev/tty* is pretty much useless. It's there for historical reasons. >/dev/ttyS* is the one for actual serial adapters, and, unless you >override with a command line parameter on boot, it is limited to 0..3 in >modern kernels. > Here is what I get on Ubuntu 20.04.5 LTS: $ ll /dev/ttyS* crw-rw 1 root dialout 4, 64 2022-11-26 08:47 /dev/ttyS0 crw-rw 1 root dialout 4, 65 2022-11-26 08:47 /dev/ttyS1 crw-rw 1 root dialout 4, 74 2022-11-26 08:47 /dev/ttyS10 crw-rw 1 root dialout 4, 75 2022-11-26 08:47 /dev/ttyS11 crw-rw 1 root dialout 4, 76 2022-11-26 08:47 /dev/ttyS12 crw-rw 1 root dialout 4, 77 2022-11-26 08:47 /dev/ttyS13 crw-rw 1 root dialout 4, 78 2022-11-26 08:47 /dev/ttyS14 crw-rw 1 root dialout 4, 79 2022-11-26 08:47 /dev/ttyS15 crw-rw 1 root dialout 4, 80 2022-11-26 08:47 /dev/ttyS16 crw-rw 1 root dialout 4, 81 2022-11-26 08:47 /dev/ttyS17 crw-rw 1 root dialout 4, 82 2022-11-26 08:47 /dev/ttyS18 crw-rw 1 root dialout 4, 83 2022-11-26 08:47 /dev/ttyS19 crw-rw 1 root dialout 4, 66 2022-11-26 08:47 /dev/ttyS2 crw-rw 1 root dialout 4, 84 2022-11-26 08:47 /dev/ttyS20 crw-rw 1 root dialout 4, 85 2022-11-26 08:47 /dev/ttyS21 crw-rw 1 root dialout 4, 86 2022-11-26 08:47 /dev/ttyS22 crw-rw 1 root dialout 4, 87 2022-11-26 08:47 /dev/ttyS23 crw-rw 1 root dialout 4, 88 2022-11-26 08:47 /dev/ttyS24 crw-rw 1 root dialout 4, 89 2022-11-26 08:47 /dev/ttyS25 crw-rw 1 root dialout 4, 90 2022-11-26 08:47 /dev/ttyS26 crw-rw 1 root dialout 4, 91 2022-11-26 08:47 /dev/ttyS27 crw-rw 1 root dialout 4, 92 2022-11-26 08:47 /dev/ttyS28 crw-rw 1 root dialout 4, 93 2022-11-26 08:47 /dev/ttyS29 crw-rw 1 root dialout 4, 67 2022-11-26 08:47 /dev/ttyS3 crw-rw 1 root dialout 4, 94 2022-11-26 08:47 /dev/ttyS30 crw-rw 1 root dialout 4, 95 2022-11-26 08:47 /dev/ttyS31 crw-rw 1 root dialout 4, 68 2022-11-26 08:47 /dev/ttyS4 crw-rw 1 root dialout 4, 69 2022-11-26 08:47 /dev/ttyS5 crw-rw 1 root dialout 4, 70 2022-11-26 08:47 /dev/ttyS6 crw-rw 1 root dialout 4, 71 2022-11-26 08:47 /dev/ttyS7 crw-rw 1 root dialout 4, 72 2022-11-26 08:47 /dev/ttyS8 crw-rw 1 root dialout 4, 73 2022-11-26 08:47 /dev/ttyS9 32 in all... -- Bo Berglund Developer in Sweden -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
On Mon, 28 Nov 2022 14:44:27 +0100, "Carlos E. R. via lazarus" wrote: >> I had thought of this but it looked like an overly complicated way given that >> the list of tty* ports using ls -l /dev/tty* on my system comprises no less >> than >> 98 hits > >Please see my post. It is not tty* OK, doing /dev/ttyS* reduces the hits to 32... -- Bo Berglund Developer in Sweden -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
Il 28/11/22 14:08, Bo Berglund via lazarus ha scritto: On Mon, 28 Nov 2022 13:31:12 +0100, Giuliano Colla via lazarus wrote: Hope that it helps, Thanks, it does. I had thought of this but it looked like an overly complicated way given that the list of tty* ports using ls -l /dev/tty* on my system comprises no less than 98 hits So I am now limiting the program to use USB connected serial adapters USB0..USB3 and on start I populate the list of ports by checking that /dev/USBx eists where x is 0..3. After all this is the most common use nowadays with USB serial devices in connection with developing IoT devices. /dev/tty* is pretty much useless. It's there for historical reasons. /dev/ttyS* is the one for actual serial adapters, and, unless you override with a command line parameter on boot, it is limited to 0..3 in modern kernels. Giuliano -- Do not do to others as you would have them do to you.They might have different tastes. -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
On 2022-11-28 14:08, Bo Berglund via lazarus wrote: On Mon, 28 Nov 2022 13:31:12 +0100, Giuliano Colla via lazarus wrote: Hope that it helps, Thanks, it does. I had thought of this but it looked like an overly complicated way given that the list of tty* ports using ls -l /dev/tty* on my system comprises no less than 98 hits Please see my post. It is not tty* -- Cheers / Saludos, Carlos E. R. (from 15.3 x86_64 at Telcontar) OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
On Mon, 28 Nov 2022 13:31:12 +0100, Giuliano Colla via lazarus wrote: >Hope that it helps, Thanks, it does. I had thought of this but it looked like an overly complicated way given that the list of tty* ports using ls -l /dev/tty* on my system comprises no less than 98 hits So I am now limiting the program to use USB connected serial adapters USB0..USB3 and on start I populate the list of ports by checking that /dev/USBx eists where x is 0..3. After all this is the most common use nowadays with USB serial devices in connection with developing IoT devices. -- Bo Berglund Developer in Sweden -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
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) OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] How to list available serial orts on Ubuuntu?
On Mon, Nov 28, 2022 at 12:31 PM Bo Berglund via lazarus < lazarus@lists.lazarus-ide.org> wrote: > > 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. > lazarus@lists.lazarus-ide.org > https://lists.lazarus-ide.org/listinfo/lazarus Here is an example for POSIX type OSs: https://github.com/ccrause/LazScope/blob/master/gui/serialobject.pas#L299 -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] How to list available serial orts on Ubuuntu?
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 -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus