2014年10月7日 星期二

[ Android ] Add device driver to kernel

take a note!

===================================================

To cross compile your own driver in the arm architecture you have to follow some steps as mentioned below.
  1. Create a directory like my_drvr inside drivers(which is in the Linux source code) for your driver and put your driver (my_driver.c) file inside this directory. It will looks like /linux_source_code/drivers/my_drvr/my_driver.c
  2. Create one Makefile inside your driver directory (using vi any editor) and inside this put obj-$((CONFIG_MY_DRIVER) += my_driver.o and save this file. This will appears like /linux_source_code/drivers/my_drvr/Makefile
  3. Create one Kconfig file inside your driver directory (using vi any editor) and inside this put
    config MY_DRIVER
    tristate "my driver" //gives your driver description like vendor name etc.
    depends on ARM
    default y if ARM
    help
      my driver module.
  4. Save this file, this will appears like /linux_source_code/drivers/my_drvr/Kconfig
  5. Add both Makefile and Kconfig file in the Linux source drivers Makefile and Kconfig file which are at /linux_source_code/drivers/Makefile and /linux_source_code/drivers/Kconfig
  6. In the Makefile add below in last line
     obj-y    += my_drvr/ 
    or
     obj-$((CONFIG_MY_DRIVER)  += my_drvr/
  7. In Kconfig file add below in last line
    source "drivers/my_drvr/Kconfig"
  8. Finally have to add Kconfig file into architecture specific config file which will be at kernel_source/arch/arm/configs/--defconfig in this add below line in the last
    CONFIG_MY_DRIVER=y
Note:- Last step will differ according to your architecture, so that you have take care. Now you can compile your driver by using make command.

===================================================

2014年8月11日 星期一

[ 投資理財 ] 筆記 : 杜金龍教室 20 堂投資必修課


1. 認識公司基本面 :

    a. 認識老闆、經營團隊、經營業務
    b. 由研究報告、相關新聞快速了解公司

2. 檢視公司財務結構 :

    a. 負債比 : ( 總負債 / 總資產 ) * 100%
        衡量公司長期償債能力的指標,< 50% 較安全
    b. 利息保障倍數 : ( 稅前淨利 + 利息費用 ) / 利息費用
        代表公司支付借貸利息的能力,x > 5 佳; x < 2 不佳
    c. 長期資金佔固定資產比率 ( 長期資產 / 固定資產淨額 ) * 100%
        長期資產 = 長期負債 + 股東權益
        代表公司投資相關設備的資金,是來自長期資金居多,還是短期負債來支應長投,> 200% 佳; < 100 % 不佳。
    d. 衍生性商品佔資產比率
    e. 公司發行的公司債

3. 了解公司償債能力 :

    a. 流動比率 : ( 流動資產 / 流動負債 ) * 100%
        衡量公司一年之內的短期償債能力,> 200% 安全;< 200% 不安全
    b. 速動比率 : ( 速動資產 / 流動負債 ) * 100%
        速動資產 = 流動資產 - 存貨 - 預付費用
        表示公司緊急償債能力,> 100% 0 安全;< 100% 不安全
    c. 利息保障倍數 ( 同前 )

4. 了解公司經營績效 :
 
    a. 存貨周轉率
    b. 應收帳蒯周轉率
    c. 總資產周轉率

5. 從獲利指標看公司賺錢能力 :

    a. 營業毛利率 :
        ( 營業毛利 / 營業收入 ) *100%
        營業毛利 = 營業收入 - 營業成本
    b. 營業利益率 :
        ( 營業利益 / 營業收入 ) *100%
        又稱 "營業淨利率", 營業利益率愈高代表公司經營本業的賺錢能力越好
    c. 純益率 :
        ( 稅後收入 / 營業收入 ) *100%
        純益率至少要高於定存利率
    d.  股東權益報酬率 :
        ( 稅後淨利 / 平均股東權益 ) *100%
       平均股東權益 = ( 年初股東權益 + 年底股東權益 ) / 2
       股東權益報酬率 > 15% 較好
 e. 資產報酬率 :
        [ 稅前淨利 + 利息 * ( 1 - 稅率 ) / 平均總資產 ] *100%
       資產報酬率愈高越好

6. 從現金流量看公司財務風險 :

    a

7. 選擇配息穩健的企業賺錢 :

    現金殖利率 = 每股股利 ( 現金股利 + 盈餘配股 ) / 每股市價
    現金殖利率愈高表示越具投資價值

8. 從本益比判斷合理股價 :

    本益比 = 股價 / 每股稅後純益 ( PER = P / EPS )











2014年8月3日 星期日

[ Android ] : bluetooth HCI log ( >= android 4.3)


After android 4.2, the bluetooth stack was changed from bluez to bluedroid;
so... the log tool ( hci tools ) was abandoned.

But you can still get BT log by thess 3 steps :

1. enable BT HCI logger at "settings > developer" :

2. modify the log level you want trace :

a. the location of configure file at /etc/bluetooth/bt_stack.conf

b. then modify the file content:
============================================================
# Enable BtSnoop logging function
# valid value : true, false
BtSnoopLogOutput=false

# BtSnoop log output file
BtSnoopFileName=/sdcard/btsnoop_hci.log

# Enable trace level reconfiguration function
# Must be present before any TRC_ trace level settings
TraceConf=true

# Trace level configuration
#   BT_TRACE_LEVEL_NONE    0    ( No trace messages to be generated )
#   BT_TRACE_LEVEL_ERROR   1    ( Error condition trace messages )
#   BT_TRACE_LEVEL_WARNING 2    ( Warning condition trace messages )
#   BT_TRACE_LEVEL_API     3    ( API traces )
#   BT_TRACE_LEVEL_EVENT   4    ( Debug messages for events )
#   BT_TRACE_LEVEL_DEBUG   5    ( Full debug messages )
#   BT_TRACE_LEVEL_VERBOSE 6    ( Verbose messages ) - Currently supported for TRC_BTAPP only.
TRC_BTM=2
TRC_HCI=2
TRC_L2CAP=2
TRC_RFCOMM=2
TRC_OBEX=2
TRC_AVCT=2
TRC_AVDT=2
TRC_AVRC=2
TRC_AVDT_SCB=2
TRC_AVDT_CCB=2
TRC_A2D=2
TRC_SDP=2
TRC_GATT=2
============================================================
you should change BtSnoopLogOutput=false >> BtSnoopLogOutput=true
and change the log level you interest, like : TRC_L2CAP=2 >> TRC_L2CAP=5
notice that the output log file at /sdcard/btsnoop_hci.log

3. read your output log file by wireshark :




2014年5月11日 星期日

[ Java ] : Bytes to hex string

public static String bytesToHex(byte[] bytes) {
    char[] hexArray = "0123456789ABCDEF".toCharArray();
        char[] hexChars = new char[bytes.length * 3];
        for ( int j = 0; j < bytes.length; j++ ) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 3] = hexArray[v >>> 4];
            hexChars[j * 3 + 1] = hexArray[v & 0x0F];
            hexChars[j * 3 + 2] = '-';
        }
        return new String(hexChars);
    }

