tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Detecting available ports



On Tue, Oct 20, 2009 at 12:59:17AM -0400, Jacques Pelletier wrote:

> In Linux, there´s a way to scan the /proc or /sys directories for getting the 
> available serial ports. I would like to do the same on NetBSD. How can it be 
> done?

Quick hack:

grep ^com /var/run/dmesg.boot > thelist
grep ^ucom /var/run/dmesg.boot >> thelist

should be enough for PC hardware. comN is accessible as /dev/ttyNN,
ucomN as /dev/ttyUNN, iirc.

To do it right:

We don't have a generic solution - would need to keep a list at
serial device attach/detach time, which shows up as a sysctl node
like the disk list (sysctl hw.disknames). Just a simple matter of
kernel programming. Translating to /dev/ nodes is a bit more
difficult, as in principle, the mapping is arbitrary, but the
standard names on a given platform are known. 

For discussing the kernel programming part, tech-kern is more 
appropriate.

        -is

Attachment: pgpUc0CF59Vtm.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index