2014年12月30日 星期二

用指令把關鍵字丟google搜尋

https://code.google.com/p/pygoogle/

pygoogle is a very basic Google search module for Python. It has a limitation of only 64 results. If you want more results, see xgoogle

一個python工具, 直接把關鍵字當參數餵進去就吐出結果了


在cygwin上裝python跑  太輕鬆啦!

2014年12月27日 星期六

搞Linux

http://handingsky.blogspot.tw/2012/02/kernel-initrd-root-filesystem.html

  • make modules_install 把各模組放到/lib/modules/`uname -r`/下面去,並且建立module間的dependacny
  • depmod -a 這會重新尋找目前kernel下的所有模組,重新建立彼此的dependancy,如果你是third party的driver,基本上會放在/lib/modules/`uname -r`/extra底下,這時必須重建modules.dep。

2014年12月22日 星期一

Linux下操cpu運算的一行指令

http://www.linuxidc.com/Linux/2009-06/20495.htm

time echo “scale=5000; 4*a(1)” | bc -l -q

time是计时程序。scale是精度,4*a(1)调用了反正切函数。由三角函数我们知道1的反正切是pi/4, pi=4* pi/4。 -l -q参数的意思请参照manpage。这一行其实就是让bc计算1的反正切,计算精度是5000位。

2014年12月17日 星期三

為了SPI Flash 控制, 加入mtd

http://giros.pixnet.net/blog/post/96929648-support-spi-flash-on-linux

kernel 2.6.28裡面有一個支援 SPI flash 的驅動程式 m25p80.c,於是乎我就把它搬進來2.6.21,然後再做了一點小修改,如此一來就支援 Linux 本來用來讀取flash的MTD架構,更白話的說就是可以支援MTD partition切割以及利用mtd-utils等工具來讀寫flash了。

2014年12月12日 星期五

Android HAL 進階追碼

http://myblog-maurice.blogspot.tw/2011/12/android-hal.html


Android硬件抽象层(HAL)概要介绍和学习计划
http://blog.csdn.net/luoshengyang/article/details/6567257


HAL stub的框架比較簡單,三個結構體、兩個常量、一個函數,簡稱321架構,它的定義在:
@hardware/libhardware/include/hardware/hardware.h
@hardware/libhardware/hardware.c
http://fanli7.net/a/caozuoxitong/Android/2012/1016/236821.html

http://www.360doc.com/content/12/0117/10/3700464_179849603.shtml

Android HAL 初始入門

hw_module_t struct Reference

Every hardware module must have a data structure named HAL_MODULE_INFO_SYM and the fields of this data structure must begin with hw_module_t followed by module specific information.
找這個關鍵字


一個HelloWorld
http://blog.csdn.net/luoshengyang/article/details/6573809

hello.h
  1.   
  2. /*定义模块ID*/  
  3. #define HELLO_HARDWARE_MODULE_ID "hello"  
  4.   
  5. /*硬件模块结构体*/  
  6. struct hello_module_t {  
  7.     struct hw_module_t common;  
  8. };  
  9.   
  10. /*硬件接口结构体*/  
  11. struct hello_device_t {  
  12.     struct hw_device_t common;  
  13.     int fd;  
  14.     int (*set_val)(struct hello_device_t* dev, int val);  
  15.     int (*get_val)(struct hello_device_t* dev, int* val);  
  16. }; 

盜 連 程式語言界的鄙視鏈

http://vinta.ws/blog/695

2014年12月11日 星期四

Linux 下使用 Bluetooth USB Dongle

http://lang.idv.tw/doku.php/os/linux/linux%E4%B8%8B%E4%BD%BF%E7%94%A8_bluetooth_usb_dongle

舊時代的Android wireless Bluetooth porting guide (FroYo/Gingerbread)

http://processors.wiki.ti.com/index.php/Android_wireless_build_and_porting_guide#Bluedroid

當時kernel不支援使用 rfkill 開關 BT module, 於是使用wl1271bt_enable 程式來代替rfkill的作用

Android logcat 基本用法

參考 http://www.miui.com/article-272-1.html

指定標籤顯示訊息
# logcat [tag]:* *:S

指定輸出成檔案
# logcat -f [filename]

設定格式,加入時間資訊
# logcat -v time

看一個例子
adb logcat ActivityManager:I MyApp:d *:S       上面表达式的最后的元素 *:S ,,是设置所有的标 签为”silent”,所有日志只显示有”View” and “MyApp”的,用 *:S 的另一个用处是 能够确保日志输出的时候是按照过滤器的说明限制的,也让过滤器也作为一项输出到日志中. 

2014年12月10日 星期三

Android BlueDroid porting 需要 vendor提供 libbt-vendor.so

external/bluetooth/bluedroid/hci/src/Bt_hw.c
在init_vnd_if()函数可以看到其实是一个libbt-vendor.so的interface。这个是Vendor(芯片厂商)的library
Vendor就是芯片供应商的意思,在他们做好一块蓝牙芯片后,需要提供一些硬件相关的动作,比如上下电,设置波特率之类的。但是这些操作一般不会对没有许可的开放。Bluedroid提供了一个统一的接口bt_vendor_interface_t,供应商只需要实现这个接口定义的蓝牙相关的操作就可以交给bluedroid去做剩下的事情了

2014年12月9日 星期二

Android BlueDroid 移植跟調試講解

http://blog.csdn.net/xiaojsj111/article/details/12647923

Android 4.4 藍芽大補帖 完整!

http://www.cnblogs.com/shed/p/3737016.html

Android 4.2 BlueDroid support USB HCI

http://paz00.ru/index.php?title=Bluedroid_4.2_battle&setlang=en
http://stackoverflow.com/questions/17608727/does-android-4-2-2-support-usb-bluetooth-dongle

