2011年3月21日 星期一

[Shell script] format print number (補零)

nn=`echo $num|awk '{printf "%02d", $1}'`

[Shell script] convert decimal to hex

n=0
hex=0
echo -n "Enter number in decimal format : "
read n
hex=`echo "obase=16;ibase=10; $n" | bc`
echo "$n is equivalent \"$hex\" in hexadecimal"

2011年3月12日 星期六

[轉]Use uart(rs-232) with putty in ubuntu

http://ed32.blogspot.com/2010/01/ubuntuputty.html
在Linux底下,通常都是使用 minicom 來做uart(rs-232)端的通訊工具,不過使用 Putty 也可以達到一樣的功能。

另外putty也有提供ssh的連線功能,非常的簡單直覺,應該都沒什問題,所以就不說了。

我這次是在 VMware 裡面用實體com port 作連線。

【設定】
先把實體 com port mapping 到 vm,如果你是用usb-to-serial cable的話,應該可以跳過。

1. 選 Use physical port on the host



















2. 用的是 com1



















3. 加好了

















【下載】

1. 抓一下 putty.exe
view source
print?
1 $ wget http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
2. 作一個 software link,等等 putty 用的是 com1,也就是實體的 /dev/ttyS0。
view source
print?
1 $ ln -s /dev/ttyS0 ~/.wine/dosdevices/com1
3. 補充#2,如果是 usb-to-serial cable的話,應該是
view source
print?
1 $ln –s /dev/ttyUSB0 ~/.wine/dosdevices/com1
其中的ttyUSB*,應該針對你的裝置號碼自行更改。
4. 看看#3的結果,會發現有了一個com1
view source
print?
1 $ ls ~/.wine/dosdevices/
2 c: com1 d:: e:: z:

【啟動】

1. 使用下面指令,用 wine 帶起putty
view source
print?
1 $ wine putty.exe
2. 設一下相對於Target的Baudrate,我的是 com1/57600














3. 連線成功,Tx/Rx 進來出去都OK。















【設定】

1. Implicit CR in every LF,把LF延伸成 \r\n


















2. 若有存檔需求,按照你的需求勾選。