ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

顯示具有 software_package 標籤的文章。 顯示所有文章
顯示具有 software_package 標籤的文章。 顯示所有文章

2015年5月7日 星期四

twitter client in console mode : rainbowstream

http://www.rainbowstream.org/

是用 python 寫的。
就 follow doc 說明。用virtualenv 建立一個工作環境,在用 pip 裝。以後就可以在這個工作還行 run.

要注意的是,有關 proxy.
他會吃環境變數 http_proxy, 但是又不會動。然後 --proxy command 又會受影響。

所以要先把 http_proxy unset, 再用 --proxy option 來 run.

第一次run 會叫出 browser login twitter, 給 rainbowstream 授權。


source venv/bin/activate
unset http_proxy
unset https_proxy
rainbowstream -ph 192.168.0.1 -pp 3128 -pt HTTP



大概說明一下...
virtualenv 是 python 的一個 tool, 會幫你建立一個虛擬環境,在這個環境裡,你可以安裝軟體,設定環境變數..etc
都不會動到主系統。
而且退出後就消失。 virtualenv venv 的命令就是:建立一個 virtualenv 環境,名稱叫 venv.
之後,在home 目錄下就會有 venv 這個目錄。

要進入venv 這個環境,只要:
source venv/bin/activate
就可以。

2013年5月20日 星期一

rEFIt -- Macbook 的光碟/usb 開機程式

http://refit.sourceforge.net/doc/c1s1_install.html

是在 這邊 看到的。

文章是用 rEFIt 把 Fedora 安裝在 usb3.0 的外部硬碟。
所以完全不會動到 Macbook 的 SSD。

另外 這一篇 是用 rEFIt 安裝 ubuntu 12.04

2012年8月8日 星期三

debian-multimedia ---- deb-multimedia

www.debian-multimedia.org 改為 www.deb-multimedia.org 了
所以 apt update 會 fail..

ref : http://www.deb-multimedia.org/

2011年12月14日 星期三

update flashplayer 11 for debian squeeze

最近 squeeze 的 chrom 一直 complain flash player plugin 太舊,所以不執行。

所以到 adobe 網站去download,但是沒有 debian 的版本。
只好 download tar.gz 版,自己解開。

google 一下手動安裝。
好像就是把 libflashplayer.so copy 到某個目錄就可以。
其他 /usr /,... 的,大概是因為原來就有 install none-free 版的 rev 10,所以不必用。

這樣,就只要把解開的 libflashplayer.so 覆蓋掉 /usr/lib/flashplugin-nonfree/libflash.so
然後重開 chrome 就可以..

至少沒有 complain,然後 youtube 播放 OK。

2011年9月21日 星期三

editor : sublimetext2

http://lucifr.com/139225/sublime-text-2-tricks-and-tips/

挺不錯的 (可惜要錢,還挺貴的 $60)。
但是開發中免費 (?)

還可以用 vim 的 command 喔...
http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/

開啟 Preference -Global Setting - default

跟 geany 比:

  1. 字型漂亮
  2. 排版漂亮
  3. 有支援 vi command
  4. command line 啟動,每次都會開一個新 session
  5. 沒有 function list --- 要自己弄 ctags ?

2011年4月14日 星期四

smbclient -- command line smb share client

用來連 samba 跟 Windows Share.

command :
/$ smbclient //192.168.147.235/source -U softwaretest -W lowtech 注意是用 unix 的 folder seperator (/) 不是 windows 的 (\)
-U  : with user name.
-W  : with working groupe
login 完成後,就可以用類似 ftp 的 command. get put ls dir cd 來傳檔,工作。



其他:
-L  : browse the share -- 看看/列出 內容就好。
-W 的 workgroup 很重要,如果沒有加這個 option, smbclient 會用 /etc/samba/smb.conf 的設定。
如果和 share server 不一致,會有 session setup failed: NT_STATUS_LOGON_FAILURE 的 error

2011年4月13日 星期三

diff two source folders

因為 vendor patch 過的 source code 沒有完整的 repo project 資訊,所以只好用 diff 來找出後來自己修改過的地方。
因為 build 過的 source folder 包含一堆不是 source code 的東西,還有一些 git folder 都不要加入 比較,所以要用一些 option 來排除
所以我用的 command 是:
diff -x '.*' -r --brief -x 'out' -x 'kernel_imx' -x 'bootable' --exclude='*.ko' --exclude='*.o' --exclude='*.a' --exclude='*.mod' --exclude='*.cmd' myandroid91 myandroid9.1local 2>&1 | tee difflog
說明:
-r 是 recursive 的意思
-x 是 ignore folder 的意思
--brief 是只要報告不一樣就可以,不必列出不同的內容
--exclude 是排除 xxx

