Chit chat

———–

Not so much stuff in this posting.

Updated the Arch linux box for the “vim” rearrangement.

Disappoints me that people think they have to have a particular linux distro, but now with systemd that changes.

Added several apps to the test web server.

Found a web based arduino ide, but it only works in the local browser and not on a server.

Played with the arduino a little bit, found some differences between the real Arduino and the Osepp board.

———————————————-

Couple of cartoons:

———————————————-

If you set up your serial port for communications (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.

$  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)

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

 

———————————————-

Saw this article (http://www.raphnet.net/electronique/adlib/adlib_en.php) about connecting and 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, or etc).

 

Adlib information:
http://www.o-bizz.de/qbtuts/mallard/sbfaq.htm

http://www.shipbrook.net/jeff/sb.html

———————————————-

Just like there are many verbal languages for speaking i.e. English, Spanish, Italian or etc.,  computers have their own languages also. Most people understand a verbal language  without having to do any translation. For computers that can be different. So if you want to use a language on a computer, some translation will need to be done to convert the commands (aka source code) to the ones and zeroes a computer understands. This is called compiling. There are a zillion languages that can be used, but one of the most common is “C” pronounced “see”. “C” was made famous by Dennis Ritchie and Brian Kernighan also know and K&R.

Even if you are not a programmer, you will get the urge to create your own program. This usually happens when you seem some code on a web page or in a magazine that you just have to try. So then every once in a while you may actually need to create a simple program either for testing a system or just to create a quick utility. Most systems support GCC (a c compiler) although you may have to install some programs. i.e. “sudo apt-get install  build-essential”. Now let us create the world famous “HelloWorld” program for your system.

1. Create  or copy your source code into and editor such as vim, nano, joe, or etc. Be sure to save the file (aka source code) and then exit.   (source code is in the examples)

$ nano hw.c

Note:

 and 

are not entered into the editor.

2. The you need to convert the source code to an executable program.

# $ gcc sourcecode.c -o executablename
$ gcc hw.c -o hw

3. Run or execute your program. (if no errors are detected otherwise changes will need to be made and then recompiled),

$ ./hw
Hello World!

Or if you want sort of a gui:

$ ./hw | zenity –text-info

Pat your self on the back as you have created your first program! That is all there is to it for simple programs you create. More advanced programs will require a bit more work. More about that later.

Collected C source code from: http://www.geekboots.com/c/intro. Here are some basic examples that you will eventually use.

Basic file tools:
Simple output
Read a file
Write to a file

System tools:
Access the system
Remove a file
Copy a file

Basic i/o
———————————————-
Simple output

$ ./hw
Hello World!

#include<stdio.h>
int main()
{
/* Display text on the screen */
printf("Hello World!\n");
return 0;
}

Read a file

$ ./readfile
Get text as character from file
This is data to read.

Read file up to first blank space or line break
This


#include<stdio.h>
int main()
{
/* Declare File pointer */
FILE *fp;
char text, text1[10];
/* Open file 'myfile.txt' in read mode */
fp = fopen("myfile.txt", "r");
/* Read character on file using 'fgetc' function */
printf("Get text as character from file\n");
while( (text = fgetc(fp) ) != EOF )
printf("%c", text);
printf("\n");
/* Go to the beginning of the file */
fseek(fp,0L,0);
/* Read text on file using 'fscanf' function */
printf("Read file up to first blank space or line break\n");
fscanf(fp, "%s", text1);
printf("%s\n", text1);
/* Close file */
fclose(fp);
return 0;
}

Write to a file:

$ ./writfile
File created and written successfully!
eddie@oelt02:~/csource$ cat myfile.txt
Hello!
Hello World!

 #include<stdio.h>
int main()
{
/* Declare File pointer */
FILE *fp;
char text[10] = "Hello!";
int i = 0;
/* Create/Open file 'myfile.txt' in write mode */
fp = fopen("myfile.txt","w");
/* Write character on file using 'fputc' function */
while(text[i] != '\0')
{
fputc(text[i], fp);
i++;
}
/* Write text on file using 'fprintf' function */
fprintf(fp,"\nHello World!");
/* Checking error on file */
if (ferror(fp))
printf("Error occur...Try Again!\n");
else
printf("File created and written successfully!\n");
/* Close file */
fclose(fp);
return 0;
}

System tools:
—————————————————————-
Access the system:

$ ./sysaccess
Tue Sep  2 21:20:18 CDT 2014
cpvile.c  delfile.c  readfile.c  sysaccess.c

#include<stdlib.h>
int main()
{
/* System function use to run system commands */
/* Print date on the terminal */
system("date");
/* List directory content on the terminal */
system("ls");
return 0;
}

Remove a file:

$ ./delfile
File Deleted Successfully!
eddie@oelt02:~$ ./delfile
Unable to delete the file!
Error: No such file or directory

#include<stdlib.h>
int main()
{
/* System function use to run system commands */
/* Print date on the terminal */
system("date");
/* List directory content on the terminal */
system("ls");
return 0;
}

Copy a file:

$ ./cpfile
File copied successfully!


#include<stdio.h>
#include<stdlib.h>
int main()
{
/* Declare File pointer */
FILE *source, *destination;
char ch;
/* Open file 'myfile.txt' in read mode */
source = fopen("myfile.txt", "r");
/* Checking for file is properly open or not */
if(source == NULL)
{
printf("Error occur on file opening\n");
exit(EXIT_FAILURE);
}
/* Create/Open file 'newfile.txt' in write mode */
destination = fopen("newfile.txt", "w");
/* Checking for file is properly open or not */
if(destination == NULL)
{
fclose(source);
printf("Error occur on file opening\n");
exit(EXIT_FAILURE);
}
/* Copying text from one file to another */
while( ( ch = fgetc(source) ) != EOF)
fputc(ch, destination);
/* Checking error on file */
if (ferror(destination))
printf("Error occur...Try Again!\n");
else
printf("File copied successfully!\n");
/* Close file */
fclose(source);
fclose(destination);
return 0;
}

———————————————————-

Data files:

myfile.txt, newfile.txt:

This is data to read

———————————————-

Question was asked recently what open software tools do we use or have used for tech support. Once, I thought about it the answer was, what do I not use. One of the first tools I ever used was Knoppix. Microsoft Windows did not have a free tool (there was a commercial one from sys internals) to boot to an operating system to rescue failed hard drives. Of course you could pull the drive and hook it to another machine, but that could be very iffy.

To back up files, I would boot with knoppix live cd (long before ubuntu) and make sure the drive was readable despite not being bootable. Then I would use the linux ntfs utilities and samba to log into the mswindows server and back up the user files to the home drive from linux. Of course you had to have admin rights to do that both on linux and MSWindows.  That made a lot of people happy that they did not lose all their data. Lastly,  the data was restored after a hard drive replacement and a new MSWindows was installed on the new drive. Then it was easy just to drag and drop files to the new system all under MSWindows.

Back then all we had was Samba3 and no gui utilities. Today things are a bit different.

apt-get install samba4 to get the latest version of Samba.
apt-get install cifs-utils to get necessary files/utils required to mount Windows shares.
Then do the following:
mkdir /mnt/share
Type the following command to mount the share:
mount -t cifs //windowsmachineip/sharename -o username=user,password=urPassword /mnt/share
On older machines the shares could be mounted as follows:
mount -t smbfs -o username=user,password=urPassword //windowsmachineip/sharename /mnt/share

———————————————-

Starter menu to show you the power of tput.

 

#!/bin/bash
#testmenu.sh
#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
QUIT=0
while [ $QUIT -lt 1 ]
do
#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 ]
 then
 continue
 fi
 if [ $SEL -eq 4 ]
 then
QUIT=1
continue
 fi
 #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";;
esac
done
#reset the screen
#Find out if this is a "linux" virtual terminal
if [ $TERM ~ "linux" ]
then
 tput setb 0 #reset background to black
fi
tput reset
tput clear

———————————————-

Not my idea, but thought this might be another article to look at. It is allegedly a video generator. http://sbc.rictor.org/io/vid3.html

I am obligated to also mention:
https://code.google.com/p/arduino-tvout/
http://www.gammon.com.au/forum/?id=11608
http://www.pyroelectro.com/tutorials/arduino_basic_vga/index.htmlhttp://forum.arduino.cc/index.php/topic,102181

———————————————-

Homemade chips

SUNP0052

Good day.

Advertisements