!!selamat taun baru 2010!!

Posted in my extraordinary life on December 31, 2009 by satriant
met taon baru

met taon baru

Browse The Web Using Lynx

Posted in my extraordinary life on December 31, 2009 by satriant

lynx -> web browser for the console…

*tidak d sarankan..this is Just for Fun..

ktemu lagi ama gw..hehe..

kali ini gw akan memperkenalkan web browser untuk console..hihihi (jaman gini pake konsol, dah kaya kmbali k jaman batu).

langsung aja boi, ni langkah2 yang harus d lakukan…

1. install lynx

$ sudo apt-get instal lynx

2. jalanin lynx…

$ lynx

untuk pergi ke web… teken ‘g’ dan tuliskan URLnya dan teken Enter…..

this is the picture….

lynx screenshot...

google dengan lynx

Mail Client with Mutt

Posted in programming on December 30, 2009 by satriant

welcome to cli world..hehe…

mutt adalah email client untuk console.., gw akan ngasi tau cara termudah untuk setting mutt di ubuntu.

packet yang harus lo install adalah sebagai berikut :

OpenSSL, fetchmail, procmail, msmtp and mutt

step 1

installing the needed componen n aplikasi :

$ sudo apt-get install openssl fetchmail procmail msmtp mutt ca-certificates

step 2

ok, untuk contoh gw akan setting mail untuk gmail, dan account detailnya adalah sebagai berikut :

username : otong@gmail.com

password : otongmaritong

, balik ke konsol dan buat directory dan file sbb:

$ mkdir -pv ~/mail/certs $ cd ~/mail/certs $ touch Thawte_Premium_Server_CA.pem $ touch Equifax_Secure_CA.pem $ curl –verbose –output mk-ca-bundle.pl \ http://cool.haxx.se/cvs.cgi/*checkout*/curl/lib/mk-ca-bundle.pl?rev=1.10 $ perl mk-ca-bundle.pl re-Hash tu folder :

$ c_rehash ~/mail/certs/

step 3
setting fetchmail
 
masuk ke home 
$ cd ~

$ vim .fetchmailrc

buat file .fetchmailrc
dan isi file dengan parameter sebagai berikut :
poll pop.gmail.com
with proto POP3
user 'otong@gmail.com'
there with password 'otongmaritong'
is 'otong' here
mda "/usr/bin/procmail -d %T"
options
no keep
ssl
sslcertck
sslcertpath /etc/ssl/certs

set readable ke tuh file
$ chmod 600 ~/.fetchmailrc


step 4
setting procmail
tambahin ni script ke .bashrc
$ cd ~
$ echo "MAIL=/var/spool/mail/otong && export MAIL" >> .bashrc

buat file .procmailrc
$ vim .procmailrc
dan isi tu file dengan parameter ini :
ATH=/bin:/usr/bin:/usr/local/bin
VERBOSE=off
DEFAULT=/var/spool/mail/otong
MAILDIR=$HOME/mail
LOGFILE=$HOME/.procmaillog
# Recipes below this comment:

:0:
* ^TOmutt-user
mutt

step 5
setting msmtp, ni buat ngirim mail.
masuk ke home
$ cd ~
buat file .msmtprc
dan isi file itu dengan parameter sebagai berikut :
account default
host smtp.gmail.com
port 587
from otong@gmail.com
tls on
tls_starttls on
tls_trust_file /home/otong/mail/certs/Thawte_Premium_Server_CA.pem
# tls_trust_file /home/otong/mail/certs/Equifax_Secure_CA.pem
auth on
user otong
password rover
logfile ~/.msmtp.log

make file readable, run this : $ chmod 600 ~/.msmtprc
step 6 setting mutt masuk ke home : $ cd ~ buat file .muttrc $ vim .muttrc dan isi file itu ada parameter ini :

#======================================================#
# Boring details
set realname = "otong
set from = "otong@gmail.com"
set use_from = yes
set envelope_from ="yes"

