* How to get a list of all available serial ports?
@ 2004-08-26 7:24 Francisco M. Marzoa Alonso
2004-08-26 10:51 ` Jan-Benedict Glaw
2004-08-26 10:52 ` Salomon, Frank
0 siblings, 2 replies; 4+ messages in thread
From: Francisco M. Marzoa Alonso @ 2004-08-26 7:24 UTC (permalink / raw)
To: linux-serial
Hi,
Under Windows my program is able to perform an autodetection of the device
with which it work. For that it takes a list of all available serial ports
from Windows registry.
Is there any manner to do the same under LiNUX that works on all
distributions?
Thx.
--
Francisco M. Marzoa Alonso
Responsable de Software - Softrónica S.A.
http://www.softronica.org/
C/Herrerías, 14 - 28760 Tres Cantos (Madrid)
tfno. +34 918 038 600 fax. +34 918 032 297
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get a list of all available serial ports?
2004-08-26 7:24 How to get a list of all available serial ports? Francisco M. Marzoa Alonso
@ 2004-08-26 10:51 ` Jan-Benedict Glaw
2004-08-26 10:52 ` Salomon, Frank
1 sibling, 0 replies; 4+ messages in thread
From: Jan-Benedict Glaw @ 2004-08-26 10:51 UTC (permalink / raw)
To: linux-serial
[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]
On Thu, 2004-08-26 09:24:02 +0200, Francisco M. Marzoa Alonso <fmmarzoa@softronica.org>
wrote in message <200408260924.02123.fmmarzoa@softronica.org>:
> Under Windows my program is able to perform an autodetection of the device
> with which it work. For that it takes a list of all available serial ports
> from Windows registry.
>
> Is there any manner to do the same under LiNUX that works on all
> distributions?
There are several solutions:
- opendir()/readdir()/closedir() "/dev/" and strncmp(ent->d_name, "ttyS", 4),
then open all matches with O_NONBLOCK to see if you not get ENODEV
from errno. This works on "traditional" systems not using something
like devfs. Also, you'd better stat() all hits to not get false
positives from things like symlinks.
- opendir/readdir/closedir "/dev/ttyS/" and iterate through all entries.
These are solely serial ports, so not that much postprocessing
involved. However, that would only work with devfs...
- open /proc/tty/driver/serial, check the format (first line), read all
further lines and check if uart is != "unknown".
For sure, there are more techniques, like
- if you're runnung with root privileges, you'd temporarily
create new device nodes for char devices, and mojor/minor
number from /proc/tty/drivers (the "^serial" lines).
- check major/minor from /sys/class/tty/ttyS* (open() checking
for ENODEV in errno...), but that'd require creating temporary
device nodes and also having a 2.6.x kernel...
Personally, I don't like software that tries to "know better" than I do.
I'd like telling a program "use this device node and shut up!" and
possibly others would like to have it work that way, too...
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get a list of all available serial ports?
2004-08-26 7:24 How to get a list of all available serial ports? Francisco M. Marzoa Alonso
2004-08-26 10:51 ` Jan-Benedict Glaw
@ 2004-08-26 10:52 ` Salomon, Frank
2004-08-26 12:09 ` Jan-Benedict Glaw
1 sibling, 1 reply; 4+ messages in thread
From: Salomon, Frank @ 2004-08-26 10:52 UTC (permalink / raw)
To: linux-serial
> Under Windows my program is able to perform an autodetection of the device
> with which it work. For that it takes a list of all available serial ports
> from Windows registry.
>
> Is there any manner to do the same under LiNUX that works on all
> distributions?
hi,
cat /proc/ioports and serach serial
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc
0080-008f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : fpu
02f8-02ff : serial(auto)
0340-0340 : HiSax hscx A fifo
03c0-03df : vga+
03f8-03ff : serial(auto)
0740-075f : HiSax hscx A
0b40-0b40 : HiSax hscx B fifo
0cf8-0cff : PCI conf1
0f40-0f5f : HiSax hscx B
1340-1340 : HiSax isac fifo
1740-175f : HiSax isac
1b40-1b47 : avm cfg
e800-e8ff : Adaptec AHA-2940U2/W
f0a0-f0bf : Intel Corp. 82371AB PIIX4 ACPI
f0c0-f0ff : Intel Corp. 82371AB PIIX4 ACPI
f400-f43f : Intel Corp. 82557 [Ethernet Pro 100]
f400-f43f : eepro100
f800-f81f : Intel Corp. 82371AB PIIX4 USB
f800-f81f : usb-uhci
fcf0-fcff : Intel Corp. 82371AB PIIX4 IDE
fcf0-fcf7 : ide0
fcf8-fcff : ide1
or cat /proc/tty/driver/serial
serinfo:1.0 driver:5.05c revision:2001-07-08
0: uart:16550A port:3F8 irq:4 baud:9600 tx:11 rx:0
1: uart:16550A port:2F8 irq:3 baud:9600 tx:11 rx:0
Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get a list of all available serial ports?
2004-08-26 10:52 ` Salomon, Frank
@ 2004-08-26 12:09 ` Jan-Benedict Glaw
0 siblings, 0 replies; 4+ messages in thread
From: Jan-Benedict Glaw @ 2004-08-26 12:09 UTC (permalink / raw)
To: linux-serial
[-- Attachment #1: Type: text/plain, Size: 1498 bytes --]
On Thu, 2004-08-26 12:52:27 +0200, Salomon, Frank <frank.salomon@wincor-nixdorf.com>
wrote in message <412DC0EB.1090605@wincor-nixdorf.com>:
> hi,
>
> cat /proc/ioports and serach serial
>
[...]
> 02f8-02ff : serial(auto)
[...]
> 03f8-03ff : serial(auto)
That's *very* unreliable. There are a lot of UARTs that handle more than
one serial port within one I/O space or PCI bar, so you'd "miss" those.
To be honest, I think that quite a lot of the non-8250 UARTs will
actually handle more than one serial port...
> or cat /proc/tty/driver/serial
>
> serinfo:1.0 driver:5.05c revision:2001-07-08
> 0: uart:16550A port:3F8 irq:4 baud:9600 tx:11 rx:0
> 1: uart:16550A port:2F8 irq:3 baud:9600 tx:11 rx:0
I actually think that this is one of the mest methods to find out about
serial ports from userspace (among letting the user specify the correct
device node for it:-) Also (just as a hint), don't really worry about
I/O address, uart type (as long as it isn't "unknown") or IRQ. It's
somewhat architecture dependant (eg. Sparc64 used to show off vector
addresses instead of IRQ numbers, so you'd see an address instead...).
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-26 12:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-26 7:24 How to get a list of all available serial ports? Francisco M. Marzoa Alonso
2004-08-26 10:51 ` Jan-Benedict Glaw
2004-08-26 10:52 ` Salomon, Frank
2004-08-26 12:09 ` Jan-Benedict Glaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox