2007/08/29

Change radio transmit power and frequency on Tmote

http://www.moteiv.com/community/Change_radio_transmit_power_and_frequency

---Backup the article

Change frequency at compile time

One way to set the CC2420 radio channel is to do it at compile time by assigning the environment variable CC2420_CHANNEL perhaps like this

export CC2420_CHANNEL=12

The valid channels for the CC2420 are 11 to 26, and the default is channel 11. You can put that export command in your login script such as ~/.bashrc to make it persistent across login sessions. If you want a radio channel specific to an application, you can put a similar command in that application's Makefile, like this

CC2420_CHANNEL=12

The next time you build your application, the changes will take effect. Do not forget to also recompile and reinstall TOSBase with the new channel, as well, if applicable.

Change transmit power at compile time

To change the transmit power at compile time, you will need to predefine a preprocessor directive called CC2420_DEF_RFPOWER. To do this, define your compile flags "CFLAGS" before compiling your application. You must specify a power index from 1 to 31. The valid values are 1 through 31 with power of 1 equal to -25dBm and 31 equal to max power (0dBm)

CFLAGS=-DCC2420_DEF_RFPOWER=x make tmote

Change transmit power or frequency at run time

Another way to set the CC2420 radio channel or transmit power is to use the CC2420Control interface provided by the CC2420RadioC component. The two applicable commands are

command result_t TunePreset( uint8_t rh, uint8_t channel );
command result_t SetRFPower( uint8_t rh, uint8_t power );

rh
Either RESOURCE_NONE for automatic resource scheduling or a resource handle acquired by the CC2420ResourceC component. Note, this parameter is not present in any of the commands in the TinyOS 1.x CC2420Control interface

channel
One of the valid 802.15.4 present channels. Valid channel values are 11 through 26. The channel frequencies are calculated by

Freq = 2405 + 5(k-11) MHz for k = 11,12,...,26

power
A power index from 1 to 31. The input value is simply an arbitrary index that is programmed into the CC2420 registers. The output power is set by programming the power amplifier. The valid values are 1 through 31 with power of 1 equal to -25dBm and 31 equal to max power (0dBm)

2007/08/28

The Big Ol' Ubuntu Security Resource

http://www.itsecurity.com/features/ubuntu-secure-install-resource


Watch video in Ubuntu

1. Add new repository following http://medibuntu.sos-sts.com/repository.php

2. Install codecs


sudo apt-get update
sudo apt-get install gstreamer0.10-alsa \
gstreamer0.10-esd \
gstreamer0.10-ffmpeg \
gstreamer0.10-fluendo-mpegdemux \
gstreamer0.10-gnomevfs \
gstreamer0.10-plugins-base \
gstreamer0.10-plugins-base-apps \
gstreamer0.10-plugins-good \
gstreamer0.10-plugins-ugly gstreamer0.10-x
sudo apt-get install w32codecs \
libdvdcss2 \
libxine-extracodecs \
totem-xine \
ffmpeg \
lame \
faad \
sox \
mjpegtools \
libxine-main1



3. Upgrade



sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade



2. Set preferences
Select video driver to xv (X11/Xv)

Reference:
http://tw.myblog.yahoo.com/jw!Z3YOJZSGER5taqtYmemK3uSU/article?mid=368&prev=-1&next=366
http://54061.blogspot.com/2007/03/ubuntu-704-codec-rmvb.html
http://www.ubuntu.org.tw/modules/newbb/viewtopic.php?topic_id=4041&viewmode=flat&order=ASC&type=&mode=0&start=30
http://www.ubuntu.org.tw/modules/newbb/viewtopic.php?topic_id=42&viewmode=flat&order=ASC&type=&mode=0&start=0

2007/08/27

Server list

YZU

bbs.cse.yzu.edu.tw 2200 FreeBSD 4.11-STABLE *
freebsd.netlab.cse.yzu.edu.tw 22 Ubuntu
OSs.CNA.CCu.Edu.Tw 23
bbs.yzu.edu.tw 22 FreeBSD 4.11-STABLE *
linux.netlab.cse.yzu.edu.tw 22 Linux version 2.6.10-1.771_FC2
moon.cse.yzu.edu.tw 9999 FreeBSD 6.2-STABLE
webbbs.yzu.edu.tw 22 FreeBSD 6.2-STABLE *

