Thursday, November 14, 2013

Non blocking connect

同事問我為何用 select () 去等 non blocking connect () 卻會馬上 return 但卻顯示 EINPROGRESS。

找了一陣子文章,似乎都指向一個答案,必須要使用 epoll 。

下面是相關的程式碼範例

另外相關的文章也有討論到這個問題。
link1
link2
link3
link4
link5



Tuesday, November 12, 2013

Ubuntu 從 Windows 出發的安裝過程

終端機

    MenuBar->檔案->設定組合偏好設定
    取消 使用系統固定字型
    Liberation 10 字型
    我比較習慣這樣的字型

    可以在視窗中直接 Ctrl + Alt + T 叫出來,這比較適合在 X Window 嚴重損毀時,Unity Launcher 通通無法執行時。

    複製 : Ctrl + Ins
    貼上 : Shift + Ins

GCIN 中文輸入法控制台

    原本的 iBus 輸入法只有 拼音 跟 Bopomo 感覺很難使用
    所以我手動安裝 gcin
        sudo apt-get install gcin
    然後從 Launcher (左側列) → 系統設定值 → 語言支援
        鍵盤輸入法系統 gcin
    然後可能需要重開機才會生效

Dropbox

    ClassicMenuIndicator 可以從 Ubuntu 軟體中心 (在 Launcher上) 去安裝

ClassicMenu Indicator

    這是類似以往 Gnome 的開始程式集選單, 似乎較新的 Ubuntu 12, 13 都拿掉了這個功能, 改而使用 Unity Launcher (左側工具列) 最上面那個 [搜尋您的電腦和網上資源] 來尋找你要的程式, 這樣的缺點是你根本不知道系統上有什麼程式可以用.
ClassicMenuIndicator 可以從 Ubuntu 軟體中心 (在 Launcher上) 去安裝



檔案

    改成慣用的清單檢視顯示方式
    檔案->MenuBar->偏好設定->清單檢視,以修改日期

Skype

    從英文官網下載 skype-ubuntu-precise_4.2.0.11-1_i386.deb
    下載後在瀏覽器選擇以 Ubuntu軟體中心 來安裝. 裝完就可以使用了.

Line

    因為沒有Linux版本的wine,所以要安裝 Windows 版本的才可以,以 wine (Wine Windows Program Loader) 去執行 LineInst.exe。
    如果是從 Ubuntu 軟體中心(Unity Launcher) 去安裝 Wine 1.4, 會需要再安裝後手動升級 1.5/1.6. 否則安裝LineInst.exe 會出現錯誤訊息.
        sudo add-apt-repository ppa:ubuntu-wine/ppa
        sudo apt-get update
        sudo apt-get install wine1.5
    Line 的中文輸入一定要搭配 gcin , Ubuntu 預設的 iBus 無法輸入, 你會無法選字.

Google Chrome

    不用浪費時間去 Google 網站下載安裝 Google Chrome, 我的經驗都是失敗 …
    按照網路上的說法, Google Chrome 其實是來自 Ubuntu 的 Chromium 瀏覽器, 而這可以從 Ubuntu 軟體中心去安裝

wintricks

    如果沒有出現在 ClassicMenu Indicator 裏面的 Wine 程式集的話, 就從 console 執行
    winetricks --gui   
    選擇 Select the default wineprefix (好像會需要首次一些對話框, 應該確定就可以)
    ->Install a Windows DLL or component
    riched20 (因為 Office 會用到), vcrunxxx 全選
    他會去下載安裝一些以後我們會用到的東西

小畫家

    Ubuntu 上類似小畫家的軟體是 Pinta, 可以從軟體中心去安裝

Vmware Player

    如果你的工作需要用到 Windows , 那就會需要 Vmware Player
    從這邊下載 Linux 32Bit
        chmod 755 VMware-Player-6.0.1-1379776.i386.bundle
        sudo ./Vmware-Player-6.0.1-1379776.i386.bundle

Microsoft Office

    以 Wine 來安裝, 要注意一定要在 winetricks 裏面安裝 riched20 , 否則 PowerPoint 會無法執行起來.
        mkdir xx
        sudo mount -o look Office_Enterprise_2007_32bit_ChnTrad.ISO xx
        cd xx; wine setup.exe
    安裝完後, 就可以從桌面 或是 ClssicMenu Indicator 去選擇執行了.


