2016年10月24日 星期一

無眠

以下是蘇打綠 ê 無眠, 用教育部 ê 標準用字,  小可校正.口音盡量按照 Youtube 內, 我聽著 ê 青峰 ê 口音!

今仔日月娘那遐爾光                   kin-á-ji̍t   gue̍h-nîu  ná    hiah-nī kng

照著阮歸暝攏袂當睏                   tsìo-ti̍oh  gún  kui-mî  lóng   bē-tàng  khùn
連頭毛都歇睏                          liân  thâu-m̂ng  tōo    hioh-khùn
(親像魚死佇花園)                   tshin-tshīunn  hî  sí  tī  hue-hn̂g

你敢知阮對你的思念                  lí   kám  tsai  gún  tuì  lí  ê  su-liām
希望你有的夢                     hi-bāng  lí  ū  kāng-khún  ê  bāng
咱兩人做陣轉來一工              lán  nng  lâng  tsuè-tīn  tńg--lâi  hit   tsi̍t  kang
互相依的情愛                         hōo-sìong  i-  ê  tsîng-ài

佇你的心肝內                             tī  lí  ê  sim  kuann  lāi
是不是有我的存在                  sī  m̄  sī  koh  ū   guá  ê  tsûn-tsāi
永遠攏等                                íng-uán  lóng  teh  tán
有時陣嘛會甘願                     ū-sî-tsūn  mā  ē  m̄  kam-guān

想講要作飛                            siong  kóng  beh  tsuè-hué  pue
去一个心中美麗的所在             khí  tsit-ê sim-tiong  bí-lē  ê  sóo-tsāi
所有的一切                               sóo-ū  ê  it-tshè
攏總作夥                        lóng  tsóng  kah  lí  khǹg  tsò-hué 
希望你 會當了解                       hi-bāng  lí  ē-táng  liáu-kái
(為著你 我一定等)                  uī  ti̍oh  lí guá it-tīng táng

偌濟時間偌濟目屎         guá m̄-kuán guā-tsuē sî-kan guā-tsuē bo̍k-sái 
  偌濟失望來忍耐                     guā-tsuē sit-bōng lâi lím-nāi
管你當時會轉來                guá  m̄-kuán  lí  tang-sî  ē  tńg-lâi
其實我嘛知影為怎樣            kî-si̍t guá mā m̄-tsai-iánn uī-tsuánn-īunn
  為怎樣憨憨等待                     uī-tsuánn-īunn gōng-gōng lâi tán-thāi

你 是我唯一的愛                      lí  sī  guá  uî  i̍t  ê  ài

懷春曲


以下是根據林英美所唱 ê 懷春曲, 儘量以教育部所定的標準台文來重寫歌詞
另外 A-Lan 所演唱的版本, 嘛真好聽!



日落西天色黃昏     馬車跑山侖
 li̍t lo̍k sai thinn-sik hông-hun         bé-tshia pháu suann-lūn

咱二人真有緣份     相會在這陣
 lán nn̄g-lâng tsin ū iân-hūn           siong-huē tsāi tsit-tsūn

阮心內真正興奮     佮著貼心
 gún sim-lāi tsin-tsiànn hing-hùn      kah tīo tah-sim kun

手牽手做陣游賞     快樂當青春
 tshíu khan tshíu tsuè-tīn îu-síunn   khuài-lo̍k tng tshing-tshun



戀花開又媠又芳     花心一點紅
 luān hue khui īu suí īu phang         hue-sim tsit tiám âng

在等待蝴蝶飛來     守阮的花欉
 tsai tán-thāi ôo-tia̍p pue-lâi              síu gún ê hue tsâng

為著伊心情茫茫     日頭直直暗
 uī ti̍oh i sim-tsîng bâng-bâng         li̍t-tâu ti̍t-ti̍t àm

提紙筆來寫情批     寄乎伊一人
 thê tsuá-pit lâi siá tsîng-phue        kià hō i tsit lâng



在眠夢佮伊相見     散步溪仔墘
 tsāi bîn-bāng kah i sann-kìnn         sàn-pōo khue-á kînn

夢見伊對阮講起     婚緣的代誌
 bāng-kìnn i tuì gún kóng-khí          hun-iân ê tāi-tsì