CyanogenMod and Android-X86 contain patches to support USB HCI like this:

To enable this support in board look at android-x86 example, for BoardConfig
# Some framework code requires this to enable BT
BOARD_HAVE_BLUETOOTH := true
BLUETOOTH_HCI_USE_USB := true
BOARD_HAVE_BLUETOOTH_BCM := true
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/generic/x86/bluetooth
and for buildcfg
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H 
#define BTM_DEF_LOCAL_NAME "Android-x86"
// At present either USB or UART is supported
#define BLUETOOTH_HCI_USE_USB          TRUE
// Bluetooth Low Power Mode is supported on BT4.0
#define HCILP_INCLUDED                 FALSE
#endif
Also your kernel need UHID support.

藍芽常識術語

http://www.plantronics.com/tw/support/kb/detail.jsp?vfurl=/articles/zh_TW/Product_Information/RN16992&retURL=%2Farticles%2Fzh_TW%2FHow_To%2FRN18627&region=tw&p=13&c=All&k=%25E9%2585%258D%25E5%25B0%258D&t=&lang=zh_TW&popup=false

藍牙技術中ACL和SCO 指的是?

藍牙基帶技術支持兩種連接方式:
  • ACL (Asynchronous Connectionless Link)       無連接的異步連接(主要用于分組數據傳輸)
  • SCO (Synchronous Connection Oriented Link) 面向連接的同步連接(主要用于話音傳輸)
藍牙技術用來無線連接不同生産廠家生産的藍牙設備,這些設備之間也需要相互的溝通,以便他們確認進行什麽樣類型的服務。藍牙耳機是用于語音、聽和說的音頻設備,但當耳機不進行上述工作時,它還是要和其它的作爲音訊閘道(audio gateway,簡稱AG)的設備,如手機,USB適配器進行溝通。

壹旦耳機完成了與AG的配對,它將進入壹個待機模式。當耳機與AG在有效範圍內時,它們以ACL方式連接。耳機與AG相互檢測以確認範圍,檢測控制信號如來電,重撥或語音撥號需要等。

如果AG接收到壹個電話且耳機的ACL是良好的,AG將將信號知會給耳機,耳機將發出哔哔聲提示用戶有來電。按下耳機通話控制按鈕,知會AG耳機可以開啓SCO且語音數據可以在耳機和AG之間進行交換。

Freescale對Android 4.4 bluetooth with USB support的態度

最新: https://community.freescale.com/thread/336813


https://community.freescale.com/docs/DOC-94235#comment-3898

Sorry, For USB HCI, it should be considered by Google. It is only for UART HCI now. We don't focus on this.



https://community.freescale.com/docs/DOC-93985#comment-9604
Woogeun Shin 2014/2/3 上午 3:44

Hi Sandesh and Chris,

I've also tried to use USB Bluetooth dongle with JB4.2.2 and IMX6 Sagbresd board.
In my case, i use libusb library to access USB Bluetooth device. .
I did reference below link to do that.
ac100 - Bluedroid 4.2 battle

I can create SCO link between USB Bluetooth device and USB headset.
But i don't know how to send traffic this SCO link.

If you have any progress about SCO issue, could you share that in here?

Thanks,
Shin.

Android 4.2之後 藍芽結構與程式碼分布

Android Official Document
http://source.android.com/devices/bluetooth.html

http://blog.sina.com.cn/s/blog_69b5d2a50101f2ew.html
  1. application framework
    • 程式碼: framework/base/core/java/android/bluetooth/
  2. Bluetooth System service
    • 程式碼: packages/apps/Bluetooth/
  3. JNI
    • 程式碼: packages/apps/Bluetooth/jni/
  4. HAL
    • 你得實現這些接口來讓你的BT Hardware運作正常
    • 程式碼的標頭檔:    
      • hardware/libhardware/include/hardware/bluetooth.h
      • hardware/libhardware/include/hardware/bt_*.h
  5. BT Stack
    • 4.2開始, 預設為BlueDroid
    • 程式碼: external/bluetooth/bluedroid/
  6. Vendor extension
    • 為了追蹤添加自定義擴展和一個HCI層,創建一個libbt-vendor模組去指定

Download Android lollipop source code via repo

repo init -u https://android.googlesource.com/platform/manifest  -b android-5.0.0_r6

or

repo init -u https://android.googlesource.com/platform/manifest  -b lollipop-dev


repo sync -j8

2014年12月4日 星期四

Android bluetooth BlueZ

參考  http://my.oschina.net/u/1436933/blog/192060



http://processors.wiki.ti.com/index.php/TI-Android-JB-PortingGuide


a thread on porting bluetooth
http://forum.xda-developers.com/showthread.php?p=39907803#post39907803

Helloworld JNI

參考  中文網頁  http://yuanfarn.blogspot.tw/2013/12/javah-native-support-jni.html

可以使用javah來自動從java code產生C 的 header 與 source code

對照Android project src的話  在framework/base/  下面可以找到許多名叫jni的資料夾
裡面塞滿一些 *.cpp檔, 都是用來實作JNI的 (這種抓著皮毛追脈絡的方式可能不是很正統....反正這應該只是我個人的筆記對吧?  不正統也不是害別人)

JNI如何在Android中運作呢?

參考  http://my.oschina.net/u/874134/blog/158621

分層呼叫控制  http://www.embedu.org/Column/Column339.htm

http://www.cnblogs.com/keis/archive/2011/04/12/2013174.html

2014年12月3日 星期三

bash shell裡的指令 "source"

正在使用的ubuntu 14.04裡的sh, 預設是dash

Android build/envsetup.sh , 用dash執行會有語法辨識錯誤

Syntax error: "(" unexpected

用bash才不會出錯