很慘,因為 diff 連 folder attribute 都會compare,而 main trunk 因為大家還不會用 git remote 作 merge ,所以修改了fild attribe 讓所有人都可以 access,導致 diff 的內容整個都...

所以還是要咧出內容 (取消 --brief ),這樣才可以看出真正 source code 的修改。

2011年1月26日 星期三

captive portal - driver all web access to login page

像一些 wifi ap 第一次連線會把所有 web access都會導入到 他自己的 login page。 這樣的功能較 captive portal. 可以google 一下,就有很多資料,包括 opensource 的 CoovaChilli 還有內建 coovachilli 的

2011年1月21日 星期五

libusb-dev , libusb.h & usb.h

libusb 的 header file 好像換掉了,不是 libusb.h,改成 usb.h

用 aptitude search libusb 可以看到有 libusb-dev 這個 package。
install 後,用 dpkg -L libusb-dev 看一下這個 package 裝了什麼東西:
$dpkg -L libusb-dev /usr/bin/libusb-config /usr/include/usb.h /usr/lib/libusb.a /usr/lib/libusb.la /usr/lib/pkgconfig /usr/lib/pkgconfig/libusb.pc /usr/lib/libusb.so 可以看到沒有 libusb.h ....

libusb.org 有說明 這個相容性問題 http://www.libusb.org/wiki/libusb-1.0#Backwardscompatibility
libusb-1.0 is not backwards compatible with libusb-0.1 - all function names are different, etc. 
However, libusb-1.0 is designed to be happily installable alongside libusb-0.1 (even in the default 
configuration) so the lack of backwards compatibility is not really a problem - users can have both 
libusb versions present on the same system without conflict.

That said, there is a libusb-compat-0.1 compatibility layer. This is a "wrapper" which converts 
libusb-0.1 function calls to their 1.0 equivalents. For more info, see libusb-compat-0.1.
所以..要麻 install libusb-0.1 ,不然就要 libusb-compat-0.1。
不然就要改code.

把 code 的 include libusb.h 改 usb.h 試試。
就 OK 了。



從 pkg -L libusb 的 list 可以看到,有提供 libusb-config。
試 run 一下:
$libusb-config Usage: libusb-config [OPTIONS] [LIBRARIES] Options: [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags] 可以知道,就像 libsdl,用 libusb-config --libs , libusb-config --cflags 會列出build 時的 參數。



ref : http://www.linuxquestions.org/questions/linux-newbie-8/ubuntu-9-10-include-libusb-libusb-h-802880/

2011年1月13日 星期四

Run Project on Real Target

用Eclipse 可以在真的 target 作 debugging.
ref: Set Up Device for Developement
大概就是: AndroidManigest.xml 的 project 的 property 要設: application: debug TRUE。 device 要設 settings - applications - developement - USB debugging enable.
確認 adb 可以連線。
就可以了。

這樣, run eclipse 的 debug 時,就會 install apk 到 real target,然後 run 起來。

如果先在 source code 中設好 break point,eclipse 就會切到 debug perspective.
可以作 step, view variable, ... etc

2011年1月12日 星期三

AF_UNIX, sendto and receive - in Android