OutLook 2007

    之前有使用過 Evolution ,但是感覺不是很好用,所以還是希望回到原來的 Outlook2007.






Inkscape

          向量圖形編輯器, 以前安裝 Windows 版本,現在可以安裝 Linux 版本了了,從 Ubuntu 軟體中心安裝.

OpenSCAD

          玩 3D 列印的人會用到的模型設計軟體。Ubuntu 軟體中心.

Putty

         Ubuntu 軟體中心,安裝好後,ttyS0 必須要用 root
                  sudo putty
         右鍵選單 -> Ctrl + 滑鼠右鍵 才會出現.

Wireshark

         Ubuntu 軟體中心,安裝好後,必須要用 root
                  sudo wireshark

TeamViewer

         http://www.teamviewer.com/zhtw/download/linux.aspx
    中文的部份似乎有問題,另外安裝完後似乎無法登入,可能要重開機。

Synergy

        目前測得與 VMware 會互相衝突,懶得去找問題再那。

SketchUp

        PlayOnLinux 與 Wine 都無法正常的安裝好 SketchUp, 前者是執行時無法選擇 Template ,後者是執行時抱怨缺少 OPENGL 。所以幕前只能在 VMware Player 裏面執行。

Netfabb

MeshLab

EAGLE

Any Video Converter

Play on Linux

參考這篇文章,這是一套讓 Windows 程式可以在 Wine 上跑的腳本整合軟體
   Ubuntu 軟體中心
         可以安裝 Internet Explorer 8, 甚至跑 ActiveX


RPM 與 Ubuntu apt-get/dpkg 指令對照表

Minicom

       sudo minicom  /dev/ttyS0 -c on -m
       原本打算使用 Putty , 卻因為 Copy Paste 搞不定 ,各種左鍵拉選,中鍵貼上,Shift+Ins 貼上其他程式的複製,卻無法複製出去,感覺困難重重。索性把 Minicom  灌起來用。
       Minicom 所使用的特殊按鍵 Ctrl + A 因為 Screen 會用到,所以我用 -m 的方式替換掉 Ctrl + A 特殊鍵為 Esc + Z ,另外如果要送出 Serial Break 的話,Putty 是用 Ctrl + PrintScreen,Minicom 則是 ESC , Z , F 就可以送出。
       -c on 是打開 ANSI 彩色功能。

SSH-server

       sudo apt-get install openssh-server

關閉螢幕自動鎖定

       我不確定是 NVIDIA 顯示卡驅動程式問題還是何者,似乎螢幕因為自動省電關閉後,要喚醒時有機會讓系統整個 HANG 住 (鍵盤都不會有反應) ,所以建議把
        系統設定值 ->亮度與鎖定 當不活動多就後把螢幕關閉 改成 [ 永不 ].

顯示卡驅動程式

又再發生一次螢幕 hang 住的事件,這次我更換顯示卡驅動程式
系統設定值 -> 軟體和更新 -> 額外驅動程式
從 [使用 X.Org X server ...] 更換到 [使用 NVIDIA binary Xorg driver .... 319-updates (專有)]
希望可以解決問題。



Tuesday, February 8, 2011

來自Skyter的 Google 網頁註解訊息

哈 ~ Sexduino ~
no one has done this yet, but we predict it is only a matter of time.

參考來源:

"no one has done this yet, but we predict it is only a matter of time."
- Freeduino and Boarduino and more.... - Arduino.TW樂園 (在「Google 網頁註解」中檢視)

Wednesday, November 3, 2010

ffmpeg for arm 編譯成功

所以最後我使用了./configure --enable-cross-compile --cc=arm-linux-gcc --arch=arm --target-os=linux --enable-shared --enable-gpl --disable-stripping --disable-mpegaudio-hp --enable-pthreads --enable-small --disable-parsers --disable-optimizations --disable-yasm --disable-armv6 --disable-armv5te --disable-static --disable-armvfp --disable-amd3dnow
這樣的參數來編譯 ffmepg for arm, 並且在 arm 上面執行成功.
接下來就是測試與簡化了.

參考來源: http://blog.xuite.net/jack6739/blog/37033025 (在「Google 網頁註解」中檢視)

Monday, May 17, 2010

貼入中... Cancel

 