NCU

sokoyo.csit.tw 2222 Ubuntu 7.10 *
axp1.csie.ncu.edu.tw 5330 Linux version 2.6.19-1.2911.fc6PAE
sparc12.cc.ncu.edu.tw 22 Solaris
sparc13.cc.ncu.edu.tw 22 Solaris
sparc14.cc.ncu.edu.tw 22 Solaris
sparc15.cc.ncu.edu.tw 22 Solaris
sparc19.cc.ncu.edu.tw 22 Linux version 2.6.17-1.2142_FC4
sparc20.cc.ncu.edu.tw 22 Linux version 2.6.17-1.2142_FC4

2007/08/18

Build Octopus develop environment

What is Octopus?

1. Install Moteiv's Tmote Tools from http://www.moteiv.com/

If already installed Cygwin, I recommend uninstall Cygwin firstly. Secondly,
to run setup.msi from tmote-tools-2_0_5.zip. Finally, to upgrade or install
other Cygwin packages.

2. Copy and Modify target file


shell> cd /opt/moteiv/tools/make/
shell:/opt/moteiv/tools/make/> cp tmote.target octopus.target



octopus.target




...

-PLATFORM ?= tmote
+PLATFORM ?= octopus

...

-CFLAGS += \
--I$(MOTEIV_DIR)/tos/platform/tmote \
--I$(MOTEIV_DIR)/tos/platform/tmote/util/uartdetect \
+CFLAGS += \
+-I$(MOTEIV_DIR)/tos/platform/octopus \
+-I$(MOTEIV_DIR)/tos/platform/octopus/util/uartdetect \

...

- BOOTLOADER ?= $(MOTEIV_DIR)/tos/lib/Deluge/TOSBoot/build/tmote/main.ihex
+ BOOTLOADER ?= $(MOTEIV_DIR)/tos/lib/Deluge/TOSBoot/build/octopus/main.ihex

...

-tmote: $(BUILD_DEPS)
+octopus: $(BUILD_DEPS)

...




3. Create octopus directory


shell> cp -r /opt/moteiv/tos/platform/tmote /opt/moteiv/tos/platform/octopus



4. Modify hardware.h file

/opt/moteiv/tos/platform/octopus/hardware.h




...

// LEDs
TOSH_ASSIGN_PIN(RED_LED, 5, 4);
TOSH_ASSIGN_PIN(GREEN_LED, 5, 5);
-TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6);
+TOSH_ASSIGN_PIN(YELLOW_LED, 5, 3);
+TOSH_ASSIGN_PIN(BLUE_LED, 5, 6);

...

TOSH_ASSIGN_PIN(STE1, 5, 0);
+TOSH_ASSIGN_PIN(BUFFER_CS, 4, 3);

// ADC
TOSH_ASSIGN_PIN(ADC0, 6, 0);

...

// FLASH
-TOSH_ASSIGN_PIN(FLASH_PWR, 4, 3);
+TOSH_ASSIGN_PIN(FLASH_W, 4, 0);
TOSH_ASSIGN_PIN(FLASH_CS, 4, 4);

...




5. Copy and Modify HPLUSART1M.nc file


shell> cp /opt/moteiv/tos/platform/msp430/HPLUSART1M.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/HPLUSART1M.nc




...

async command result_t USARTControl.tx(uint8_t data){
atomic {
+ TOSH_CLR_BUFFER_CS_PIN();
U1TXBUF = data;
}
return SUCCESS;
}

...




6. Copy and Modify Leds.nc file


shell> cp /opt/tinyos-1.x/tos/interfaces/Leds.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/Leds.nc




interface Leds {

...

/**
* Toggle the yellow LED. If it was on, turn it off. If it was off,
* turn it on.
*
* @return SUCCESS always.
*
*/
async command result_t yellowToggle();

+ async command result_t blueOn();
+ async command result_t blueOff();
+ async command result_t blueToggle();

/**
* Get current Leds information
*
* @return A uint8_t typed value representing Leds status
*
*/
async command uint8_t get();

...
}



7. Copy and Modify LedsC.nc file


