The first challenge is interfacing the Serial AB Switch’s RS232 levels to the RPi 3.3V levels. I achieved this by purchasing a plugin shield board that sits on top of the RPi. As seen here, the board selected is the “SainSmart RS232 / GPIO Shield for Raspberry Pi”. This GPIO shield not only gives me the needed serial interface but also supplied a breakout of many of the RPi’s General Purpose Input Output (GPIO) lines needs in another phase of this project.
The RPi is using a minimal version 2015-2-16 of RASPBIAN. RASPBIAN is just a version of Linux at the core. The initial setup is nothing special so I just followed the process outlined at the Raspberry Pi web site.
Once the RPi RASPBIAN is up and running, I needed to prevent the Linux from using the serial port. The Broadcom UART appears as /dev/ttyAMA0 under Linux. There are several minor things in the way if you want to have dedicated control of the serial port on a Raspberry Pi. The kernel will use the port as controlled by kernel command line contained in /boot/cmdline.txt. The file will look something like this:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
The console keyword outputs messages during boot, and the kgdboc keyword enables kernel debugging. All references to ttyAMA0 need to be removed. The resulting /boot/cmdline.txt, should now contain:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
You must be root to edit this (e.g. use sudo nano /boot/cmdline.txt). Be careful doing this, as a faulty command line can prevent the system from booting.
A login prompt appears on the serial port after boot up and will need to be disabled. This is controlled by the following lines in /etc/inittab:
#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
You will need to edit this file to comment out the second line like so:
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Now reboot the RPi for the new settings to take effect. You can use /dev/ttyAMA0 like any normal linux serial port, and you will not get any unwanted traffic confusing any attached devices like the Altair Clone.
I use two different serial software packages to communicate with my Altair. Minicom and ser2sock. Each are accessed using different methodology.
Minicom is a terminal emulation program in Linux. To access minicom I first have to connect to the RPi via SSH and then login to Linux via a user account. From there I run the minicom program within the user shell. This method provides a nice form of data security and limits access rights to only approved users.
Ser2sock is a utility program that allows sharing of a serial devices over a TCP/IP network. It also supports encryption and authentication via OpenSSL. In my setup ser2sock is setup as a simple serial over TCP/IP on port 10000 with no encryption. I just use putty, Tera Term, etc. to access the Altair. For more information on ser2sock visit the project site at https://github.com/nutechsoftware/ser2sock