Sunday, October 25, 2009

tinyOS make error

There is an error might be occurred when compiling.
/opt/msp430/msp430/include/stdlib.h:52: syntax error before "asm"
make: *** [exe0] Error 1


Here is a solution,

Modify Line 52 of /opt/msp430/msp430/include/stdlib.h:
extern void exit(int) __asm__(”__stop_progExec__”) __ATTR_CONST__;

Into
extern void exit(int) __ATTR_CONST__;
void exit(int a) __asm__("__stop_progExec__");

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"