這一篇(http://www.few.vu.nl/~jms/socket-info.html)有unix udp 的 client - server example: /* receiver */ #include <sys/types.h> #include <sys/socket.h> struct sockaddr myname; struct sockaddr from_name; char buf[80]; main() { int sock; int fromlen, cnt; sock = socket(AF_UNIX, SOCK_DGRAM, 0); if (sock < 0) { printf("socket failure %d\n", errno); exit(1); } myname.sa_family = AF_UNIX; strcpy(myname.sa_data, "/tmp/tsck"); if (bind(sock, &myname, strlen(myname.sa_data) + sizeof(name.sa_family)) < 0) { printf("bind failure %d\n", errno); exit(1); } cnt = recv(sock, buf, sizeof(buf)); // recfrom not work !! if (cnt < 0) { printf("recvfrom failure %d\n", errno); exit(1); } buf[cnt] = '\0'; /* assure null byte */ from_name.sa_data[fromlen] = '\0'; printf("'%s' received from %s\n", buf, from_name.sa_data); } /* sender */ #include <sys/types.h> #include <sys/socket.h> char buf[80]; struct sockaddr to_name; main() { int sock; sock = socket(AF_UNIX, SOCK_DGRAM, 0); if (sock < 0) { printf("socket failure %d\n", errno); exit(1); } to_name.sa_family = AF_UNIX; strcpy(to_name.sa_data, "/tmp/tsck"); strcpy(buf, "test data line"); cnt = sendto(sock, buf, strlen(buf), 0, &to_name, strlen(to_name.sa_data) + sizeof(to_name.sa_family)); if (cnt < 0) { printf("sendto failure %d\n", errno); exit(1); } } 我修改了一下 android 的 test_udp (system/extras/tests/bionic/libc/common/test_udp.c) #define PROGNAME "test_udp" #define DEFAULT_PORT 7000 #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <string.h> #define BUFLEN 512 #define NPACK 10 void diep(char *s) { perror(s); exit(1); } static void usage(int code) { printf("usage: %s [options]\n", PROGNAME); printf("options:\n"); printf(" -p<port> use specific port (default %d)\n", DEFAULT_PORT); printf(" -a<inet> use specific IP address\n"); printf(" -s run server (default is client)\n"); exit(code); } int main(int argc, char** argv) { int runServer = 0; int udpPort = DEFAULT_PORT; int useLocal = 0; int address = htonl(INADDR_ANY); struct sockaddr si_me, si_other; int s, i, slen; char buf[BUFLEN]; int cnt; while (argc > 1 && argv[1][0] == '-') { const char* optName = argv[1]+1; argc--; argv++; switch (optName[0]) { case 's': runServer = 1; break; default: usage(1); } } if (runServer) { if ((s=socket(AF_UNIX, SOCK_DGRAM, 0))==-1) diep("socket"); si_me.sa_family = AF_UNIX; strcpy(si_me.sa_data,"/data/tsck"); if (bind(s, &si_me, strlen(si_me.sa_data)+sizeof(si_me.sa_family))==-1) diep("bind"); printf("UDP server listening \n"); for (i=0; i<NPACK; i++) { cnt = read(s, buf, BUFLEN); printf("cnt=%d\n",cnt); if(cnt>=0){ buf[cnt]='\0'; printf("Received packet Data: %s\n",buf); } } printf("UDP server closing\n"); close(s); unlink("/data/tsck"); } else /* !runServer */ { if ((s=socket(AF_UNIX, SOCK_DGRAM, 0))==-1) diep("socket"); si_other.sa_family = AF_UNIX; strcpy(si_other.sa_data,"/data/tsck"); printf("UDP client sending packets \n"); for (i=0; i<NPACK; i++) { printf("Sending packet %d\n", i); sprintf(buf, "This is packet %d\n", i); if (sendto(s, buf, BUFLEN, 0, &si_other, strlen(si_other.sa_data)+sizeof(si_other.sa_family))==-1) diep("sendto()"); } close(s); printf("UDP client closing\n"); } return 0; } server close 後要 unlink,否則會留一個 file 在 /data/tsck。下次再 bind 就會 fail
ref: AF_UNIX, SOCK_DGRAM 好像不能用 recvfrom, 只能用 read, 否則有 data 近來時會有 argument error.

2011年1月10日 星期一

pthread

pthread 的 p 是 posix,也就是 posix 標準的 thread api。 fork 的 parent 和 child 沒有任何共用的地方。 但是 thread_create 出來的 thread 和 mother(?) process/thread 共用 所有的東西。 所以 thread 間的同步控制就更重要。 pthread 的標準就包含很多 process 間同步的物件。 從resource 共用來看 process 和 thread: thread 間要共用一個 array,就宣告一個 global array 就可以。 但是 process 間要共用一個 array,在 fork 之前就要先用 shmget,shmat 準備好。

2011年1月5日 星期三

bionic libc liked busybox

現在要 build 使用 bionic libc 的 busybox 變得比較簡單了。
這都要感謝 android-x86 專案。

因為 android-x86 已經把 busybox 內建在 source package,
所以只要把 external/busybox copy 到自己的專案就可以。
-- 他的 git link 到 .rep/project/external/busybox.git,有需要也可以一併 copy

然後就可以用 mm build 了。
如果你的 bionic 版本太舊,可以參考 android-x86 的 bionic 修改。
一般來說,會缺 這一篇 (http://lazyhack.net/compile-busybox-linked-bionic/ ) 講得幾個 system call.
bionic/libc/arch-arm/syscalls/adjtimex.S bionic/libc/arch-arm/syscalls/stime.S bionic/libc/arch-arm/syscalls/swapoff.S bionic/libc/arch-arm/syscalls/swapon.S bionic/libc/arch-arm/syscalls/sysinfo.S bionic/libc/arch-arm/syscalls/getsid.S 就 follow 把 android-x86 的 source code copy 過來。
還有修改 mk 和 header ,
這樣就可以重新 build bionic, busybox。
busybox build 完會 install 在 out 的 system/xbin 下面。

這樣就見識到 open source 的專案, user 會讓 function 漸漸的完整。

2011年1月4日 星期二

fdisk in shell script

nelson 說的 在 shell script 裡要用 fdisk ,可以這樣用: #!/bin/sh sudo fdisk /dev/sdc <lt; EOF n p 1 w EOF exit 其中有兩行只按 enter,對應 fdisk 的操作

2010年12月10日 星期五

more on serial programming - termios and read/write raw data

上次 tty (UART) 的測試,結果我丟一個 0x0d, 0x0a ,對方卻收到 0x0d,0x0d,0x0a。 因為tty 會特別處理 控制字元,用 termios structure 可以知道: tty = open("/dev/ttymxc2",O_RDWR | O_NOCTTY | O_NONBLOCK); tcgetattr(tty,&tio); printf("c_oflag:"); if(tio.c_oflag & OPOST){ printf("OPOST "); if( tio.c_oflag & ONLCR) printf("-ONLCR"); if( tio.c_oflag & OCRNL) printf("-OCRNL"); if( tio.c_oflag & ONOCR) printf("-ONOCR"); if( tio.c_oflag & ONLRET) printf("-ONLRET"); printf("\n"); } printf("c_iflag:"); if(tio.c_iflag & IGNBRK) printf("-IGNBRK"); if(tio.c_iflag & BRKINT) printf("-BRKINT"); if(tio.c_iflag & IGNPAR) printf("-IGNPAR"); if(tio.c_iflag & PARMRK) printf("-PARMRK"); if(tio.c_iflag & INPCK) printf("-INPCK"); if(tio.c_iflag & ISTRIP) printf("-ISTRIP"); if(tio.c_iflag & INLCR) printf("-INLCR"); if(tio.c_iflag & IGNCR) printf("-IGNCR"); if(tio.c_iflag & ICRNL) printf("-ICRNL"); if(tio.c_iflag & IUCLC) printf("-IUCLC"); if(tio.c_iflag & IXON) printf("-IXON"); if(tio.c_iflag & IXANY) printf("-IXANY"); if(tio.c_iflag & IXOFF) printf("-IXOFF"); if(tio.c_iflag & IMAXBEL) printf("-IMAXBEL"); printf("\n"); run 的結果是: c_oflag:OPOST -ONLCR c_iflag:-ICRNL-IXON 參考這一篇,有解釋每個 bit field 的意義。 ONLCR - 會把 0x0a 變成 0x0d,0x0a. 所以我要把 OPST 這個 bit clear 掉...
要 read raw data, 參考 這一篇 (Serial Proramming Guide in POSIX System)。 termios 的 lflag 是: options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 如果是要 output raw data,就只要: options.c_oflag &= ~OPOST; ... 那篇文章最後就有 raw data input/output 的 code: int fd; struct termios options; /* open the port */ fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); fcntl(fd, F_SETFL, 0); /* get the current options */ tcgetattr(fd, &options); /* set raw input, 1 second timeout */ options.c_cflag |= (CLOCAL | CREAD); options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); options.c_oflag &= ~OPOST; options.c_cc[VMIN] = 0; options.c_cc[VTIME] = 10; /* set the options */ tcsetattr(fd, TCSANOW, &options);
read tty 的動作 (block, no block , wait time, how many bytes.. etc) 是由 c_cc[VMIN], c_cc[VTIME] 的值決定的。 有關 c_cc[] 中 VMIN, VTIME 的功能: (ref : Nonecanonical Input)
  • VMIN : 至少收到多少 bytes 後 return
  • VTIME : 達成 收到 VMIN bytes 的條件後,多少時間 timout 後 return.
