Serial Communications

This section answers common questions about serial communications with FreeBSD. PPP and SLIP are covered in the section. How do I tell if FreeBSD found my serial ports?

As the FreeBSD kernel boots, it will probe for the serial ports in your system for which the kernel was configured. You can either watch your system closely for the messages it prints or run the command dmesg | grep sio

after your system's up and running.

Here's some example output from the above command: sio0 at 0x3f8-0x3ff irq 4 on isa sio0: type 16550A sio1 at 0x2f8-0x2ff irq 3 on isa sio1: type 16550A

This shows two serial ports. The first is on irq 4, is using port address The for more details. How do I tell if FreeBSD found my modem cards?

Refer to the answer to the previous question. I just upgraded to 2.0.5 and my

Don't worry, they have been merged with the How do I access the serial ports on FreeBSD?

The third serial port, (known as COM3 in DOS), is on /dev/cuaa2 for dial-out devices, and on /dev/ttyd2 for dial-in devices. What's the difference between these two classes of devices?

You use /dev/ttydX in blocking mode, a process will wait for the corresponding How do I enable support for a multiport serial card?

Again, the section on kernel configuration provides information about configuring your kernel. For a multiport serial card, place an line for each serial port on the card in the kernel configuration file. But place the irq and vector specifiers on only one of the entries. All of the ports on the card should share one irq. For consistency, use the last serial port to specify the irq. Also, specify the The following example is for an AST 4-port serial card on irq 7: options "COM_MULTIPORT" device sio4 at isa? port 0x2a0 tty flags 0x781 device sio5 at isa? port 0x2a8 tty flags 0x781 device sio6 at isa? port 0x2b0 tty flags 0x781 device sio7 at isa? port 0x2b8 tty flags 0x781 irq 7 vector siointr