初戀味情意真甜     見笑暗歡喜
 tshoo luân tshîng-ì tsin tinn           kiàn-siàu àm huann-hí

醒來才知影都是     夢見見著伊
 tshínn--lâi tsiah tsai-iánn to-sī       bāng-kìnn kìnn tio̍h i



想彼時自由自在     談情相意愛
 sīunn hit-sî tsū-uî-tsū-tsāi             tâm tsîng sio ì-ài

心對心談情說愛     歡喜無人知
 sim tuì sim tâm tsîng suè ài          huann-hí bô lâng tsainn

求神明替阮想覓     佮阮鬥催排
 kîu sîn-bîng thè gún siūnn-māi          kah gún tàu tshui-pâi

保庇阮達成希望     幸福的將來
 pó-pì gún ta̍t sîng hi-bāng            hīng-hok ê tsiong-lâi

2010年4月18日 星期日

Using BlackBarry Bold 9000 as 3G modem on Linux

Recently I got the BlackBerry Bold 9000 and it can work as 3G modem by using the BlackBerry Desktop Software. Since I used to work under the environment of Linux, I want to make it work on Linux.

In ubuntu 9.10, I do the following steps
$ sudo apt-get install pkg-config libusb-dev libssl-dev libboost-serialization-dev libtar-dev libgtkmm-2.4-dev libglibmm-2.4-dev libglademm-2.4-dev zlib1g-dev

And then download and install the "libbarry" and "barry-util" from Source Forge: http://sourceforge.net/projects/barry/files/

But it could not work.

After trial for awhile, I finally make it works from the recompiling and debug from the ppp package.

In the debugging, I found that it looks when using the IPCP to get the local IP adderss, BlackBerry cannot provide it immediately and pppd daemon polling for many times, so that ppp get the many NAK's from Barry. Finally it provides but the pppd complains and exit.

The quickfix to it is to increase the max number of IPCP NAK tolerance to reject the NAK's information. From the the ppp source tree:

vi pppd/ipcp.c

and the line:

f->maxnakloops = 100;

and change it to larger number, I use the 2000;

And it works well,

Also, my telecom company is Taiwan Mobile, attach the ppp script and chat for reference:
/etc/ppp/peers/barry-taiwan_mobile:

-------------
pty "/usr/sbin/pppob"
connect "/usr/sbin/chat -f /etc/chatscripts/barry-taiwan_mobile.chat"
#noauth
user ""
password ""

defaultroute
usepeerdns
noipdefault
nodetach
novj
nocrtscts
nomultilink
ipcp-restart 7
ipcp-accept-local
ipcp-accept-remote
lcp-echo-interval 0
lcp-echo-failure 999
mtu 1492
ipcp-max-configure 100
nopcomp
noaccomp
nomagic
--------------
/etc/chatscripts/barry-taiwan_mobile.chat:
------------
ABORT ERROR
OK ATZ
OK ATI
OK AT+CGDCONT=1,"IP","internet"
OK ATD*99#
CONNECT
------------
The workable command is:

pppd call barry-taiwan_mobile


-- Enjoy

2008年4月3日 星期四

Using script to Write Notes - (我用 Script 寫筆記)

I am a firmware engineer and I often write notes to record my trial and experience on installation of software, tools, and some other things! These notes help me a lot because I can redo any thing after a long time!!

Recently, I tried the Ubuntu Hardy with version Alpha 5 and got some problem with my amd64 machine. I have to re-install it several times! The installation of Ubuntu is quick, but it takes me a lot of time to tune it to fit the my used environment! I have to install a lot of other software and re-write the configuration files!!

If I have write down the steps by script, I can save a lot of my time after each installation!!

The second experience is: When I try the building of Glibc, I keep on write down the notes. And suddenly I think: Since it is step by step, why don't I use the script to note it instead of simply text?

For a software / firmware notes, such as software and program build, the notes style is something like:
---------------
Description
....
Commands
....
Description
...
Commnads
...
---------------
You describe something, and then show up your command or program!!


if what you note down can not be realized step by step, the information must be obsolete or outdated!!! So I have to revise my old notes frequently!! If that is true, why do I not to make my note runnable? This can save my time a lot for the second round!!!

