2015年5月23日 星期六

[Android]Linux kernel 開發基礎 (五)- driver attribute

透過driver attribute的讀寫,

可以讓使用者用讀寫檔案方式,直接跟driver溝通,

這在debug與其他driver之間互動提供了簡便的方法,

要在driver定義attribute只需要兩個步驟

1. 定義attribute本身:


static ssize_t hello_show(struct device *dev,struct device_attribute *attr, char *buf)
{


printk("hello_show \n");

return 0;
}
static ssize_t hello_store(struct device *dev,struct device_attribute *attr,const char *buf, size_t size)
{
printk("hello_store \n");
return -1;
}

static struct device_attribute hello_adv_setting = {
.attr = {
.name = "hello_adv",
.mode = 0664,
},
.show = hello_show,
.store = hello_store,
};

static struct device_attribute *hello_adv_group[] = {
&hello_adv_setting,
// &hello_adv_setting2,

};

2. 在driver建立attribute檔案

for (i = 0; i < ARRAY_SIZE(hello_adv_group); i++) { ret = device_create_file(&pdev->dev,hello_adv_group[i]);
if (ret) {
dev_err(&pdev->dev, "failed: sysfs file %s\n",hello_adv_group[i]->attr.name);
}
}

如果還不是很明白,

可以下載範例程式來觀看

2015年5月22日 星期五

[dreamstime]新增相片

許久未更新的Dreamstime , 閒著沒事上傳了幾張照片去審查,

沒想到竟然過了七張,

令人相當意外,

還記得當年剛註冊時候,傳了一堆只合格五張,

錄取率只能說是低的破表,

該說是事隔多年技術提昇了呢?還是國外風景比較受評審歡迎?

有興趣的人請點:前往欣賞

2015年5月7日 星期四

[推薦]Asus ZenTalk

是的
今天要來推薦的是ASUS官方推出的網站 ZenTalk
顧名思義這個網站主要是為了ASUS手機 Zenfone建立的網站
不過呢
除了手機相關活動(比如說底下抽手機活動)與討論之外

這網站還有許多網友提供的app使用心得
或者網友分享的照片等等
是一個不錯的論壇

前往可以點擊上方超連結
或者底下:
ASUS ZenTalk