Skip to content

Simple Console Server

David Goodwin edited this page Sep 18, 2024 · 3 revisions

Kermit 95 supports the Telnet com-port-control option (RFC2217) allowing it to control serial ports over the network. All you need is a suitable telnet server that supports this option and some serial ports for it to serve and Kermit 95 can take care of the rest. As Kermit 95 is just the Windows and OS/2 port of C-Kermit, all of this applies to C-Kermit on other platforms too.

This means you can build yourself a cheap console server with some simple software and off-the-shelf parts you may already have lying around - a Raspberry Pi and some USB Serial adapters.

Installation and Configuration

One option for the telnet server is SRedird. This was originally built in part by the main developer of Kermit 95 and was distributed in the past by The Kermit Project but these days is available from the Debian (and so raspbian) repositories making it just an apt install sredird away.

Configuration is trivial. Just add some entries to /etc/services for your serial ports - I'm using port 7001 for the first serial port and counting up from there:

# Local services
tty1            7001/tcp
tty2            7002/tcp
tty3            7003/tcp

And then over in /etc/inetd.conf you need a matching entry for each serial port:

tty1    stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/sredird 5 /dev/ttyUSB0 /run/lock/ttyUSB0.lock
tty2    stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/sredird 5 /dev/ttyUSB1 /run/lock/ttyUSB1.lock
tty3    stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/sredird 5 /dev/ttyUSB2 /run/lock/ttyUSB2.lock

Connecting

Then over in Kermit 95 you can connect to /dev/ttyUSB2 on your console server, configure the serial port and start your session with something like this:

set carrier-watch off                         ; Important - the next command will fail if carrier-watch is on
set host console-server-hostname 7003 /telnet ; connect to port 7003 on console-server-hostname
set speed 9600                                ; set the serial port speed to 9600
set flow-control none                         ; Configure flow-control
set stop-bits 1                               ; Configure stop-bits
set parity none                               ; Configure parity
connect                                       ; Begin terminal session

At any point after the set host command you can see the current serial port settings with the show communications command:

image

A Macro for Convenience

If your settings are always going to be the same and the only variable that changes is the port number you're connecting to, you can save yourself a lot of typing by putting a macro in your k95custom.ini that does most of the work for you! The example below takes only one parameter - the serial port number. It then calculates the TCP/IP port number, tries to connect, and on success configures the remote serial port and begins a terminal session:

def serial {
	local port host
	
	; Change this value to the hostname or IP of your console server
	.host := 10.0.1.24

	; Add the serial port number to the base TCP/IP port number.
	; For example, TCP/IP port 7001 for serial port 1.
	.port ::= 7000 + \%1
	
	echo Connecting to \m(host) port \m(port)...
	
	set carrier-watch off                 
	set host \m(host) \m(port) /telnet
	
	; If anything goes wrong connecting to the console server don't bother
	; trying to set the serial port configuration, just output an error message
	if fail end 1 Failed to connect to \m(host) port \m(port)

	echo Connected to: \v(rfc2217_signature)

	; Configure serial port settings	
	set speed 9600                        
	set flow-control none                 
	set stop-bits 1                       
	set parity none                 

	; Begin terminal session      
	connect    
}

You can then connect to serial port 3 on your console server with serial 3, the result being:

[C:\apps\kermit\] CKW> serial 3
Connecting to 10.0.1.24 port 7003...
 Trying 10.0.1.24... (OK)
Connected to SRedird 2.2.1 /dev/ttyUSB2

followed by a switch to the terminal.