# Use a signature
set signature="~/.signature"

# Use msmtp rather than sendmail. Check that
# the path is correct for your system:
set sendmail="/usr/bin/msmtp"   

# If not set in ~/.bashrc:
set spoolfile = /var/spool/mail/otong

#======================================================#
# Folders
set folder="$HOME/mail"      # Local mailboxes stored here
set record="+sent"           # Where to store sent messages
set postponed="+postponed"   # Where to store draft messages
set mbox_type=mbox           # Mailbox type
set move=no                  # Don't move mail from spool

#======================================================#
# Watch these mailboxes for new mail, useful only if
# Procmail or Maildrop is used to sort mail.
mailboxes ! +slrn +fetchmail +mutt
set sort_browser=alpha    # Sort mailboxes by alpha(bet)

#======================================================#
# What to show and order of headers
ignore *
unignore Date: From: User-Agent: X-Mailer X-Operating-System To: \
         Cc: Reply-To: Subject: Mail-Followup-To:
hdr_order Date: From: User-Agent: X-Mailer X-Operating-System To: \
        Cc: Reply-To: Subject: Mail-Followup-To:

#======================================================#
# which editor do you want to use?
# vim of course!
set editor="vim -c 'set tw=70 et' '+/^$' "
set edit_headers=yes      # See the headers when editing

#======================================================#
# Lists: An example using the mutt-users list:

lists mutt-users
subscribe mutt-users
set followup_to=yes        # Sets 'Mail-Followup-To' header
set honor_followup_to=yes
fcc-hook mutt-user +mutt   # See your own posts using fcc

#======================================================#
# Odds and ends

set markers          # mark wrapped lines of text in the pager with a +
set smart_wrap       # Don't wrap mid-word
set pager_context=5  # Retain 5 lines of previous page when scrolling.
set status_on_top    # Status bar on top.
push <show-version>  # Shows mutt version at startup

---------------------------------------------------------------------------------------

ok.. finish.. sekarang coba buka mutt $ mutt dan ketik shift-1 (!) dan masukan perintah fetchmail -v ,

jika semua parameter benar.  nanti mail akan ke fetching semua..
ini adalah picture mutt yang udah jalan :

the working mutt

mutt mail client

selamat mencoba
Best Regards
Tommy

Programming Colorfull Console-Program with ncurses

Posted in programming on December 3, 2009 by satriant

dalam windows kita mengenal conio.h, nah dalam linux ada yang namanya ncurse library, library ini mengurusi tentang tampilan program kita.

Preparation :

1. Niat

2. Komputer dengan OS Linux

3. ncurses library

4. gcc tentunya…

5. Rokok 1 bungkus

Lets Start :

$ vim hellofuckingworld.c

// tulis program ini : ……

#include <ncurses.h> /* ga perlu include stdio.h cuz dalem ncurses udah ada */

int main (void)

{

initscr(); /* init screen – hal pertama yang harus di lakukan*/

addstr(“Hello Wondelful World”); /* cetak tu message */

getch();

refresh(); /* refresh layar konsole */

endwin(); /* ini yang harus di lakukan setelah program selesai memakai ncurses mode */

return 0;

}

//fungsi2 manipulasi layar ncurses



Debugging AVR, with Asynchronous UART with LINUX

Posted in programming on October 21, 2009 by satriant

the case :

if you want to get sumthing controlled by computer or you need a data aquition for your microcontroller device….

ok!!

——–indonesia aja deh—–HIDUP INDONESIA!!!

okeh, now asumsikan bahwa smua pack untuk AVR udah kamu install smua, dan kamu telah bisa meng-compile dan men-download the hex file to modul kamu!!

register di AVR yang menangani masalah UART adalah

UCSRA  = 0×00;
UCSRB  = 0×18; pilihan mode
UBRRH = 0×00;
UBRRL  = 0×19; pilihan baud rate