shell> cp /opt/tinyos-1.x/tos/system/LedsC.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/LedsC.nc




...

enum {
- RED_BIT = 1,
- GREEN_BIT = 2,
- YELLOW_BIT = 4
+ BLUE_BIT = 1,
+ GREEN_BIT = 2,
+ RED_BIT = 4,
+ YELLOW_BIT = 8
};

async command result_t Leds.init() {
atomic {
ledsOn = 0;
dbg(DBG_BOOT, "LEDS: initialized.\n");
TOSH_MAKE_RED_LED_OUTPUT();
TOSH_MAKE_YELLOW_LED_OUTPUT();
TOSH_MAKE_GREEN_LED_OUTPUT();
+ TOSH_MAKE_BLUE_LED_OUTPUT();
TOSH_SET_RED_LED_PIN();
TOSH_SET_YELLOW_LED_PIN();
TOSH_SET_GREEN_LED_PIN();
+ TOSH_SET_BLUE_LED_PIN();
}
return SUCCESS;
}

...

async command result_t Leds.yellowToggle() {
result_t rval;
atomic {
if (ledsOn & YELLOW_BIT)
rval = call Leds.yellowOff();
else
rval = call Leds.yellowOn();
}
return rval;
}

+ async command result_t Leds.blueOn() {
+ dbg(DBG_LED, "LEDS: Blue on.\n");
+ atomic {
+ TOSH_CLR_BLUE_LED_PIN();
+ ledsOn |= BLUE_BIT;
+ }
+ return SUCCESS;
+ }

+ async command result_t Leds.blueOff() {
+ dbg(DBG_LED, "LEDS: Blue off.\n");
+ atomic {
+ TOSH_SET_BLUE_LED_PIN();
+ ledsOn &= ~BLUE_BIT;
+ }
+ return SUCCESS;
+ }

+ async command result_t Leds.blueToggle() {
+ result_t rval;
+ atomic {
+ if (ledsOn & BLUE_BIT)
+ rval = call Leds.blueOff();
+ else
+ rval = call Leds.blueOn();
+ }
+ return rval;
+ }

async command uint8_t Leds.get() {
uint8_t rval;
atomic {
rval = ledsOn;
}
return rval;
}

async command result_t Leds.set(uint8_t ledsNum) {
atomic {
- ledsOn = (ledsNum & 0x7);
+ ledsOn = (ledsNum & 0xF);
if (ledsOn & GREEN_BIT)
TOSH_CLR_GREEN_LED_PIN();
else
TOSH_SET_GREEN_LED_PIN();
if (ledsOn & YELLOW_BIT )
TOSH_CLR_YELLOW_LED_PIN();
else
TOSH_SET_YELLOW_LED_PIN();
if (ledsOn & RED_BIT)
TOSH_CLR_RED_LED_PIN();
else
TOSH_SET_RED_LED_PIN();
+ if (ledsOn & BLUE_BIT)
+ TOSH_CLR_BLUE_LED_PIN();
+ else
+ TOSH_SET_BLUE_LED_PIN();
}
return SUCCESS;
}

...




8. Copy MSP430ClockM.nc file


shell> cp /opt/moteiv/tos/platform/msp430/timer/MSP430ClockM.nc /opt/moteiv/tos/platform/octopus/



9. Copy and Modify MSP430GeneralIOM.nc file


shell> cp /opt/tinyos-1.x/tos/platform/msp430/MSP430GeneralIOM.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/MSP430GeneralIOM.nc




...

- async command uint8_t Port12.getRaw() { return TOSH_READ_PORT12_PIN(); }
- async command bool Port12.get() { return TOSH_READ_PORT12_PIN() != 0; }
+ async command uint8_t Port12.getRaw() { TOSH_READ_PORT12_PIN(); return 1;}
+ async command bool Port12.get() { TOSH_READ_PORT12_PIN(); return 1;}

...




10. Copy and Modify NoLeds.nc file


shell> cp /opt/moteiv/tinyos-1.x/tos/system/NoLeds.nc /opt/moteiv/tos/platform/octopus/



/opt/moteiv/tos/platform/octopus/NoLeds.nc




...

async command result_t Leds.yellowToggle() {
return SUCCESS;
}

