Monday, August 03, 2009

YuShanNet - Base Station Installation Guide

 



  • Overview - Base Station Functionality


Helping forwarding the user tags' information to the server.

Using 3G communicate to the server.

 



  • Install Debian From USB CD-ROM


Do NOT install any addiction package (space is limited)



  • Install required package


apt-get install libdevice-serialport-perl


apt-get install expect


apt-get install wvdial


apt-get install rsync


apt-get install beep


apt-get install ntpdate




  • Change time zone

ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime



  • Edit wvdial.conf


vim /etc/wvdial.conf

 

[Dialer Defaults]
Init1 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

Modem Type = USB Modem

IDSN = 0

New PPPD = yes

Phone = *99#

Modem = /dev/ttyUSB1

Username = default

Password = default

Ask Password = 0

Dial Command = ATD

Stupid Mode = yes



  •  Create udev rule for serial device

vim /etc/udev/rules.d/taroko.rules 
 

kerne;="ttyUSB*", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", SYMLINK="TAROKO"



vim /etc/udev/rules.d/battery.rules

 

KERNEL=="ttyUSB*", SYSFS{idVendor}=="067b", SYSFS{idProduct}=="2303", SYMLINK="BATTERY"



  •  Edit rc.local


vim /etc/rc.local

 

/usr/bin/wvdialconf

/usr/bin/wvdial &

sh /root/BaseStation/run &

sh /root/BatteryMonitor/run &

sh /root/check.sh

exit 0



  • Copy and extract Base Station file to /root

 File structure
 

    /root

    |
    |-- BaseStation
    |   |-- SerialForwarder.pl
    |   |-- run
    |   |-- send
    |   |   `-- message
    |   `-- wildernessnet.sql
    |-- BatteryMonitor
    |   |-- SerialBattery.pl
    |   `-- run
    |-- check.sh
    `-- cmdSender.sh



  •  Add crontab tasks


crontab -e

 


# m h  dom mon dow   command

*        *    *     *       *       sh /root/cmdSender.sh "/sbin/ifconfig" "/root/BaseStation/send/message/" "network.log"

*/10    *    *    *       *       sh /root/cmdSender.sh "sh /root/check.sh" "/root/BaseStation/send/message/" "check.log"

*        *    *    *       *       rsync -av --compress --remove-source-files --timeout=10 --progress /root/BaseStation/send/ YuShanNet@140.112.42.162:/home/nas/YuShanNet/StarBox/data > /root/rsync.log 



  •  Add ssh key to server


ssh-keygen at StarBox (no passphrase)

copy the content of id_rsa.pub to the authorized_keys at the server

 


 




  •  Programs description


SerialForwarder.pl      Receive the message from user's tag and forward to PC

SerialBattery.pl         Communication with the battery
check.sh                   PC self-check procedure

cmdSender.sh           Dump command inforamtion

 

All data that needed to send to the server will be placed under BaseStation/send directory.

Once the data is sent successfully, the data will be deleted.

 

  

 

 

 

Tuesday, January 06, 2009

Picture flow for ARM embedded system

This is the final project of SOC design lab. The goal is using FPGA to decoding jpeg files and show the pictures on the LCD screen. We use touch panel ( not support multi-touch) to create ipod like picture view applicaiton.



Tuesday, August 12, 2008

How to compile the g++ object file with gcc

Here is an example shows how to compiler a program with gcc with objects files which are compiled by g++

Example codes:
( Reference from here )

test.c 
 #include
 #include
 #include "adio.h"
 #include "adstring.h"
 int main()
 {
  char input[21];
  char buffer[11];
  char buf[11];
  const char* str = "hello world!!";
  adstring_strcpy(buffer, str, 11);
  puts(buffer);
  adio_fgets(input, 21, stdin);
  puts(input);
  adstring_strcpy(buffer, input, 5);
  puts(buffer);
  int a = 12345;
  puts(adstring_itoa(buf, a, 11));
  puts(buf);
  return 0;
 }