silahkan liat fungsi masing2 bit di Datasheet :) jangan males ya!!

nah untuk meng-konekan antara komputer dan tuh modul, perlu di initialisasikan

standart io di linux.

stdin n stdout

ni adalah initialisinya :

static int uart_putchar(char ch, FILE* stream);
static int uart_getchar(FILE* stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar,NULL,_FDEV_SETUP_WRITE);

static FILE mystdin  = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ);

static int uart_putchar(char ch, FILE* stream) {

if (ch == ‘\n’) {
uart_putchar(‘\r’, stream);
}
loop_until_bit_is_set(UCSRA, UDRE);
UDR = ch;

return 0;
}


static int uart_getchar(FILE *stream) {

char temp;
loop_until_bit_is_set(UCSRA,RXC);
temp = UDR;
uart_putchar(temp, stream);
return(temp);
}

nah itu adalah initialisasi dan fungsi untuk file stream io.

nih main programmnya:

int main(void) {
init_uart();
stdout = &mystdout;
stdin  = &mystdin;
while(1) {
printf(“Hello World UNIX \n”);
delay_ms(1000);
}
return (0);
}

________________________________________________________

PROGRAM LENGKAPNYA

/*
*
*
* Tommy Agustianto
* Progname : Hello World…
* Asych 19200 bps.
*
*/

#define F_CPU 4000000UL
#include <avr/io.h>
#include <avr/iom16.h>
#include <util/delay.h>
#include <stdio.h>

static int uart_putchar(char ch, FILE* stream);
static int uart_getchar(FILE* stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar,NULL,_FDEV_SETUP_WRITE);

static FILE mystdin  = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ);

static int uart_putchar(char ch, FILE* stream) {

if (ch == ‘\n’) {
uart_putchar(‘\r’, stream);
}
loop_until_bit_is_set(UCSRA, UDRE);
UDR = ch;

return 0;
}

static int uart_getchar(FILE *stream) {

char temp;
loop_until_bit_is_set(UCSRA,RXC);
temp = UDR;
uart_putchar(temp, stream);
return(temp);
}

void init_uart() {

UCSRA = 0×00;
UCSRB = 0×18;
UBRRH = 0×00;
UBRRL = 0×19;

}

void delay_ms(int ms) {
unsigned int i;
for (i=0; i<=ms; i++) {
_delay_ms(1);
}
}

int main(void) {
init_uart();
stdout = &mystdout;
stdin  = &mystdin;
while(1) {
printf(“Hello World UNIX \n”);
delay_ms(1000);
}
return (0);
}

nah konekin PD0 dan PD1 di AT16, (tx,rx,+gnd) ke komputer..

configuring terminal di linux…

kamu bisa bikin sendiri terminalnya, ini bisa di buat pake lib. termios.h

atau klo ga mau pusing, pke aja minicom…

# sudo apt-get install minicom

nah klo udah, masuk ke terminal dan ketik minicom…

konfigurasi minicom dengan pencet ctrl+a+o

setting parameternya…

trs jalankan program yang tadi…(download dulu)…

dah liat apa yang terjadi di mincom…

* klo karakternya aneh, itu brati baud rate antara si mikon n si komputer blm sama, silahkan setting minicom lagi!!

BEST REGARDS

TOMMY

Tulisan ini dibuat untuk menyukseskan Lomba Blog Open Source P2I-LIPI dan
Seminar Open Source P2I-LIPI 2009.

http://www.informatika.lipi.go.id/seminar/lombablog/
http://www.informatika.lipi.go.id/seminar/

AVR di LinuX – How To…

Posted in programming on September 17, 2009 by satriant

hehe :)

just smile before you read…