2014年3月12日 星期三

[ Android ] : enable settings page of your Aplication

You can easily add "Settings feature" to your android app, just following these 10 steps:
( Android 4.0 & 4.4 works fine )

1. You need create your android app project with eclipse first. (here sample project is "enableSettings")

2. right click your android project >> new >> others


3. select "Android Activity"

4. select "Settings Activity"

5. No need to change, next step.

6. This "settings feature" need dependency android lib, if you can't press "Next" button, just install it.

7. Now just start your app see if can run normally, UI should like this:

8. then add this code in your android MainActivity.java, after that you should be able to go to "SettingsActivity" page:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
       
        switch (item.getItemId()) {
       
        case R.id.action_settings:
            
            Intent i = new Intent(this, SettingsActivity.class);
            startActivityForResult(i, 0);

            break;

        default:
            break;
        }
        return true;
    }

9. You can see the template settings from android now, and there are check box for boolean variable, editable dialog for string variable, list dialog for int & string ...etc, you can easily use what you need.



10. Next step you need to do a little study into the "SettingsActivity.java" file to know how to use it; and "SharedPreferences" class to access/store your app's preference.





2014年1月19日 星期日

[ Android ] : 10MinNews, dedicated app for CNN 10

Update : 2020/02/21

App Name : 10MinNews

Newest version : 1.4

App Type : English Learning / News

Install : install page

Download apk:from google cloud

簡介 :
追蹤最近 60 天 CNN 10 的影片與簡稿;
可以邊看影片邊看簡稿比對學習,幫助你增加英文的聽讀能力。

Introduce :
Trace latest 60 videos & scripts of CNN 10.
You can watch video & script at same page / at same time.
Easily enhance your English reading & listening abilities.

主要功能包括 :
- 下載影片與簡稿到本地後可離線操作。
- 選取簡稿單字,翻譯並紀錄。
- 分享你的單字筆記。

Main Features include :
- You can download video & script to do offline learning.
- You can select a word to translate, to take a note.
- You can share your note.

Demo Pictures :