Valgrind - 北歐神話中英靈殿的入口
功能:
Memcheck : 檢查 memory leak, malloc(), new, free(), delete 都可以被檢查. 可以偵測未被初始化的記憶體, 讀取寫入已經釋放的記憶體, 或是超過範圍的記憶體, 記憶體洩漏, 不成對的 malloc <-> free, new <-> delete, 以及 memcpy 覆寫.
Cachegrind : cache 模擬分析器, 模擬 CPU I1 D1 L2 快取記憶體
Callgrind : 類似 Cachegrind ,但是進一步整合了模擬並分析呼叫者, 被呼叫者之間的關係
Massif : heap 分析器, 可以測量統計 heap 的使用情形,stack 的大小。可以幫你降低記憶體耗盡的機會,減少 swap 來加快速度
Helgrind : 偵測 POSIX threads 之間的同步錯誤。包括不正確的使用 POSIX API. 偵測潛在的 deadlock, 搶用資料, 因為沒有 lock 而造成程序間競爭讀寫同一份資料。
Lackey : 統計指令週期,記憶體使用,以及整數,浮點數的計算。

支援:
x86, ppc. 至於 arm 則為中等程度支援 (medium)
http://www.network-theory.co.uk/valgrind/manual/valgrind-sample.pdf編輯
Valgrind: Supported PlatformsOfficial Home Page for valgrind, a suite of tools for debugging and profiling. Automatically detect memory management and threading bugs, and perform detailed profiling. The current stable version is...


Sunday, May 16, 2010

下載 Kindle for PC

下載 Kindle for PC, google: kindle for pc,

http://www.amazon.com/gp/feature.html/ref=kcp_pc_mkt_lnd?docId=1000426311

height=185

不需要 Kindle 就可以透過此軟體看書。

Read Kindle Books on Your Computer

·        Get the best reading experience available on your PC. No Kindle required

·        Access your Kindle books even if you don't have your Kindle with you

·        Automatically synchronizes your last page read and annotations between devices with Whispersync

·        Create new highlights, notes, and bookmarks and manage those created on your Kindle

·        Full screen reading view, color modes, and brightness controls offer an immersive reading experience

http://g-ecx.images-amazon.com/images/G/01/kindle/www/mazama/download/beta-1-sm-home._V227198794_.gif

View larger image

 

安裝的過程很快速,來不及抓圖

 

Amazon Kindle 同步軟體

height=228

 

可以 Highlight 也可以 Add Note , Note 的呈現有一點不直覺

height=296

 

文字雖然可以框選段落,卻無法複製到剪貼簿,文字可以放大縮小而且會按照式窗大小自動重新排版。

 height=320

 

主頁面右上角有購物車按鈕,會直接打開 Amazon 網站讓你買書。height=319

 

 

Tuesday, May 4, 2010

利用 Wireshark 進一步分析 RTP 中的 H264 (Mpeg4)

通常我們抓了一段 RTSP/RTP 封包後,了不起做個 Decode As … RTP 就結束了,無法進一步解析 RTP payload。

但是其實 Wireshark 有一個特異功能可以進一步解析 RTP 中的 H264 (Mpeg4),

只要在 Edit -> Preferences… -> Protocols -> H264 , H264 dynamic payload type : 填入 96 (也就是 RTSP Describe 內的 m=video xx RTP/AVP 96).

就可以看到 H264 Stream 的部分欄位。在RTP封包中點選有 Marker bit 或是一般封包就可以看到。

在下面可以看到 FU Identifier 以及 FU Header,按照原本 TPL 的程式判斷 nal == 67 來解析 s-property,在這邊就是 FU Identified 的值,

對照 [RFC 3984], $5.3.  NAL Unit Octet Usage 有進一步的說明各欄位的意義。

 

 

cid:image002.jpg@01CAEC5D.C98E72B0cid:image006.jpg@01CAEC5D.C98E72B0 

 

除此之外還有一個隱藏功能,請嘗試尋找最後一個 P frame ,也就是一輪 GOV 裡的最後一個 frame,點選該 frame 的最後一個 packet (Marker bit)

可以看到更多的資料。

cid:image008.jpg@01CAEC5D.C98E72B0

 

RTP Mpeg4 Stream ,選擇 Edit -> Preferences … -> Protocols -> MP4V-ES MP4V-ES dynamic payload type : 96

記得將 H264 dynamic payload type 0 ,不然應該是會有衝突。

packets 中點選 P frame 第一個 packet 可以看到一點點資料,點選 I frame 第一個 packet 可以看到較多欄位。

cid:image010.jpg@01CAEC5D.C98E72B0

 

Regards,

Skyter