adio.h
 #ifndef ADVENCE_IO_H
 #define ADVENCE_IO_H
 #include
 char* adio_fgets(char* buf, int num, FILE* fp);
 void adio_stdinclean(void);
 #endif

adstring.h
 #ifndef ADVENCE_STRING_H
 #define ADVENCE_STRING_H
 char* adstring_strcpy(char* to, const char* from, int num);
 char* adstring_itoa(char* to, int from, int num);
 #endif

adio.c
 #include
 #include
 char* adio_gets(char* buf, int num, FILE* fp)
 {
  char* find = 0;
  fgets(buf, num, stdin);
  if ((find = strrchr(buf, '\n')))
  {
   *find = '\0′;
  }
  else
  {
   while (fgetc(fp) != '\n');
  }
  return buf;
 }
 void adio_stdinclean()
 {
  while (getchar() != '\n');
 }

adstring.c
 #include
 #include
 char* adstring_strcpy(char* to, const char* from, int num)
 {
  int size = num-1;
  strncpy(to, from, size);
  if (strlen(from) >= size)
  {
   to[size] = '\0′;
  }
  return to;
 }
 char* adstring_itoa(char* to, int from, int num)
 {
  char tmp[11];
  sprintf(tmp, "%d", from);
  adstring_strcpy(to, tmp, num);
  return to;
 }



Make static library , here we assume object files need to be compiler in g++
 g++ adio.c adstring.c -Wall -c (this line will come out with adio.o adstring.o)
 ar rcs libadlib.a adio.o adstring.o (archieve into libadlib.a file)

 gcc test.c -I. -L. -ladlib -o test

Here, there are some errors say that the function with object files is not found.
The reason is that compiler will change c++'s function name while compiling.
In order to tell compiler not to change function name, we can use extern "C"

We can modify adio.c adstring.c into :

adio.c
 #include
 #include

 #ifdef __cplusplus
 extern "C" {
 #endif

 char* adio_gets(char* buf, int num, FILE* fp)
 {
  char* find = 0;
  fgets(buf, num, stdin);
  if ((find = strrchr(buf, '\n')))
  {
   *find = '\0′;
   }
  else
  {
   while (fgetc(fp) != '\n');
  }
  return buf;
 }
 void adio_stdinclean()
  {
  while (getchar() != '\n');
 }

 #ifdef __cplusplus
 }

 #endif

adstring.c
 #include
 #include

 #ifdef __cplusplus
 extern "C" {
 #endif


 char* adstring_strcpy(char* to, const char* from, int num)
 {
  int size = num-1;
  strncpy(to, from, size);
  if (strlen(from) >= size)
  {
   to[size] = '\0′;
  }   return to;
 }
 char* adstring_itoa(char* to, int from, int num)
 {
  char tmp[11];
  sprintf(tmp, "%d", from);
  adstring_strcpy(to, tmp, num);
  return to;
 }


 #ifdef __cplusplus
 }
 #endif

Saturday, July 26, 2008

Indoor Localization - Position System


This is the program I wrote for visualize indoor localization system.

I use GTK+2.x to implement GUI and the detail description is at the webpage of the program.

If there are any questions or suggestions, please feel free to email to me. Thanks

Program webpage: LINK

Friday, July 11, 2008

Complie MASE alpha version problem

It can be complied with pisa version, however there are some error inforamation pop out using alpha configuraiton.simplescalar

There are two files need to be midified

1.machine.h a. (line 223)
= orginal =
/* internal decoder state */
extern enum md_opcode md_mask2op[];
extern unsigned int md_opoffset[];
extern unsigned int md_opmask[];
extern unsigned int md_opshift[];

= change into =
extern enum md_opcode md_mask2op[MD_MAX_MASK+1];
extern unsigned int md_opoffset[OP_MAX];
extern unsigned int md_opmask[OP_MAX];
extern unsigned int md_opshift[OP_MAX];

b. codes below part a
/* global opcode names, these are returned by the decoder (MD_OP_ENUM()) */
enum md_opcode {
OP_NA = 0, /* NA */
#define DEFINST(OP,MSK,NAME,OPFORM,RES,FLAGS,O1,O2,I1,I2,I3) OP,
#define DEFLINK(OP,MSK,NAME,MASK,SHIFT) OP,
#define CONNECT(OP)
#include "machine.def"
OP_MAX /* number of opcodes + NA */ };