banyak compiler untuk microcontroller yang biasanya di pake oleh para hobi dan mahasiswa di indonesia, pada umumnya di lingkungan windows, compiler yang dipakai adalah Codevision dan Bascom. ya tergantung tu mahasiswa maunya pake bahasa apa. Codevision untuk , Bascom untuk Basic, AVR studio untuk Assembly, AVRco untuk Pascal, dan banyak deh..

nah…hampir semua IDE(integrated development environtment) di atas itu ga gratis cuy, yang gratis palingan cuma AVR studio aja, bawaan Atmel.

ok… now… GOIN’ TO OPEN SOURCE…

opensource avr di lingkungan windows = WinAVR…, winAvr ini adalah IDE gratis buat ngompile dan ngedit2 program AVR pake bahasa C…itu cukup?! TIDAK!!

karena nanggung cuy, klo lo migrasi sistem stengah2…blm tentu juga wuh windows lo tuh asli..nah lo…

AVR-GCC & Linux

ini adalah solusinya…

pilih salah satu distro linux ksukaan lo..(penulis make ubuntu 8.1)

ok.. the steps

1. make sure klo lo pake linux..

2. download paket yang di butuhkan

$ sudo apt-get install gcc-avr

$ sudo apt-get install avr-libc

$ sudo apt-get install avrdude

3. tulis program contoh…misal testled.c

#define F_CPU 12000000UL  //setting crystal yang lo pake
#include <avr/io.h> //standart file IO header
#include <avr/iom16.h> // lib buat atmega16, lo pake apa..misal atmega8, iom8
#include <avr/delay.h>

void delayms(uint16_t millis) {
uint16_t loop;
while ( millis ) {
_delay_ms(1);
millis–;
}
}

int main(void) {
DDRC = 0xFF; /* set jadi Output..*/
while(1) {
PORTC = 0×00; /* LED on */
delayms(1000);
PORTC = 0xFF; /* LED off */
delayms(1000);
}
return 0;
}

4. Buat Makefilenya…

#
# Makefile for Tom’s AVR-Board with STK200 Parallel Programmer
# by Tommy Agustianto <satria.nt@gmail.com>
# ver 0.1
#

CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega16
OBJ2HEX=avr-objcopy
AVRDUDE=avrdude
TARGET=testled

program : $(TARGET).hex
$(AVRDUDE)  -p m16 -P /dev/parport0 -c stk200 -U flash:w:testled.hex
if=$(TARGET).hex -v=2
%.obj : %.o
$(CC) $(CFLAGS) $< -o $@

%.hex : %.obj
$(OBJ2HEX) -R .eeprom -O ihex $< $@

clean :
rm -f *.hex *.obj *.o *~

okeh…smua udah terinstal dan lo juga udah buat file yang di perlukan , jangan lupa tapo tuh testled.c dan Makefile di folder yang sama…

dan ….coba dah lo ketik

make

klo smuanya benar, nanti akan ada tulisan bgini..

tommy@xsatria:~/myprojects/AVR-Linux$ sudo make
[sudo] password for tommy:
avrdude   -p m16 -P /dev/parport0 -c stk200 -U flash:w:testled.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0×1e9403
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file “testled.hex”
avrdude: input file testled.hex auto detected as Intel Hex
avrdude: writing flash (214 bytes):

Writing | ################################################## | 100% 0.18s

avrdude: 214 bytes of flash written
avrdude: verifying flash memory against testled.hex:
avrdude: load data flash data from input file testled.hex:
avrdude: input file testled.hex auto detected as Intel Hex
avrdude: input file testled.hex contains 214 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.20s

avrdude: verifying …
avrdude: 214 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

nah, skarang lepas kabel download lu…dan hehehehe…

IT WORKS…isn’t it?

nih skematik stk200 gw…cuma modal goceng bro…

ga usah pake buffer2an…cuma resistor 4buah n lpt male connector..

toms stk200

toms stk200


Tulisan ini dibuat untuk menyukseskan Lomba Blog Open Source P2I-LIPI dan
Seminar Open Source P2I-LIPI 2009.