所以..
  • c_cc[VMIN], c_cc[VTIME] 的值都是 0 : 有沒有資料都會立刻 return,不過有資料的時候,會把資料都讀出來再return.
  • c_cc[VMIN]=0, c_cc[VTIME] 不是 0 : 等 c_cc[VTIME] 都沒有資料就 return.,如果有收到 data 就立刻 return
  • c_cc[VMIN] 不是 0, c_cc[VTIME] = 0 : 一定要等到收到 c_cc[VMIN] 個資料後才 return.
  • c_cc[VMIN], c_cc[VTIME] 都不是 0 : ..

後來又發現,對方送 0x0d, 0x0a,我收到 0x0a, 0x0a。 確認一下, c_iflag 要 mask 掉 + options.c_iflag &= ~(INLCR | IGNCR | ICRNL); 才行

2010年12月9日 星期四

install flash plugin failed in 10.10

10.10 amd64 在 install flash plugin 時,會出現要去 canonical download gz 檔的時候,沒有辦法 download. 這是因為她沒有看 系統的 proxy 設定。 在 launpad 也有列出這一項..Flash Plugin / Update Manager / PROXY not being honored 解決的方法就是 .... 到沒有 proxy 的地方去裝 XD
..等 install retry 20 次 fail 後,關掉 firefox,在 console 把http_proxy 環境變數設好,然後: sudo bash -c 'eval $(apt-config shell http_proxy Acquire::http::Proxy) dpkg-reconfigure flashplugin-installer' 就會正常經由 proxy download 了。

