The Commodore Telnet BBS by Bo Zimmerman (ez13942@swt.edu) Overview The following are instructions for setting up a Commodore computer as a telnet-able BBS. It relies on a modem connection with a PC running LINUX with a telnet daemon. The Commodore is connected to the PC via a null modem cable. The LINUX box has a modified version of minicom, which comes with the slackware distribution (and others I would imagine), and a shell script, all described in greater detail below. The essential goal is this: when a user telnets to the LINUX machine and logs in as the BBS user, the PC will run the modified minicom, which is set up to communicate with the COM port connected to the Commodore. When minicom starts up, it will signal the Commodore that a connection has been made by setting the modem port's DTR signal. The Commodore BBS program goes online because the DTR line is attached to the DCD line in the cable. So long as the user is still in minicom, the connection remains, and wa-la! A Commodore on the net! Part I : Required Components Part II : RS232 Adapter Instructions Part III: Setting up the LINUX box Part IV : Setting up the Commodore BBS program Part V : What's missing Part VI : Credits Part I: Required Components 1) Commodore 64/128/VIC-20 2) Sufficient Commodore drives for your BBS software. 3) Commodore BBS software with DCD initiation capabilities (see part IV) 4) Standard RS232 null modem cable adaptor for the Commodore 5) PC 386 or better running Linux 6) Network capabilities for the Linux machine (ethernet card, PPP connection, or other connection) Part II: RS232 Adaptor Instructions (This is cut and pasted from some instructions I downloaded off of ftp.funet.fi and then modified for a standard 9 pin female COM port on a PC). USER PORT STD. DB9 COM NULL DB9 COM CABLE CABLE | +------\ | | | 2 | \ 3 | | M -|------------------| U1-A O-------|- 2 TX ----------|- 3 RX | | / | | | +------/ | | | \ | | | | \ | | | 3| \ 4 4+------\ | | D -|---|U3-B O----+---| \ 6 | | | | / | 5| U1-B O-------|- 7 RTS ----------|- 8 CTS | | / +---| / | | | / +------/ | | | | | | \ | | | | \ | | | 5| \ 6 9+------\ | | E -|---|U3-C O----+---| \ 8 | | | | / | 10| U1-C O-------|- 4 DTR ------+---|- 6 DSR | | / +---| / | | | | / +------/ | | | | | | | | | | | | / | | | B -|---+ / | | | | | | 3 / | 1 | | | C -|-----------------O U2-A -----------|- 2 RX ------|---|- 3 TX | \ | | | | | \ | | | | | \ | | | | | | | | | | | | | | | | / / | | | | / | / | | | | | 10 / |11 6 / | 4 | | | L -|----O U3-E ------O U2-B -----------|- 6 DSR ---+ +---|- 1 DCD | \ | \ | | | | | \ | \ | | | | | \ \ | | | | | | | | | | | | / / | | | | / | / | | | | | 12 / |13 8 / | 10 | | | K -|----O U3-F ------O U2-C -----------|- 8 CTS ---|------|- 7 RTS | \ | \ | | | | | \ | \ | | | | | \ \ | | | | | | | | | | | | / / | | | | / | / | | | | | 8 / | 9 11 / | 13 | | | H -|----O U3-D ------O U2-D -----------|- 1 DCD ---+------|- 4 DTR | \ | \ | | | | \ | \ | | | | \ \ | | | | | | | | N -|-----------------------------------|- 5 SIG GND ----------|- 5 | | | | +5V | | 2 -|----+------------+ +------|- PROTECTIVE GND --------|- | | | | | | | | | | | | | --+-- 0.1uF | ------- | | | --+-- 10V | --- | | | | | - | ********************************* A -|----+ | | * * | | | | * U-1 1488 RS-232 XMTR * | ------- | 14 +----+ 7 | * * | --- +----| U2 |--+ | * U-2 1489 RS-232 RCVR * | - | +----+ \ | * * | | \ | * U-3 7404 HEX INVERTER * | | 14 +----+ 7\ | * * | +----| U3 |--+ | * DIODES SIGNAL DIODES * | |\ | +----+ | | * WILL WORK HERE * | | \| | | * * 10-|----| |---+--------+ | | * NOTE: THE RS-232 VOLTAGE * | | /| + | | ------- | * BE APPX +/- 10 VOLTS * | |/ | --+-- | --- | * WHICH IS OK TO USE * | 100uF --+-- 14 | - | * PER RS-232 STANDARD * | 15V | +--|--+ | * * | | | | 7 | * * | ------- | U1 +----+ | ********************************* | --- | | | | | - +--|--+ | | | 1 | ------- | | | --- | | 120uF | - | | 15V | /| | | ********************************* | +|| |/ | | | * * 11-|--||----+---| |----+----+ | * Commodore User Port to RS-232 * | || | |\ | | | * Adaptor designed by Stephen * | | | \| | | * Coan, Version 2, 03-NOV-83. * | | | | * * | -------- 100uF ---+--- | * This general design has also * | \ / 15V ---+--- | * been used in other devices * | \/ + | | * where a negative voltage was * | -------- | | * not available for the RS-232 * | | | | * * | | | | * The user port is a 44 pin * | +-------+----------+ | * edge connector and the PC COM * | | | * port is a female DB 9 (as on * | | | * on a joystick) * | ------- | * * --- | * * - | * * | * * | ********************************* | | You'll want to follow the instructions for the NULL modem cable for the sake of this project, so use the pin settings on the right hand side. Part III: Setting up the LINUX box You should know now that if you don't have root access to the LINUX machine, you should give up now. Secondly, you need to have the machine already configured with respect to its network hardware and the telnet daemon. The popular slackware distribution sets all this up during its installation process. The first step will be to create the above shell "new_minicom" and its accompanying configuration "cua0". 1. Log on as root, and enter the /usr/bin directory. 2. Run minicom by entering its name followed by the name of the port you'll be using. For instance, enter: "minicom -l -o cua0" for com port 1. "minicom -l -o cua1" for com port 2. 3. Enter CTRL-A followed by 'z' to view a menu of options. 4. Enter CTRL-A,P for communication parameters. You'll want the parameters to be: 2400 baud, 8 bits, no parity, 1 stop bit. Exit this menu when done. 5. Enter CTRL-A,T for terminal parameters. ANSI, Backspace, and enabled are fine settings. 6. Enter CTRL-A,O for configuration parameters. Select the third option- communication port setup. Make sure the serial device reads "/dev/cua0" for com port 1 or "/dev/cua1" for com port 2. Baud/parity/bits should read as you set them above. Hardware and software flow control should BOTH be turned OFF! 7. Exit back to the parameters menu and select "modem and dialing." The reset and initialization strings should be blank. Auto baud detect, hang-up drops DTR, and modem has DCD line should all read YES. 8. Exit back to the parameters menu again and hit the option "save configuration as cua0" (or cua1 if you are using com 2). 9. Exit minicom altogether by entering CTRL-A,X. 10.We will make this our TEMPORARY new_minicom by entering from the shell: cp minicom new_minicom If you want to test the RS232 cable, now would be a good time. Run minicom with the following options: new_minicom -l -o cua0 (or cua1 for com port 2) The next step is to create the BBS "user." 1. Log on as root and run the program "adduser." Call your account "bbs" and give it the name "bbs." After the user is created, you should have a directory called "/home/bbs." 2. Now load the file "/etc/passwd" into emacs and find the line containing the information about your BBS. The characters between the first and second colons in the line are the encrypted password. Delete these characters. Next change the default shell (the part following the last colon) to point to the file /usr/bin/new_minicom -l -o cua0. 3. When complete, excepting the ID number (504), your line should look identical to this one: bbs::504:100:bbs:/home/bbs:/usr/bin/new_minicom -l -o cua0 If you are using com 2, change the shell command to read "cua1" instead of cua0. The next step is a little tricky. You'll need to make some changes to minicom to make it much more secure against abuse by users. Without changes, the user can enter all the commands you did above! It will be necessary to have extensive knowledge of C and knowledge of compiling in LINUX to perform these changes. ;) Now that you're frightened, you'll be glad to know that the necessary files are available at: 147.26.162.107 in the "lib" subdirectory. The only files you'll really need are "new_minicom", which must be copied to your /usr/bin directory, and the file "wb.rc" (discussed below), which must be copied to /home/bbs. Also available is the file "newminicom.zip" which contains all the modified source code. The following changes, to the best of my memory, were made: 1. All CTRL-A commands have been disabled, with the exception of CTRL- A,X. 2. Minicom will automatically exit on the reception of the sequence CTRL- A,CTRL-B,CTRL-C,CTRL-D from the modem. 3. Spawning out has been disabled. 4. The status windows have been removed. 5. ANSI has been made permanent. 6. A "busy" message for already connected processes has been added. 7. A "cleaning up" message for the com port has been added in the event of an abnormal exit. After new_minicom is set up in the /usr/bin directory, you may think you're done. Well, you almost are! You may need to make sure there are no protections on the com port, on minicom, or on other necessary files. Do this with the "chmod" command. You'll want to turn on read and write for the com port as follows: chmod +r /dev/cau0 (or cua1) chmod +w /dev/cau0 (or cua1) Read and execute abilities can be added to minicom similarly: chmod +x /usr/bin/new_minicom Now you're done, right? No, but the last step requires a bit of explanation. Our telnet session is maintained because we have an actual user logged on and running a program. Should this user disconnect themselves from their telnet session without logging off, we are actually left with an open session of new_minicom still running in LINUX. Normally we wouldn't care, except that so long as new_minicom is running, the com port is protected from use, such that the system will be eternally busy! What we need to do then is to have a shell script, with root privileges, that will keep an eye on copies of new_minicom running without a telnet daemon connection. The following shell script will do that. From the /home/bbs directory, create the file "wb.rc" (I call it the watch-boy) and enter the following lines: set temp=1 while (temp=1) do pid=`ps -auxg | grep 'new_minicom' | grep -v 'grep' | grep 'bbs' \ | grep '?'| awk '{print $2}'` tty=`ps -auxg | grep 'new_minicom' | grep -v 'grep' | grep 'bbs' \ | grep '?' | awk '{print $7}' | grep '?'` if [ 'expr $tty : "?"' ] then kill -9 $pid fi sleep 60 done [!NOTE!: The two lines with the backslash (\) are extensions of the prior lines. For instance, the characters "| awk '{print $2}'`" should immediately follow the end of the line that reads "...grep '?'". Do not include the backslashes!] What this actually does is to look for occurrences of "new_minicom" being run by a user called "bbs" in which there is no terminal connection. It then kills those processes and goes to sleep for awhile before checking again. This file can also be downloaded from 147.26.162.107 in the "lib" subdirectory. Last thing to do then is to activate the watchboy by adding the following line to the file /etc/rc.d/rc.local /home/bbs/wb.rc & You can start up the watch boy as root without rebooting the machine, but the above will make sure it is started up whenever the LINUX box is restarted. Now on to the Commodore side. Part IV: Setting up the Commodore BBS program Thankfully, doing this is MUCH easier than setting up the LINUX box. The requirements on the Commodore end are actually very few, since what we end up doing is have the LINUX machine act as our modem and phone connection. As far as the BBS program is concerned (with few exceptions), it is acting completely as normal. You'll first want to select the BBS program to work with. Make sure it is one that is written in BASIC so that you can modify it easily. The BBS should also support ASCII, and preferably ANSI as well. For the time being, ANSI is the only way we'll get any color at all out of LINUX. The BBS program should support 2400 baud through the modem port. If not, you'll need to lower the set baud rate in minicom above. Detecting a connection is accomplished by simply watching the Data Carrier Detect line on the modem port. That will be bit 4 in location 56577. When the following BASIC condition becomes true, the BBS should go online: (peek(56577)and16)=16 The BBS program should go online by swinging its Data Terminal Ready signal high. This can be done with the following: poke56577,6:poke56579,6 The BBS program should hang up whenever it detects the Data Carrier Detect line go low. That's done with something similar to the peek above: (peek(56577)and16)=0 Lastly, the program will hang-up by doing two things. The first thing is to tell minicom to terminate. This is done by the following: print#2,chr$(1);chr$(2);chr$(3);chr$(4); Where print#2 is above you should substitute the proper modem channel for the number 2. The second is to drop the Data Terminal ready signal by entering: poke56577,0:poke56579,32 If the BBS program does all these things, it will perform admirably. Part V: What's to Come There are two current problems with this configuration for a telnet Commodore BBS. One is that Commodore graphics do not work. For a long time this baffled me, and I looked all over the minicom source for the solution. It wasn't there. Now I'm thinking it has something to do with the telnet daemon itself, which is the next place to check. When it's solved, I'll let you know. The other problem concerns time lag. Normally, lag is unimportant, but some transfer protocols are now especially sensitive to lag time. For this reason, along with translation problems mentioned above and the sensitivity of minicom to its termination codes, make the operation of the stream transfer protocols on the telnet BBS impossible. Perhaps some modified uuencoding packet based protocol could be written and patched in to the BBS program. If any such solution presents itself, it will be pursued. Part VI: Credits Very few of these are my original ideas. Special thanks to Matt Beall of California (mathew@cinenet.net) for most of the modifications done to minicom. The project itself is the brain child of Henry Knoepfle of Arizona, who helped me through all the linux changes. Early in August, as soon as I get my own BBS program properly configured, I'll be putting it back up on the same machine that the ftp files are on. Telnet to it and log on as user "bbs" with no password. Good luck!