+ async command result_t Leds.blueOn() {
+ return SUCCESS;
+ }

+ async command result_t Leds.blueOff() {
+ return SUCCESS;
+ }

+ async command result_t Leds.blueToggle() {
+ return SUCCESS;
+ }

async command uint8_t Leds.get() {
return 0;
}

...




11. Modify and Compile SerialByteSource.java file

/opt/tinyos-1.x/tools/java/net/tinyos/packet/SerialByteSource.java




...

public void openStreams() throws IOException {

...

try {
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
serialPort.setSerialPortParams(baudRate,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);

+ // elva set COM port pin(DTR) to LOW
+ serialPort.setDTR(false);
+ // elva end of modify

serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
}

...

is = serialPort.getInputStream();
os = serialPort.getOutputStream();

+ // elva delay for mote reboot
+ try {
+ Thread.sleep(1300);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ // elva end of modify
}

...



Complie SerialByteSource.java file


shell> cd /opt/tinyos-1.x/tools/java/net/tinyos/packet
shell:/opt/tinyos-1.x/tools/java/net/tinyos/packet> javac SerialByteSource.java



appendix 1. Make an example application


shell> cd /opt/moteiv/apps/Count/CountLeds
shell:/opt/moteiv/apps/Count/CountLeds> make octopus



appendix 2. Run an example application


shell> export MOTECOM=serial@COM6:tmote
shell> cd /opt/tinyos-1.x/tools/java/net/tinyos/tools
shell:/opt/tinyos-1.x/tools/java/net/tinyos/tools> java net.tinyos.tools.Listen



appendix 3. Set Node ID: 5

shell:/opt/moteiv/apps/Count/CountLeds> /opt/tinyos-1.x/tools/make/msp/set-mote-id --objcopy msp430-objcopy --objdump msp430-objdump --target ihex build/octopus/main.ihex build/octopus/main.ihex.out-5 5

.vimrc file

The backup of .vimrc file

2007/08/17

NS2 Installation on UNIX based system (Daily Snapshot)

1. Download Tcl/Tk from http://www.tcl.tk/software/tcltk/


shell> wget http://prdownloads.sourceforge.net/tcl/tcl8.4.15-src.tar.gz
shell> wget http://prdownloads.sourceforge.net/tcl/tk8.4.15-src.tar.gz



2. Download daily NS2 from http://www.isi.edu/nsnam/dist/daily/


shell> wget http://www.isi.edu/nsnam/dist/daily/nam-1-XXXXXXXX.tar.gz
shell> wget http://www.isi.edu/nsnam/dist/daily/ns-2-XXXXXXXX.tar.gz
shell> wget http://www.isi.edu/nsnam/dist/daily/otcl-XXXXXXXX.tar.gz
shell> wget http://www.isi.edu/nsnam/dist/daily/tclcl-XXXXXXXX.tar.gz



3. De-compress all file in custom directory (ex: ~/ns-daily-2.31/)

4. Recommand touch a file for the version of ns2


shell:~/ns-daily-2.31/> touch 20070815



5. Using following shell script to configure and make files

install.sh
[code]
#!/bin/bash

# tcl
cd tcl8.4.15/unix
./configure --enable-shared
make
cd ../..

# tk
cd tk8.4.15/unix
./configure --enable-shared
make
cd ../..

# otcl
cd otcl
./configure --disable-static --with-tcl-ver=8.4.15 --with-tk-ver=8.4.15
make
cd ..

# tclcl
cd tclcl
./configure --disable-static --with-tcl-ver=8.4.15 --with-tk-ver=8.4.15
make
cd ..

# ns-2
cd ns-2
./configure --disable-static --with-tcl-ver=8.4.15 --with-tk-ver=8.4.15 \
--with-otcl=../otcl --with-tclcl=../tclcl
make
cd ..

# nam-1
cd nam-1
./configure --disable-static --with-tcl-ver=8.4.15 --with-tk-ver=8.4.15 \
--with-otcl=../otcl --with-tclcl=../tclcl
make
cd ..

echo "Installation complete"
[/code]

If this fail, try Distribution Specific instructions

If this error for file pcap.h not existed, install libpcapX.X-dev

If this success, only needing to upgrade OTcl, TclCL, ns-2 and nam-1 in the future

6. Create soft link for needing files


shell:~/ns-daily-2.31/> mkdir bin
shell:~/ns-daily-2.31/> mkdir lib
shell:~/ns-daily-2.31/> cd bin
shell:~/ns-daily-2.31/bin/> ln -s ../ns-2/ns .
shell:~/ns-daily-2.31/bin/> ln -s ../nam-1/nam .
shell:~/ns-daily-2.31/bin/> cd ../lib/
shell:~/ns-daily-2.31/lib/> ln -s ../tcl8.4.15/unix/libtcl8.4.so .
shell:~/ns-daily-2.31/lib/> ln -s ../tk8.4.15/unix/libtk8.4.so .



7. Add following setting to set NS2 environment

.bashrc
[code]
# NS2 environment
PATH=/home/USER/ns-daily-2.31/bin:$PATH
LD_LIBRARY_PATH=/home/USER/ns-daily-2.31/bin:/home/USER/ns-daily-2.31/lib
TCL_LIBRARY=/home/USER/ns/ns-daily-2.31/tcl8.4.15/library
export PATH LD_LIBRARY_PATH TCL_LIBRARY
[/code]

8. Make Documentation


shell:~/ns-daily-2.31/ns-2/doc> make



If you want to create html documentation, install latex2html firstly

2007/08/16

Problems with installation ns-2.31 under Cygwin

Reference:
[ 1393985 ] validation fails under Cygwin
http://mailman.isi.edu/pipermail/ns-users/2006-December/058117.html

Error Message:


validate overall report: some tests failed:
./test-all-smac-multihop ./test-all-simultaneous ./test-all-wireless-tdma
to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME
Notice that some tests in webcache will fail on freebsd when -O is turned on.
This is due to some event reordering, which will disappear when -g is turned on.

Cygwin >= 1.3.19 detected (1.5.24), all tests should have passed.
Please see <http://www.isi.edu/nsnam/ns/ns-problems.html>
for potential solutions.



Solution:

Those tests currently fail on Cygwin.

2007/08/11

懷舊

整理了以前蒐集的美女相簿

看到一些推文

回想起當初

好懷念從前

不想長大

長大才發現人心的險惡

長大才發現自己的不足

長大才發現我真討人厭

2007/08/09

MySQL Backup

http://dev.mysql.com/doc/refman/5.0/en/backup-strategy-example.html

main command:

shell> mysqldump -uroot -p --single-transaction --flush-logs --master-data=2\
--all-databases > db.sql



backup script
[code]
#!/bin/sh

BACKUP_DIR="/backup"

ROOT_PASSWORD="password"

DATE=`date +%y%m%d`

SQL_FILE=db$DATE.sql
TGZ_FILE=db$DATE.tgz

cd $BACKUP_DIR

mysqldump -uroot -p$ROOT_PASSWORD --single-transaction --flush-logs --master-data=2 --all-databases > $SQL_FILE

tar zcvf $TGZ_FILE $SQL_FILE

rm $SQL_FILE
[/code]

2007/08/05

安裝兩張以上網卡備忘

/etc/network/interfaces 內只能設一個 gateway

否則 routing table 會出現一個以上的 default route

可能造成從非期望的網卡 route 出封包

2007/08/03

Install GloMoSim

GloMoSim in ubuntu http://axp1.csie.ncu.edu.tw/~rick/blog/?p=4
GloMoSim in Windows http://axp1.csie.ncu.edu.tw/~rick/blog/?p=5

---

Backup the archives


0. Windows: Install VC6
Others: Install gcc
1. Download from http://pcl.cs.ucla.edu/projects/glomosim/academic/topsecret_download.html
2. De-compress
3. Set 『PCC_DIRECTORY』 environment variable = 『glomosim-2.03/parsec/The OS
4. Add 『Path』 environment variable = 『glomosim-2.03/parsec/The OS/bin』
5. Windows: change directory to 『glomosim-2.03/glomosim/main/』 & run 『makent.bat』
Others: change directory to 『glomosim-2.03/glomosim/main/』 & run 『make』
6. Windows: To find 『glomosim2.03/glomosim/bin/glomosim.exe』
Others: To find 『glomosim2.03/glomosim/bin/glomosim』