2010年12月8日 星期三

serial programming

這一篇
設定 /dev/ttymxc2 (UART3) 為 38400,然後每隔 1 sec 送一個固定的 packet 出去.. #include <stdio.h> #include <termios.h> #include <fcntl.h> void setparameter(void) { int tty; struct termios tio; tty = open("/dev/ttymxc2",O_RDWR | O_NOCTTY | O_NONBLOCK); tcgetattr(tty,&tio); tio.c_cflag = B38400 | CS8 | CLOCAL | CREAD; tcflush(tty,TCIFLUSH); tcsetattr(tty,TCSANOW,&tio); close(tty); } int main(int argc,char *argv[]) { FILE *fd; int i; printf("ttymxc2 bomb\n"); setparameter(); int data[]={0x24,0x06,0x03,0x00,0x0d,0x0a}; fd = fopen("/dev/ttymxc2","w"); // fd = stdin; if(!fd){ printf("open /dev/ttymxc2 failed!!\n"); return 1; } data[3]=data[0]^data[1]^data[2]; data[3] &= 0xFF; while(1){ for(i=0;i<6;i++) fputc(data[i],fd); sleep(1); fprintf(stdout,"%02X %02X %02X %02X %02X %02X\n",data[0],data[1],data[2],data[3],data[4],data[5]); } fclose(fd); return 0; }
然後只要在 init.rc 加上 +# MCU sending service ttymxc2bomb /system/bin/ttymxc2bomb console 就會自動跑起來。
加上 "console" ,就會 把 stdout 放到 console,所以可以看到 message。

--- 麻煩是用 service 啟動的 東西,,,kill 掉後又會自己起來 >_<
--- 好像加一行 oneshot 就可以

2010年3月2日 星期二

run another vncserver

這裡 看到的.. 原來可以這麼簡單,就直接 run 另一個 VNC server 起來。 這樣,前一個 qemu 起不來的問題就可以解了..
vncserver :1
啟動 vncserver,使用 graphic console 1 graphic console 0 是目前的 windows (除非你是在console mode)。 vncsever listen port 從 5900 開始,所以 console 1 是 5901

2010年1月20日 星期三

debootstrap to install base-system

debootstrap 好像很有趣,會幫你install base-system 到任意 的 地方。 follow 這一篇.. 也可以參考 這個 討論 講create 一個 file 作 loopback,mount 回來後 install debian base-system。 再 chroot 過去.. 大概的步驟是:
  • dd
  • mount loop
  • fdisk
  • mkfs.ext2
  • mount as folder
然後就 可以 run debootstrap:
debootstrap lenny /mnt http://ftp.us.debian.org/debian
如果在 proxy 後面就要先設 proxy。

debian 的官方安裝文件 的附錄,也有這樣安裝的說明 (他是要安裝到 sd card)。

標籤

網誌存檔