This is not a new idea!

I am not very sure, but I did know there are some tries and maybe some useful tool available. For example, to embedded the notes in the program, such as C or others!! You write the remark by some tags or format such that you can extract your notes by utilities!!

Or the XML that can do almost anything!!

After consideration, there are some choices:
1. Search for some ready tools
2. Write my notes with the commands with some special tags so that I can use utilities to extract and run
3. Write more remark and use more "echo" in the Bash Script

For item 1, First, I have no time to learn if the grammar or tags are complicated. Second,it maybe hard to trim it for my used usage. and third and also the major reason: I don't know any ready tools and I don't search the Web. If anyone have good suggestion can tell me!!

For item 2, I think it is workable! But I think it would be more complicated to parse the runnable commands out of a plain text!! And it is not flexible or it would be more complicated if you want flexibility!!

For item 3, it is good, but it is not intuitive!! Although it is closest to our notes, but for flexibility sake, we often use the function call, indirect reference, and many flow control that make your remark trivial!!

1 Easy to note down
Not too much tags or grammar!!
2 No need more utilities or tools
As simple as good!!
3 Flexibility
Sometimes I want to just run parts of my script for some tests!! And I can turn on/off the notes when execution, or I simply want to know the usable steps to do it and don't really run

I choose the Bash Script because I often work on it and I used to it. Although I am not familiar with script programming, this is the chance that I can learn it. And it has the following benefit:

1 Its function is easy
2 Its file management is easy
3 It is easy for it to execute program
Thanks to the Unix Design, it can call almost any program to help the job