The flags indicate that the master port has minor number 7 ( Can FreeBSD handle multiport serial cards sharing irqs?

Not yet. You'll have to use a different irq for each card. Can I set the default serial parameters for a port?

The stty -a -f /dev/ttyd1

When you change the settings to this device, the settings are in effect until the device is closed. When it's reopened, it goes back to the default set. To make changes to the default set, you can open and adjust the settings of the ``initial state'' device. For example, to turn on XON/XOFF flow control by default for ttyd5, do: stty -f /dev/ttyid5 clocal cs8 ixon ixoff

A good place to do this is in /etc/rc.serial. Now, an application will have these settings by default when it opens You can also prevent certain settings from being changed by an application by making adjustments to the ``lock state'' device. For example, to lock the speed of stty -f /dev/ttyld5 57600

Now, an application that opens Naturally, you should make the initial state and lock state devices writable only by script does How can I enable dialup logins on my modem?

So you want to become an Internet service provider, eh? First, you'll need one or more modems that can auto-answer. Your modem will need to assert carrier-detect when it detects a carrier and not assert it all the time. It will need to hang up the phone and reset itself when the data terminal ready (RTS/CTS flow control or no local flow control at all. Finally, it must use a constant speed between the computer and itself, but (to be nice to your callers) it should negotiate a speed between itself and the remote modem.

For many Hayes command-set--compatible modems, this command will make these settings and store them in nonvolatile memory: AT &C1 &D3 &K3 &Q6 S0=1 &W

See the section below for information on how to make these settings without resorting to an MS-DOS terminal program.

Next, make an entry in for the modem. This file lists all the ports on which the operating system will await logins. Add a line that looks something like this: ttyd1 "/usr/libexec/getty std.57600" dialup on insecure

This line indicates that the second serial port (/dev/ttyd1) has a modem connected running at 57600 bps and no parity (). The terminal type for this port is ``dialup.'' The port is ``on'' and is ``insecure''---meaning root logins on the port aren't allowed. For dialin ports like this one, use the It's common practice to use ``dialup'' as the terminal type. Many users set up in their .profile or .login files a prompt for the actual terminal type if the starting type is dialup. The example shows the port as insecure. To become root on this port, you have to login as a regular user, then ``'' to After making modifications to , you need to send a hangup or process: kill -HUP 1

This forces the init process to reread . The init process will then start getty processes on all ``on'' ports. You can find out if logins are available for your port by typing ps -ax | grep '[t]tyd1'

You should see something like: 747 ?? I 0:00.04 /usr/libexec/getty std.57600 ttyd1 How can I connect a dumb terminal to my FreeBSD box?

If you're using another computer as a terminal into your FreeBSD system, get a null modem cable to go between the two serial ports. If you're using an actual terminal, see its accompanying instructions.

Then, modify , like above. For example, if you're hooking up a WYSE-50 terminal to the fifth serial port, use an entry like this: ttyd4 "/usr/libexec/getty std.38400" wyse50 on secure

This example shows that the port on /dev/ttyd4 has a wyse50 terminal connected at 38400 bps with no parity () and Why can't I run

On your system, the programs and are probably executable only by and group Alternatively, you can let everyone on your system run # chmod 4511 /usr/bin/cu # chmod 4511 /usr/bin/tip My stock Hayes modem isn't supported---what can I do?

Actually, the man page for is out of date. There is a generic Hayes dialer already built in. Just use `` file.

The Hayes driver isn't smart enough to recognize some of the advanced features of newer modems---messages like (using Also, the dial timeout for Actually, as shipped /usr/src/usr.bin/tip/tip. Obviously you need the source distribution to do this.

Edit the line `` How am I expected to enter these AT commands?

Make what's called a `` file. For example, if your modem's hooked up to the first serial port, /dev/cuaa0, then put in the following line: cuaa0:dv=/dev/cuaa0:br#19200:pa=none

Use the highest bps rate your modem supports in the br capability. Then, type and you'll be connected to your modem.

If there is no /dev/cuaa0 on your system, do this: # cd /dev # ./MAKEDEV cuaa0

Or use cu as root with the following command: # cu -l``line'' -s``speed''

with line being the serial port (e.g./dev/cuaa0) and speed being the speed (e.g.57600). When you are done entering the AT commands hit ~. to exit. The

The for a phone number. But the . Escape it with a backslash: pn=\@ How can I dial a phone number on the command line?

Put what's called a `` file. For example: tip115200|Dial any phone number at 115200 bps:\ :dv=/dev/cuaa0:br#115200:at=hayes:pa=none:du: tip57600|Dial any phone number at 57600 bps:\ :dv=/dev/cuaa0:br#57600:at=hayes:pa=none:du:

Then you can do something like `` over , use a generic cu entry: cu115200|Use cu to dial any number at 115200bps:\ :dv=/dev/cuaa1:br#57600:at=hayes:pa=none:du:

and type `` Do I have to type in the bps rate every time I do that?

Put in an entry for thinks a good default is 1200 bps which is why it looks for a `` I access a number of hosts through a terminal server.

Rather than waiting until you're connected and typing ``: pain|pain.deep13.com|Forrester's machine:\ :cm=CONNECT pain\n:tc=deep13: muffin|muffin.deep13.com|Frank's machine:\ :cm=CONNECT muffin\n:tc=deep13: deep13:Gizmonics Institute terminal server:\ :dv=/dev/cua02:br#38400:at=hayes:du:pa=none:pn=5551234:

will let you type `` Can tip try more than one line for each site?

This is often a problem where a university has several modem lines and several thousand students trying to use them...

Make an entry for your university in and use \@ for the big-university:\ :pn=\@:tc=dialout dialout:\ :dv=/dev/cuaa3:br#9600:at=courier:du:pa=none:

Then, list the phone numbers for the university in : big-university 5551111 big-university 5551112 big-university 5551113 big-university 5551114

will try each one in the listed order, then give up. If you want to keep retrying, run Why do I have to hit CTRL+P twice to send CTRL+P once?

CTRL+P is the default ``force'' character, used to tell that the next character is literal data. You can set the force character to any other character with the Type ``You can have the force character be whatever you want by specifying the following in your $HOME/.tiprc file: force= Suddenly everything I type is in UPPER CASE??

You must've pressed CTRL+A, ``raise character,'' specially designed for people with broken caps-lock keys. Use Here's a sample .tiprc file perfect for Emacs users who need to type CTRL+2 and CTRL+A a lot: force=^^ raisechar=^^

The ^^ is SHIFT+CTRL+6. How can I do file transfers with

If you're talking to another UNIX system, you can send and receive files with and on the remote system to accept and send files. The syntax is: ~p [] ~t []

There's no error checking, so you probably should use another protocol, like zmodem. How can I run zmodem with

First, install one of the zmodem programs from the ports collection (such as one of the two from the comms category, and ).

To receive files, start the sending program on the remote end. Then, press enter and type ``To send files, start the receiving program on the remote end. Then, press enter and type `` FreeBSD can't seem to find my serial ports, even when the settings are correct.

Motherboards and cards with Acer UARTs do not probe properly under the FreeBSD sio probe. Obtain a patch from to fix your problem.