http://www.informatika.lipi.go.id/seminar/lombablog/
http://www.informatika.lipi.go.id/seminar/


cara pake pointer di C

Posted in programming on September 10, 2009 by satriant

misal kita punya variabel rumah tipenya integer.   —> int rumah;

nah tuh rumah ada isinya 3 orang..                         —> rumah = 3;

nah ini adalah alamanya dengan menggunakan referensi(&) —> alamat_rumah = &rumah;

next….

nah…

analisa potongan code ini :

int rumah;

int *p; //ini lo baca, nilai yang di tunjukan oleh P

p = &rumah; // nilai P itu adalah alamat Rumah misal 1771

*p = 100; //nah ini brati, nilai yang di tunjukan oleh P adalah 100,

//nilai yang di tunjukin P tiu adalah alamat rumah, nah alamat rumah kan 1771,

//nah alamat 1771 itu di isikan oleh nilai 100;
ok!!

xsatria Rock-ET ver 1.0 [Meteorology & Technology]

Posted in xsatriarobotics on August 11, 2009 by satriant

rock-ET ver 1.0 by Tommy Agustianto

rock-ET ver 1.0 by Tommy Agustianto

the rocket can measure the different of Grafity, when the rocket lauched..the Gravity will be measure by

ADXL type sensor, that can detect the diff of G’….hehe….

not only grafity but also so many things that the rocket can do…measure the temperature, Humidity and Air Pressure….

the data transmitted from the rocket to the ground base [we call it as GROUND SEGMENT] via Wireless Serial Connection.

it’s up to 2 km far…hohoho……

@ the ground segment,we can see the measurement result of the rocket!! before fly away to the sky….the rocket was Calibrated first, to minimalize the error, so the result can closely accurate….

I’ made the software for the ground segment with C, that the software can logging and make a graphic.

I use ATmega8 for controller, I think it’s enough…

@future, I’m planning to make a Inertial Rocket with Navigation System…

so I can control the rocketttt…and fly to moon…….

heheheheeeee……

best regards….

Tommy Agustianto

JIKA KAMI BERSAMA

Posted in my extraordinary life on August 10, 2009 by satriant

ika Kami bersama, nyalakan tanda bahaya
Jika kami berpesta, hening akan terpecah..
Aku, dia dan mereka memang gila memang beda,,
Tak perlu berpura-pura,, memang begini adanya..

Dan kami di sini,,, akan terus bernyanyi…

Dan jika kami bersama nyalakan tanda bahaya..
Musik akan menghentak.. anda akan tersentak!!
Dan kami tahu anda bosan dijejali rasa yang sama
Kami adalah kamu,, muda, beda dan berbahaya..–

(Ini lagunya you’re ready…)  –SDA–
Lepaskan semua belenggu yang melingkari hidupmu
berdiri tegak menantang di sana di garis depan..
aku berteriak lantang untuk jiwa yang hilang..
untuk mereka yang selalu tersingkirkan..
ketika tiada beban lagi untuk berlari,.
Ketika tiada orang yang akan peduli
Aku dan dia selalu menunggumu di sini..
angkat sekali lagi..

Dan kami di sini,,, akan terus bernyanyi.,..

Dan jika Jika Kami bersama nyalakan tanda bahaya..
musik akan menghentak.. anda akan tersentak!!
Aku, dia dan mereka memang gila memang beda,,
aku adalah kamu,, kita muda dan berbahaya..

Dan kami di sini,,, akan terus bernyanyi…

Dan jika Jika kami bersama nyalakan tanda bahaya..
musik akan menghentak.. anda akan tersentak
dan kami tahu anda bosan dijejali rasa yang sama
Kami adalah kamu,, muda beda dan berbahaya..

Dan jika Jika kami bersama nyalakan tanda bahaya..
musik akan menghentak.. anda akan tersentak!!
dan kami tahu anda bosan dijejali rasa yang sama
Kami adalah kamu,, muda beda dan berbahaya..