To do it, first I create two simple function:
-------------------
n() {
if [ "$NOTE" != "n" ];then
echo "$*"
fi

p() {
if [ "$VERBOSE" != ];then
echo "executing $*"
fi
if [ "$GO" = "y" ];then
eval "$*"
fi
}
------------------------------
and then you can use them in your following script!!
------------------------------

n your notes
p ls
------------------------------
So that I can write down your note and command nearly as easy as my notes in plain text!!

You can see your notes on the standard output, and you can also see the execution command and result! I use some variables to switch the notes, execution command line, and the real execution on / off

To improve the flexibility, I use the program style used by the scripts in /etc/init.d/*. Which has the following pattern:
-----------------------
#!bin/sh
..
..
..
case $1)
start)
...
stop)
...
restart)
...
*)
;;
esac

exit
--------
It uses the CASE execute different work in one script! And I can use it o divide your stream-like flow into separate segment so that I can test them separately!!

Follow this idea, I use the compilation of glibc on PC as an experiment!! If you are using the Ubuntu Hardy and have the internet conncetion, just download the two attached files my_methods and glibc_build in the same directory and run:

./glibc_build go=y

and it would download the glibc-2.17 source package and build the source automatically. Please notes: it doesn't use the dpkg-related utilities!!

you can show the basic options by

./glibc_build show=basic

you can the basic information by

./glibc_build act=preface

you can show the building steps

./glibc_build

and it would show your notes and your steps, but not run:

########### Do Preface
Platform: Ubuntu Hardy i386 20080401
The Glibc version-glibc-2.7.tar.gz
Based on the book: The Definitive Guild To GCC, 2nd, Chapter 12


########### Do Download
$----- apt-get source glibc -----'
$----- cd glibc-2.7 -----'


########### Do Unpack
Note: We use the GNU tar so that we can use the following commands, if not, please reference the book!!
The official downloaded version is glibc-2.7.tar.gz


########### Do Intaling Tools
Install the required tools
$----- aptitude install -y autoconf automake -----'
Install the gawk to prevent the erors:mawk: scripts/gen-sorted.awk: line19: regular expression make failed
No rule to make target xxx/Versions.all, needed by ..../abi-version.h
If you do not use the gawk, it would use the mawk and casuse this error
You will needs to re-run configuration if you face this error in make
$----- sudo aptitude install -y gawk -----'


########### Do Configure
Configuraing the glibc-2.7.tar.gz
The best way to build the Glibc is to create a separate directory for buiild
The glibc is default to be installed in /usr/local
The Glibc search and load search path is determined by
LD_LIBRARY environment varialbes or configuration file /etc/ld.so.conf
Set the installation directory by --prefix= option
run the configure --help to get more configuration options
Optimize for kernel --enable-kernel=, --enable-kernel=current>


Creating a directory
$----- mkdir /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- mkdir /home/black/workarea/glibc-2.7/ttglibc-installed -----'
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- /home/black/workarea/glibc-2.7/tt/glibc-2.7/configure --enable-add-ons --prefix=/home/black/workarea/glibc-2.7/ttglibc-installed -----'


########### Do Make
Compiling the glibc-2.7.tar.gz
Fix the __stack_chk_fail_local fail by adding the -fno-stack-protector
However it would overlap the -O2 options so that glibc would complain
#error: glibc cannot be maked without optimization
So I add the -O2 together and succeeded
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- LANG=C LC_ALL=C make -j2 CFLAGS+='-O2 -fno-stack-protector' -----'


########### Do Check
do the check
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'

You can look a piece of my code:

do_configure() {
n "$SEP Do Configure"
n Configuraing the $PKG
n The best way to build the Glibc is to create a separate directory for buiild
n The glibc is default to be installed in /usr/local
n The Glibc search and load search path is determined by
n LD_LIBRARY environment varialbes or configuration file /etc/ld.so.conf
n Set the installation directory by --prefix=\ option
n run the configure --help to get more configuration options
n Optimize for kernel --enable-kernel=\, --enable-kernel=current\>
n "\n"
n Creating a directory
BUILD_DIR=$(pwd)/glibc-build
INSTALL_DIR=$(pwd)glibc-installed
PKGDIR=$(pwd)/glibc-$VER
p mkdir $BUILD_DIR
p mkdir $INSTALL_DIR
p cd $BUILD_DIR
p $PKGDIR/configure --enable-add-ons --prefix=$INSTALL_DIR
}

do_make() {
n "$SEP Do Make"
n Compiling the $PKG
n Fix the __stack_chk_fail_local fail by adding the -fno-stack-protector
n However it would overlap the -O2 options so that glibc would complain
n "\t\t"\#error: glibc cannot be maked without optimization
n So I add the -O2 together and succeeded
.......
.......

case "$ACT" in
preface)
do_preface
;;
download)
do_download
;;
tools)
do_tools
;;
usage)
do_usage
;;
patch)
do_patch
;;
restart)
do_restart
;;
precheck)
do_precheck
;;
addon)
do_addon
;;
unpack)
do_unpack
;;
addon)
do_addon
;;
configure)
do_configure
;;
make)
do_make
;;
check)
do_check
;;
install)
do_install
;;
clean)
do_clean
;;
summary)
do_summary
;;
*)
do_preface
do_download
p cd $PKGNAME-$VER
do_unpack
do_tools
do_configure
do_make
do_check
do_summary
;;
esac
exit 0

I use the function to group each step, and write the note and script inside them. Of course I want more robust and flexibility so many variables are added and many skill used. If you just want it run in your own limited situation, you can just write it serially and you can modify it if you have free time!!

2008年3月20日 星期四

一種奇怪的 C 寫法

在 Porting ARM Linux for NO MMU system 時, 遇到一個奇怪的寫法, 在 binfmt_flat.c 之中的 load_flat_binary() 函式之中, 有一段 code:


#include &lt include &gt
int main(int argc, char **argv)
{
char j;
int k;
int q[10]={1,2,3,4,5,6,7,8,9,10};
int *p= (int*) q[5];

for(j=0;j<3;j++) {
k = (j)[(unsigned int*) &q[5]];
printf("k is %d\n",k);
}

}


它的輸出是:

black@black2:~/workarea$ ./a.out

k is 6
k is 7
k is 8

如果我把

k = (j)[(unsigned int*) &q[5]];

改成

k = (j)[(unsigned char*) &q[5]];

則輸出會是 6,0,0, 若改成 unsigned short, 則輸出會是 6,0,7!

但是我改變 j 的型態為 char, short, long 都不會有影響!!

事實上, 一個陣列名稱不過是代表某個位址的 symbol, 因此, 它的元素的位址本來就是

symbol address + index*element_size

所以也許我們可以把 j 看成一個變動的 symbol address!! 於是我作個實驗, 把 [ ] 中的指標拿掉, 結果出現錯誤:

error: subscripted value is neither array nor pointer


C 似乎期待在中間一定要有一個 pointer 或 arrary!! 事實上, 在 C 中 array 和 pointer 本來也是互相為用!!

從以上結果可以推論: 它的位址計算方式, 是 ( (unsigned char*) &q[5] + j), 如果你是 unsigned char 的話!! 我們再作一次實驗:

#include

int main(int argc, char **argv)
{
short j;
int k;
int l;

int q[10]={1,2,3,4,5,6,7,8,9,10};
int *p= (int*) q[5];

for(j=0;j<3;j++) {
k = (j)[(unsigned char *) &q[5]];
printf("k is %d\n",k);
l = ((unsigned char *) &q[5])[j];
printf("l is %d\n",l);
}
}

在此的 k 和 l 會得到完全相同的值!!

因此, 我們可以說: (j)[(unsigned char*) &q[5]] 幾乎就是 ((unsigned char*) &q[5])[j]!!

當然, 行文至此, 我只是用實驗的方式知道段程式的行為, 但仍不知那一條規則容許它這樣寫? 這有待高手替我解答了!!

我也不了解這位老兄為什麼用 (j)[(unsigned char*) &q[5]] 而不用 ((unsigned char*) &q[5])[j], 也許有我不知道的秘密也說不定!!

2008年3月19日 星期三

我們住在紅燈區

今天看到中時電子報的獨家: 歐晉德家半年2度遭竊 治安亮紅燈
又讓我回憶起前一陣子胡自強座車遭竊: 春安第2天 胡志強座車被砸竊物

胡市長的車子在三天內就找到了! 我相信那個不知死活的竊賊偷到歐晋德的東西, 也很快就會被抓到! 但是, 一般老百姓的呢? 我想, 不是被吃案就是不了了之!

身為苜善之區的台北市, 光是在這兩年, 在我家附近我認識的人, 包我們自己, 至少就有三件竊案! 第一次我們有報案. 最後這一次, 我們想算了, 不要多找麻煩了!!

為什麼會不想報案呢? 我們的報案經驗是: 你花了兩三個小時在那邊作筆錄. 警察會在那一直吐苦水, 講他們人力不足云云. 最後還會要你成立專案小組哩! 怎麼說, 他還會要求報案人自己去調監視錄影帶, 這不就是我們報案人自己成立專案小組了嗎?

這就是警政署之前的標語: "警力有限, 民力無窮" 的實踐嗎?

市長的車子遭竊, 警方可以成立專案小組, 我們遭竊, 警方不吃案就偷笑了!

市長的案子三天可以找回來, 一般老百姓的車子卻一年半載找不回來, 這說明了警方對於這類案子, 是不為也, 也不能也!

每次出現社會名人遭竊遭詐騙這種新聞, 就讓一般市井小民更覺得有特權, 差別待遇, 對警察的印象也更差!!

如果名人的案子也是一年半載破不了案大家還會欣慰地說: 嗯, 至少警察一視同仁地不爭氣!!

每次這種新聞, 記者們的寫法都有固定的模式: "治安亮紅燈". 我覺得這些高官名人, 可能久久才遇到一次紅燈, 很快就綠燈了! 而這我們就一直住在紅燈區了!

2008年3月3日 星期一

我是猴子

相信大家常常接到理專的電話, 對話大體上是:
"我們公司最近有一個很棒的方案回饋給客戶, 就是每個月你只要花 XXX 元, 就可以亨有 XXX 的保障 ..."
相信這種電話很快就會被掛掉!!

就在上星期, 我接到 "台灣北部有錢的城邦" 銀行的理專電話! 一開始他說是在調查我們對他們信用卡的意見. 我當然抱怨了一下他們福利一直縮水, 而且我不小心多繳了錢, 退費居然要收手續費!! 退回帳戶要收100元, 如果其它帳戶要收 300 元 等等!!

他很耐心聽完, 好像也搞不太清楚他們公司的規定, 說 "我回去幫你查查"

接下來, 他進入正題: "先生, 我們公司最近有一個優惠方案給老客戶, 你不用花一毛錢!!"

哇, 有這種好康, 我當然要聽下去!!

"你可以 XXX 的保障, YYY 年可以 ZZZ, 可以不用花一毛錢"

可是要怎麼做呢?

"你只要在銀行帳戶存一筆錢"

好啊, 我本來就有帳戶呀!!

"我們會每個月從您的信用卡扣 xyz 元到您銀行的帳戶"

聽到這兒我開始有 "風蕭蕭兮易水寒" 的感覺!!

"20 年期滿你還會有 5% 的利息喔"

最後我還是把這個荊軻給拉出去斬了, 喔不, 把電話給掛了!! 還好我以前對保險的觀念還下過功夫, 好險我有一些親朋好友讓我了解保險的生態!!

事後想想, 這位先生
的修辭是有練過的, 他把這種到期可領回的保險講成 "不用錢", 把本來是在保險公司的保單改成放在銀行的帳號. 所不同的是: 他沒有提說即使放進銀行, 我還是 20 年不能動用!!

看來這位先生悟道了, 莊子齊物論有一段著名的故事:

"勞神明為一而不知其同也, 謂之"朝三". 何謂"朝三"? 狙公賦芧,曰: "朝三而暮四" 眾狙皆怒. 曰:"然則朝四而幕三"眾狙皆悅. 名實未虧而喜怒為用....

狙就是古時候的猴!! 我屬猴, 可不喜歡被人當成猴子耍!!

現代金融業想不出什麼創新的服務來幫顧客顧錢, 也幫自己賺錢, 整天想的就是把客戶當猴子耍!!

別懷疑, 這就是我們的金融業!!

聽朋友說, 有人在這類電話中應了一聲好, 就損失了十萬元!! 因為解約損失更多!! 他們都有電話錄音!! 當然, 這可能是極端的案例!! 但最常發生的是: 你不小心保了你不需要的險!!

我想到以前好像在數字周刋中訪問過一個人, 他是黑道轉行作保險, 十分成功!! 他說: "因為保險和黑道一樣, 都是靠恐嚇在賺錢"

這麼說來, 電話詐騙集團不就適合轉行作金融業的理專?

話說也是同一家銀行, 前一陣子我太太拎了50多萬要去存錢, 沒有想到忘了帶本子. 大家也都有常識, 銀行是有無摺存款的!! 沒想到櫃枱要我太太找理專去辦!! OK, 找理專就找理專. 因為我太太只想辦存款. 結果這個理專發現無法把我太太當猴子, 居然拉下臉, 說連存錢都不行, 直接請我太太出去!!!!!!!

這就是我們的銀行的服務嗎?

這就是我們的銀行的服務嗎?

大宗存款利息較低就算了, 不買產品都不行!! 我們銀行的服務都作表表面, 空把最底層的小姐訓練地很客氣, 但她們只是負責挨駡, 什麼有意義的決定也沒有辦法作!! 銀行不能存錢, 或是找各種理由直接 "避免" 客戶存錢!!

存錢, 不正是銀行最基本且最天職的服務嗎?

我不怪這些底層直接面對客戶的可憐員工!! 他們一定被高層逼的! 而這些領高薪的金融高層, 除了整天想著兩岸三通併購防止被併購買卡位人事想著賺完大戶的錢賺小戶的錢怪政府怪東怪西之餘, 可曾真的想過好好服務曾讓你長到今天金融巨獸的客戶?

這種和人民切身相關的零星瑣事, 不斷地在我們身邊上演!! 金管會在哪裏? 隨便發個聲明, 或是留個官僚的申訴管道就了結了嗎? 這就是我們的政府嗎?

我是猴子!! 大家也都是猴子!!

佇 Linux 來看GPX 檔案

最近定定有戶外活動。使用𤆬路機 (GPS) 來記錄行過的路線。普通我記錄路線,攏是用手機仔抑是專門个𤆬路機,罕得用電腦來看。 毋過,"仙人拍鼓有時錯,跤步踏差啥人無"。有一擺我無細膩,袂記得共一擺活動的路線收煞起來,閣直接開始記錄下一擺的活動,按呢共幾落...