8.16. Using the serial port

This section describes what is possible to do with Bochs serial port emulation. These examples use dlxlinux disk image (downloaded from http://bochs.sourceforge.net/guestos/dlxlinux3.tar.gz ) running as guest, on a debian x86 linux 2.4.19 host.

For the examples to work in dlxlinux, after you login as root, you will need to kill the running gpm, as it grabs the serial port.

Welcome to DLX V1.0 (C) 1995-96 Erich Boehm
                    (C) 1995    Hannes Boehm


dlx login: root
Linux 1.3.89.
dlx:~# ps | grep gpm
   30  S0 S     0:00 /usr/bin/gpm -t bare
   40   1 S     0:00 grep gpm
dlx:~# kill -9 30
dlx:~#

8.16.1. Logging serial port output to a file

The first example shows how to log information sent to the serial port on the guest system into a file on the host system.

Update the com1: section of your configuration file:

com1: enabled=1, mode=file, dev=serial.txt
        
After you've launch dlxlinux, everything sent to the serial port will be logged to serial.txt :
dlx:~# echo "logging to the serial port" > /dev/cua0
        
host$ cat serial.txt
logging to the serial port
host$
        

8.16.2. Interactivity : connecting to a virtual terminal

The second example shows how to connect to the guest OS, using a virtual terminal on the host OS.

First, you need to find an unused virtual terminal. Typically, X uses vt7; vt8 and up are unused. On my system, I can switch from X to vt9 by pressing ctrl-alt-f9 : this virtual terminal is not used, the screen is all black. Pressing alt-f7 switches back to X.

Once you found an unused vt, update the com1: section of your configuration file:

com1: enabled=1, mode=term, dev=/dev/tty9
        
The number must be set according to the terminal you want to use (here 9).

Now, launch dlxlinux. After you log in as root and kill gpm, enter the following command:

dlx:~# /sbin/agetty 38400 cua0
        
If you switch to vt9, you can see dlx welcome banner, and the login prompt:
Welcome to DLX V1.0 (C) 1995-96 Erich Boehm
                    (C) 1995    Hannes Boehm


dlx login:
Note that dlxlinux is configured so you can not login as root from a serial port. If you want to login, you have to create a new user first.

Also, if you plan to use this feature, the best would be to deactivate gpm in /etc/rc.d/rc.local, and add a agetty line in /etc/inittab, for example:

T0:1234:respawn:/bin/agetty 38400 cua0

8.16.3. Interactivity : connecting to a pseudo terminal

The third example is very similar to the second one, except that we connect to the guest OS with kermit as client, and we the connection is done through a pseudo terminal.

This example uses /dev/ptyp0 and /dev/ttyp0 as pseudo terminal pair. We will tie Bochs to the controlling terminal, whereas kermit will use the slave terminal.

Update the com1: section of your configuration file:

com1: enabled=1, mode=term, dev=/dev/ptyp0
        
and lauch dlxlinux. After you log in as root, enter the command:
dlx:~# /sbin/agetty 38400 cua0
        
Then in the host OS, launch kermit :
host$ kermit -l /dev/ttyp0
C-Kermit 7.0.196, 1 Jan 2000, for Linux
 Copyright (C) 1985, 2000,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/tmp/) C-Kermit>connect
Connecting to /dev/ttyp0, speed 0.
The escape character is Ctrl-\ (ASCII 28, FS)
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------

Welcome to DLX V1.0 (C) 1995-96 Erich Boehm
                    (C) 1995    Hannes Boehm


dlx login:
        
The same comments as for example 2 apply here.