Saturday, August 30, 2014

Bash menu starter

Starter menu to show you the power of tput.

#test for tput cursor movements
#colour the screen
tput setb 3 #Green in xterm and brown in linux terminal
tput clear
#paint menu onto the screen
echo ""
echo ""
echo "TEST MENU"
echo "1 ..... ECHO 1"
echo "2 ..... ECHO 2"
echo "3 ..... ECHO 3"
echo "4 ..... QUIT"
echo ""
echo "Select item: "
#loop around gathering input until QUIT is more than 0
while [ $QUIT -lt 1 ]
#Move cursor to after select message
tput cup 8 13
#Delete from cursor to end of line
tput el
read SEL
if [ ${#SEL} -lt 1 ]
if [ $SEL -eq 4 ]
#put message in middle of screen
tput cup 15 20
#Delete from cursor to end of line
tput el
case $SEL in
*) echo "You selected $SEL";;
#reset the screen
#Find out if this is a "linux" virtual terminal
if [ $TERM ~ "linux" ]
tput setb 0 #reset background to black
tput reset
tput clear

Turkey burger.


Linux terminal server project lets you connect to multiple systems via rdp, vnc and etc.

Backup monitor?

If you set up your serial port for communications and have a serial terminal (some systems may require a usb adapter), you will never worry about not having a monitor for emergencies. (Connecting in this case to an nslu2 running linux.)

Notes from an earlier article to set up serial communication, Your system may vary.
Now to get the Pda working with the unit. The Palm pda will not work as is as a dumb terminal, so I had to install a program on to it from another computer called ptelnet.prc using a usb to serial interface. The Palm has an interface cable that will plug directly into the 9 pin serial port on the back of the computer. HP Journa has a standard rs232 port.

$  pilot-xfer -p /dev/ttyUSB0 -i ptelnet.prc

That should be easy. First to test the port. Strange the serial port on what is commonly known as com2:. (com1: =ttyS0)

$ sudo /sbin/getty -h -L /dev/ttyS1 9600 vt100 &
$ sudo chmod 666 /dev/ttyS1

A prompt did not show up on the Palm pda. Now what is the problem? Time to log out and restart the computer to go into the bios. Went into the bios and noticed there were two serial ports, but you could only have one port working at a time. The motherboard was set for the second port which was IR only. Changed the motherboard to use port 1 and disabled IR. Saved the settings and rebooted. Used the temp command again to test the serial port.
$ sudo /sbin/getty -h -L /dev/ttyS0 9600 vt100 &
$ sudo chmod 666 /dev/ttyS0
The login prompt came right up on the Palm pda. Logged in and all was well. Beginning to feel like Sherlock Holmes solving issues.  Sshed back into Robotpet. Now I had to make the port available all the time.

$ sudo vim /etc/inittab

Needed to uncomment on line to make that so. (i.e. remove the pound sign)

# T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100


Do you know what day it is?

What is the day if we know how many days have passed in the year? How many days have passed if we know the date?

Friday, August 29, 2014

Microcontroller and the adlib sound card.

Saw this article ( about connecting an old eight (isa) bit sound card to the parallel port. Then I thought after looking at the connections that maybe the Arduino, RPi, Beagleboard, or the like  could also be used.  Just a matter of developing the software. Try this at your own risk. Then I thought there are lots of other old legacy eight bit cards that might be used (i.e serial, parallel, floppy, network, or etc).

Adlib information:

Embedded server with ISA network card

This embedded server was built with NE2000 compatible ISA network card (popular Realtek RTL8019, probably Davicom DM9008F also) and ATmega32 microcontroller. I've bought RTL8019 card branded as "Planet" for $1.50.
You can find souce code and basic schematic at There may be some changes to pin assignment so please refer to and/or modify rtl8019.h file to suits your needs.
Device worked as telemetry server for over a year (V 2007 - VI 2008). It was replaced by more functional (firmware) and smaller PIC18F67J60 circuit. ISA card webserver is still cheaper and may be easier to start with since AVR requires less complex programmer that PIC18FxxJ.
To allow regular measurement database update I've added to original microserver some code that works as - very simple and not reliable - TCP/HTTP client that sends POST request every few minutes.
Project should compile with WinAVR-20060421. (97kB)
Please note that I did not tested this microserver in any hostile environment nor tested with fuzzer or similar tool. There could be some errors leading to uncontrolled behavior - i.e. there is possible buffer overrun in http.c:
  unsigned char File_Name[13];
  if ( memcmp(&buffer[tcpdata],"GET /",5) == 0) 
   char *tmppointer = &buffer[tcpdata + 5];
   unsigned char counter = 0;
   while (* tmppointer != 0x20)
    File_Name[counter] = *tmppointer++;
It is recommended to hide microserver behind NAT and limit forwarded ports only to minimal required set.
100_0582.jpg 100_0581.jpg

Macaroni press?

Original drawing:

You might be a programmer if:

If you have ever created a "to do" list, you have created software or a computer program for people.

Wednesday, August 27, 2014

Legacy Robot notes.

Have not made much time to work on special projects. One thing I need to start back on is robopet.  There is nothing real super snazzy about this unit although it could be. Mainly I will use it for carrying snacks back and forth from the kitchen during sporting events. There will be a second level not currently attached to hold the goodies. More information about the unit follows.


Using an old Pentium I computer, usb wireless, DC battery power, dc-dc atx ps and compact flash with an ide conversion interface. Powered wheels came from two Tonka RC cars that I dissected.

Made a special wiring hardness to connect the parallel port with the control electronics. Now I need to start testing the electronics for the motor control. Hoping the h-bridge can take the current. If not, I think I have a IC that will. Worst case scenarios is to do it the old fashion way with transistors. After that, everything should fall into place.

Using a standard power supply to test the unit, but it will run on battery when I finish it. Since the motherboard is AT and the DC-DC PS is ATX, I had to make a special cable from scratch to interface the two. Tested the cable and it works.

Have the wireless working via a usb interface set up to work with a specific router via the mac address and the zone. Albeit the wireless is 11 mb, more than fast enough to receive and send communication

Special home made turn signals to be added also.

No sensors added yet.


The Linux OS is installed.  The OS resides on a compact flash.The iso file for the version of the Ubuntu distribution also resides on the flash drive and gets mounted as a loop.

Using my own home grown robot control software to gather data from sensors and to operate the unit. Found a binary of the very lightweight web server Boa on for the version of Ubuntu I am using. Installed it. Apache2 is too bulky for this project. Eventually, I want to make an autonomous unit.  This unit will be more like a remote controlled car via wifi.

Code to control the motors has already been tested (using parcon.c) and is working.   Using a hardwired connection, already tested client/server socket programming to communicate with and control the unit. That should be way more efficient and possibly more secure than using a web server per se..


Had to make special adapter plates to connect the wheel assemblies to the cart. Originally I used clear plastic, but those broke too easily. Wood worked much better, but not as pretty. Attached a third generic cart wheel.

Extra: We installed ptelnet on an old Palm pda to use it as a dumb terminal. That way we do not have to hook the robot to a monitor when we want to access the unit. Saves electricity and makes it more portable. With the installation of Boa, the Chumby can also be used to control the robot without requiring an umbilical cord. Which means that getting an Android or the like tablet more feasible.

Added schematic for turning blinker.


 Parcon.c for controlling parallel port

To compile:
$ gcc parcon.c -o parcon

To run (l is off and h is on.)
$ sudo parcon 1l 2l 3h 5h 8l

 Turns off pins 1,2, and 8. Tuns on pins 3 and 5.

 #include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/io.h>

char *binprint( unsigned char x, char *buf )
  int i;
  for( i=0; i<8; i++ )
  return buf;

int main( int argc, char *argv[] )
  char c;
  unsigned char val;
  char buf[9];
  int x;
  if( argc<2 )
    printf("  example usage: parcon 1l 2l 3h 5h 8l\n");
    return 2;
  if( ioperm(888,1,1) )
    printf("Couldn't get port 888\n");
    return 1;
  val = inb(888);
  printf("old = %s\n",binprint(val,buf));
  for( x=1; x<argc; x++ )
    if( argv[x][1]!='h' )
      val &= ~(1<<(argv[x][0]-'1'));
      val |= 1<<(argv[x][0]-'1');
  printf("new = %s\n",binprint(val,buf));
  return 0;