move them before part a

2.mae-mem.c (line 132)
= orginal =
static unsigned int /* total latency of access */

= change into =
unsigned int /* total latency of access */

There some bugs that have been discoveried.
Reference by:http://www.cc.gatech.edu/~loh/mase/

How to connect to wireless AP in text mode

INTERFACE_NAME: your wireless interface name, you can find it by "wconfig" command
AP_NAME : the ap you want to connect
AP_PASSWARD: the key for the AP_NAME

[root@localhost ~]# iwconfig INTERFACE_NAME essid "AP_NAME" key "AP_PASSWARD"

if the IP is accessed by DHCP
[root@localhost ~]# dhclient INTERFACE_NAME

Wednesday, June 18, 2008

GdkFont usage

To use GdkFont, you must specify the font name
And it must specify by a XLFD describing

The simplest way is set "-*-*-medium-r-normal--N-*-*-*-p-*-*-1"
N = the font size

mase simplescalar make error

There are two possible errors due to newer version of gcc.

1. /lib64/libc.so.6: could not read symbols: Bad value
( if the system is 32-bit, error might be /lib/libc.so.6: could not read symbols: Bad value )
  mark all "extern int errno;" ( eval.c misc.c range.c )
  and replace it by "#include "

2. mase-mem.c:134: error: static declaration of ‘mem_access_latency’ follows non-static declaration
mase-mem.h:104: error: previous declaration of ‘mem_access_latency’ was here
  find "mem_access_latency" in mase-mem.h and delete "static"

Tuesday, May 27, 2008

ns2 multicase problem in x86_64 system

