ok6410 android driver(5)
Test the android driver by JNI (Java Native Interface),
In the third article, we know how to compiler the moduler for localhost, ok6410 and goldfish platform.
http://www.cnblogs.com/plinx/p/3209500.html
But we didn't try to test the driver using by C/C++ program on ok6410 and goldfish.
Android was changing from linux, so there must remain some fetures linux working.
If we want to test a driver using C/C++ program, we should get ready for the following conditions :
(1) Goldfish emulator/Ok6410/Phone must got the permission to "root".
(2) The exec file compiled by the cross compiler.
It's easy to go on within these limits, we just need to compile the C/C++ program in the android source configured by "Android.mk".
Here is the Android.mk :
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # files to compiler
LOCAL_SRC_FILES := ftest.c # obj name - the output execute file name
LOCAL_MODULE := ftest LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE)
And the ftest.c is :
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h> int main(int argc, char *argv[])
{
int testdev;
int ret;
int num = ;
unsigned char buf[]; testdev = open("/dev/wordcount2", O_RDWR); if(testdev == -) {
printf("Can not open file.\n");
return ;
} if(argc > ) {
printf("Strings : %s.\n", argv[]);
write(testdev, argv[], strlen(argv[]));
} read(testdev, buf, ); num = ((int)buf[]) << | \
((int)buf[]) << | \
((int)buf[]) << | \
((int)buf[]); printf("Word Byte : 0x%d%d%d%dH\n", buf[], buf[], buf[], buf[]);
printf("word count: %d\n", num); close(testdev);
return ;
}
now, we should mkdir in the source code :
$ pwd
~/Android/source_code/development/ndk/wordcount
$ ls
Android.mk ftest.c
then return to the root directory :
$ cd ~/Android/source_code/
$ source build/envsetup.sh
$ mmm development/ndk/wordcount
...
Install: out/target/product/generic/system/bin/ftest
...
Then we just need to push the file to emulator and test it.
ok6410 android driver(5)的更多相关文章
- ok6410 android driver(11)
This essay, I go to a deeply studying to android HAL device driver program. According to the android ...
- ok6410 android driver(9)
In this essay, I will write the JNI to test our leds device. If you don't know how to create a jni p ...
- ok6410 android driver(8)
In the past, we know how to create and run a simple character device driver on pc, goldfish and ok64 ...
- ok6410 android driver(3)
This article discusses the Makefile and how to port the module to different platform (localhost and ...
- ok6410 android driver(12)
In this essay, I will talk about how to write the service libraries. TIPS : I won't discuss the name ...
- ok6410 android driver(10)
From this essay, we go to a new discussion "Android Hardware Abstraction Layer". In this e ...
- ok6410 android driver(7)
This article talk about how to test device driver on JNI. There are two ways to test the device driv ...
- ok6410 android driver(6)
This is a short essay about the mistakes in compiling ok6410 android-2.3 source codes. If there is n ...
- ok6410 android driver(1)
target system : Android (OK6410) host system : Debian Wheezy AMD64 1.Set up android system in ok6410 ...
随机推荐
- Andriod调用http请求
// 新建HttpPost对象 HttpPost httpPost = new HttpPost( "http://180.153.1.1:8080/mybankGateway/gatewa ...
- android studio logcat 换行(日志换行)
起因 今天突然要调试网络数据,调试一大截那个xml数据. 解决思路 一开始去setting哪里看一下logcat 是否有line break,类似的字眼,可惜没有. 我猜如果没有在设置的话,估计就在“ ...
- 没有公网IP的服务器如何通过有公网的服务器实现远程管理的功能?即VPN服务器搭建过程
由于很多PPPoE帐号都没有公网IP了,那我们如何实现远程管理呢? 答案是比较简单的,首先,你要拥有一台有公网IP的路由器,其他品牌的也可以,但是下面我以WayOs作为VPN服务器,给大家一个教程. ...
- This application is currently offline. To enable the application, remove the app_offline.htm file from the application r
退出VS ,把程序中主目录里的app_offline.htm文件删除,重新启动VS 就可以了.
- Android Screen Orientation Change (Screen Rotation) Example
原文见: http://techblogon.com/android-screen-orientation-change-rotation-example/#
- Android WebView Demo
activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android& ...
- 使用aspose.cell导出excel需要注意什么?
1.如果导出的数据源是汇总出来的,最好方法是将数据源放到缓存里面,当基本数据源变化的时候,在改变数据2.使用模板导出EXCEL,这样很多样式可以在模板文件里面直接设置,例如:默认打开页签,让列头固定3 ...
- uniGUI试用笔记(十五)通过URL控制参数
通过URL代入参数,在代码中读取,如: http://localhost:8501/?ServerPort=212&&ServerIP=192.168.31.12 在代码中可以通过: ...
- 用 Python 和 OpenCV 检测图片上的条形码
用 Python 和 OpenCV 检测图片上的的条形码 这篇博文的目的是应用计算机视觉和图像处理技术,展示一个条形码检测的基本实现.我所实现的算法本质上基于StackOverflow 上的这个问 ...
- 程序员编程艺术第三十六~三十七章、搜索智能提示suggestion,附近点搜索
第三十六~三十七章.搜索智能提示suggestion,附近地点搜索 作者:July.致谢:caopengcs.胡果果.时间:二零一三年九月七日. 题记 写博的近三年,整理了太多太多的笔试面试题,如微软 ...