/dev/ttyd0 as an Input Device Works on some Systems but not others.

Martin McCormick martin at dc.cis.okstate.edu
Thu Feb 3 08:27:01 PST 2005

	I wrote a C program that opens /dev/ttyd0 for reading data
from an external device.  I had beginner's luck because it worked in
Linux (actually that device is called /dev/ttyS0) and on the first
FreeBSD box I tried it as /dev/ttyd0.  The /etc/ttys file had
/dev/ttyd0 set to off so there was no login banner and that system has
been reading telephone switch logging data 24/7 for over 600 days.

	I then tried two different FreeBSD servers, each one with 2
serial ports and that's where I ran in to trouble.  Here is what I

	On systems like the one that is working, a test command like

echo "hello" >/dev/ttyd0 

works fine even if nothing is connected to the serial port.  The port
can be opened with /dev/ttyd0 as a file descripter and read
indefinitely as long as an EOF char isn't received.

	On the two-port systems I have had trouble with, echoing
anything to /dev/ttyd0 causes a total hang of that command that one
can't break with anything short of a reboot.

	I have actually tried two single-port FreeBSD systems and both could read
from ttyd0 and echoing output to ttyd0 worked as described.  One of
the systems is the one that has been up for 600 odd days.

	The BIOS settings on the two-port systems that won't work this
way indicate that the port is on.  The other choices are Auto and Off.

	Any ideas as to the reason for the differences and how I can
make /dev/ttyd0 work the same way every time?

	The dmesg output describing the serial ports from one of the
2-port systems reads as follows:

sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A

	Any suggestions are appreciated.

Martin McCormick WB5AGZ  Stillwater, OK 
OSU Information Technology Division Network Operations Group

More information about the freebsd-questions mailing list