Write and Read Memory to a File…

Posted in programming on August 3, 2009 by satriant

huh…this my task job for this month…

how to due a memory test in embedded system….

early I dun’t know what things I’ll doin’ first, but now…

I’ve just rec a bright way…

#include <stdio.h>
	#include <stdlib.h>

	int main(void)
	{
		int counter;
		double *ptr_d;
		FILE *ptr_fp;

		/* Part A */
		ptr_d = (double *)malloc(10 * sizeof(double));
		if(!ptr_d)
		{
			printf("Memory allocation error!\n");
			exit(1);
		}else printf("Memory allocation successful.\n");

		/* Part B */
		for(counter = 0; counter < 10; counter++)
			ptr_d[counter] = (double) rand();

		/* Part C */
		if((ptr_fp = fopen("test.txt", "wb")) == NULL)
		{
			printf("Unable to open file!\n");
			exit(1);
		}else printf("Opened file successfully for writing.\n");

		/* Part D */
		if( fwrite(ptr_d, 10*sizeof(double), 1, ptr_fp) != 1)
		{
			printf("Write error!\n");
			exit(1);
		}else printf("Write was successful.\n");
		fclose(ptr_fp);
		free(ptr_d);

		/* Part E */
		ptr_d = (double *)malloc(10 * sizeof(double));
		if(!ptr_d)
		{
			printf("Memory allocation error!\n");
			exit(1);
		}else printf("Memory allocation successful.\n");

		/* Part F */
		if((ptr_fp = fopen("test.txt", "rb"))==NULL)
		{
			printf("Unable to open the file!\n");
			exit(1);
		}else printf("Opened file successfully for reading.\n");

		/* Part G */
		if(fread(ptr_d, 10 * sizeof( double ), 1, ptr_fp) != 1)
		{
			printf( "Read error!\n" );
			exit( 1 );
		}else printf( "Read was successful.\n" );
		fclose(ptr_fp);

		/* Part H */
		printf("The numbers read from file are:\n");
		for(counter = 0; counter < 10; counter++)
			printf("%f ", ptr_d[counter]);

		/* Part I */
		free(ptr_d);
		return 0;
	}


Part A: Memory Allocation

After some variable declaration we start the program with a memory allocation statement. A piece of memory is requested using malloc with a size of 10 times the size of a double. A pointer ptr_d is used to point to this piece of memory. The rest of part A does some simple error handling.

Part B: Generating Random Numbers

Part B is used to generate some random numbers (using rand function) that are placed into our allocated piece of memory. We request for 10 random numbers. The rest of part B does some simple error handling.

Part C: Open a File for Writing

Part C creates an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file. In order to open a file as a binary file (instead of text), a "b" character has to be included in the mode string. The rest of part C does some simple error handling.

Part D: Write the Array

In part D the content of the array is written to the file that was opened in part C. After the array content has been written to the file, the file is closed (fclose function) and the allocated memory is released (free function.) The rest of part D does some simple error handling.

Part E: Memory Allocation

Once again a piece of memory is allocated. This piece of memory is used to write the memory to after we have read it from the file in the next part. The rest is some simple error handling.

Part F: Open Binary File for Reading

Almost the same as part C, but instead of opening the file for writing the file is opened for reading by using "rb" in the mode string. The rest is some simple error handling.

Part G: Reading the Binary File

Almost the same as writing the entire array to the file, but instead we use the fread function to read the content of the file. After the read the file is closed using the function fclose. The rest is some simple error handling. We now have written memory content to a file and read the content of the file back into another piece of memory. So we could have stopped here, but it's always nice to visualize things and that is where the last part is for.

Part H: Display Content

Once again we make a loop. This loop is used to print each member of the array onto the screen, nothing special.

Part I: Free Memory

As a last act we free the memory that we asked for in part E, so we don't create any memory leaks.