I use ns-allinone-2.31 to build a ns2 enviroment in x86_64 linux system.
But there is a problem while running multicase in dense mode ( i don't this problem also happen in sparse mode). The multicased packets are flooding over the entire network.

The reason of this problem is in "MCastClassifier::classify(Packet *pkt)" in classifier-mcast.cc.

The original code is:
 if (p == 0) {
   // Didn't find an entry.
   tcl.evalf("%s new-group %d %d %d cache-miss", name(), src, dst, iface);

Try to change into:
 if (p == 0) {
   // Didn't find an entry.
   tcl.evalf("%s new-group %ld %ld %d cache-miss", name(), src, dst, iface);

Monday, May 19, 2008

ns2 nam編譯問題

使用ns2提供的allinone2.31.tar編譯時,nam會發生下面這個問題

......
nam_stream.o: In function `NamStreamCompressedFile::gets(char*, int)':
nam_stream.cc:(.text+0x1071): undefined reference to `gzgets'
nam_stream.o: In function `NamStreamCompressedFile::NamStreamCompressedFile(char const*)':
nam_stream.cc:(.text+0x10b4): undefined reference to `gzopen'
nam_stream.o: In function `NamStreamCompressedFile::NamStreamCompressedFile(char const*)':
nam_stream.cc:(.text+0x1136): undefined reference to `gzopen'
collect2: ld returned 1 exit status
make: *** [nam] Error 1

這個問題只要把nam資料夾下的Makefile稍作修改即可

LIB = \
-L/home/hct/ns-allinone-2.31/tclcl-1.19 -ltclcl -L/home/hct/ns-allinone-2.31/otcl -lotcl -L/home/hct/ns-allinone-2.31/lib -ltk8.4 -L/home/hct/ns-allinone-2.31/lib -ltcl8.4 -lz \

(紅字為增加部份)

Wednesday, May 14, 2008

Gtkmm under Windows using Microsoft Visual Stuido 2005

Gtkmm基本上算是GTK的延伸,差異在於他將GTK修改成C++的語法
在Visual Stuido 2005的安裝方法gtkmm_windows
首先要先下載Gtk+Gtkmm development package
若是使用vista的使用者,Visual Stuido 2005須先安裝sp1

照著網頁上的說明即可,不過我編譯的時候出現下列錯誤
LNK1104 : cannot open file 'cairo.lib'
不知道為什麼,明明我都沒有連結到cairo.lib.
最後我把安裝C:\GTK\lib\cairomm-1.0d.lib複製一份名稱改成cairo.lib
這樣就可以正常編譯執行,非常的神奇....

Friday, February 01, 2008

Installing TinyOS 2.0.2

因為我在Vista裝不起來TinyOS, 所以就把腦筋動到Linux下


http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html
照tinyos的網頁安裝即可,我使用的Linux是Suse 10.3
另外我是安裝TI MSP430 Tools
最後在home下的.bashrc加上
export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.
export TOSROOT=/opt/tinyos-2.x
export TOSDIR=$TOSROOT/tos
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:$PATH

最後如果在make telosb install.1 bel,/dev/ttyUSB0執行時發生can't not find serial
http://software.opensuse.org/search搜尋 python-serial 安裝後應該就可以成功

Saturday, January 05, 2008

VMware Failed to allocate page for guest RAM

當vmware的檔案是複製的時候
power on 可能會發生"Failed to allocate page for guest RAM"的錯誤

Solusion
在檔案所在目錄找到 *.vmx
並加入一行mainmem.UseNamedFile = "false"

Friday, July 20, 2007

Install Flash Player in x86_64 system

1.download nspluginwrapper rpm packages, plugin and viewer are need.
2.install nspluginwrapper
#rpm -ivh nspluginwrapper-i386-0.9.91.4-1.x86_64.rpm
#rpm -ivh nspluginwrapper-0.9.91.4-1.x86_64.rpm

3.download flashplayer from adobo.com
install flash-plugin ,so libflashplayer.so in the /usr/lib64/flash/ or other where,
$locate libflashplayer.so you can find it.

4.$cp libflashplayer.so ~/.mozilla/plugins/
5.$nspluginwrapper -i ~/.mozilla/plugins/libflashplayer.so

Friday, June 08, 2007

GTK2+ 在win32下執行

之前在Linux下使用GTK2+來寫GUI介面,因看到網路上說GTK2+在windows下也能編譯執行,所以就突發奇想試試看能不能把程式移植到windows上。

首先下載GTK2.4 for win32

安裝至電腦裡時,他會出現是否要把library跟include檔案加入到電腦裡已知的編譯環境下。測試過Dec C++ 跟 VC++ ,不過編譯環境要先安裝才會有作用(建議讓GTK2.4幫你加入,因為檔案不少)。

接下來就是編譯GTK的程式,除了上面說的要把library跟include檔案加入到電腦裡已知的編譯環境,還需設定連結(linker)參數,這時候就要在project setting的link裡面,加入如下:
glib-2.0.lib gtk-win32-2.0.lib gdk-win32-2.0.lib gobject-2.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib gmodule-2.0.lib pango-1.0.lib intl.lib
這樣就能成功使用GTK的library了!

不過使用Dev C++雖然能編譯成功,但執行的時候會有問題。不過VC++就不會 Orz...
下面是在windows下的GTK圖形介面

Sunday, March 25, 2007

Linux下完整支援nfts檔案系統 (讀/寫)

Linux NTFS Project支援 User Space 的 NTFS FileSystem.
這個 Driver 使用 FUSE(Filesystem implement in userspace)做介面,
剛剛試了一下, UTF-8 下中文沒有問題, 可以正常讀寫, 建立目錄.


首先必須安裝fuse:
先下載fuse,解壓縮至目錄下
#./configure
#make
#make install (must at root)

接下來就是安裝ntfs-3g,安裝方式跟fuse安裝方法一樣:
先下載ntfs-3g,解壓縮至目錄下
#./configure
#make
#make install (must at root)

最後就是將ntfs檔案系統掛載到Linux下:
ntfs-3g /dev/sda1 /mnt/windows -o silent,umask=0,locale=zh_TW.utf8

若要在啟動Linux時就直接掛載,則寫在 /etc/fstab
/dev/sda1 /mnt/windows ntfs-3g silent,umask=0,locale=zh_TW.utf8 0 0

不過我測試的結果,可是新建資料夾但是好像不能把資料夾直接複製進去,不知道是不是哪裡設定錯誤?


Friday, January 19, 2007

Kiba-Dock 執行問題

安裝完Kiba-Dock後發現Systray跟Iconediter不能開啟

會出現下面兩個錯誤:
1. ImportError: No module named SimpleGladeApp
2. ImportError: No module named egg.trayicon

上網查了一下,發現解決辦法
Type the following as root:
cp /usr/lib64/python2.4/site-packages/SimpleGladeApp.py /usr/lib64/python2.5/site-packages/
If SimpleGladeApp.py doesn't exist, install avahi package

Install pygtk and python-gnome-extras package

Thursday, November 02, 2006

VMware Full Screnn Mode in Linux

1 - Install VMWare

2 - Install guest OS

3 - Run guest OS

4 - Install VMWare Tools

5 - VMWare -> View
[X] Autofit window
[X] Autofit guest

6 - VMWare -> Edit -> Preferences -> Display
Autofit
[X] Autofit window
[X] Autofit guest
Full Screen
( ) Resize host
(o) Resize guest
( ) Don't resize

7 - VMWare -> Edit -> Preferences -> Input
Keyboard and Mouse
[X] Grab keyboard and mouse input on mouse click
[ ] Grab keyboard and mouse input on key press
Cursor
[ ] Grab when cursor enters window
[X] Ungrab when cursor leaves window
[ ] Hide cursor on ungrab

8- VMWare -> View -> Toolsbars
[o] Selective text beside icons

9 - Enjoy !

Tuesday, September 19, 2006

安裝Internet Explorer

在Linux下雖然有Firefix來瀏覽網頁,不過有些網頁用Firefox顯示起來就是有些怪,而且以的還限制只能用IE來開啟.
要在Linux下裝Internet Explorer大部分都是使用wine來安裝,不過我是了很多版本就是裝不起來(在裝IE總是有錯誤訊息) ,最近在網路上有人把裝IE的步驟寫成一個執行程式,它會自動從微軟網頁下載套件然後安裝. 另外他還能選擇要裝什麼語言. 在他的網頁上還宣稱連IE 7都能裝.


首先要先安裝wine,在SuSE的安裝光碟就能找到(因為我裝wine的時候就把wine-tool一起裝了所以 不知道wine-tool是不是一定要奘)
http://www.tatanka.com.br/ies4linux/news/ 下載 ies4linux
解壓縮後,執行目錄裡的ies4linux (#./ies4linux)

他會自動安裝IE6.0版,不過會問你是否要裝5.5跟5.0的版本以及要安裝甚麼語言

之後就會自動下載套件來安裝了

安裝完成後在桌面就會出現圖示,這時候點看看有沒有IE跑出來啦!

我在別的網站上看到說需要有 cabextract套件,不過我安裝的時候倒是很順利!


Wednesday, September 13, 2006

安裝"compiz-quinn"



裝SuSE的最初目的就是喜歡他的3S桌面特效,不過現在幾乎每種Linux版本都能裝XGL了. 而且做出來的效果還比SuSE的還多(像在SuSE中啟動compiz後佈景設置只能用預設的)

最近在網路上終於找到能用在SuSE的compiz管理套件"compiz-quinn".他的功能比SuSE的還更多,而且還能更改佈景.

首先在http://software.opensuse.org/download/Compiz-Quinn/SUSE_Linux_10.1/i586/
下載compiz-quinncvs,xgl-cvs,librsvg,libwnck,cgwd-themes然後使用zen-installer安裝就行了(如果有已經安裝過的就不用下載)

安裝完成後在作業階段新增compiz-start.py自動啟動,最後重新登入就會在系統列看到小圖示了
他還能隨意更換不同桌面系統的佈景設定,還有一堆關於XGL的外掛



不過在我電腦用有點不大穩定,有時候把佈景轉換成compiz時整個桌面會掛掉害我重新開機不少次.
可能是顯示卡太嫩吧(內建的X200 >"< )