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)的更多相关文章

  1. ok6410 android driver(11)

    This essay, I go to a deeply studying to android HAL device driver program. According to the android ...

  2. 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 ...

  3. ok6410 android driver(8)

    In the past, we know how to create and run a simple character device driver on pc, goldfish and ok64 ...

  4. ok6410 android driver(3)

    This article discusses the Makefile and how to port the module to different platform (localhost and ...

  5. ok6410 android driver(12)

    In this essay, I will talk about how to write the service libraries. TIPS : I won't discuss the name ...

  6. ok6410 android driver(10)

    From this essay, we go to a new discussion "Android Hardware Abstraction Layer". In this e ...

  7. ok6410 android driver(7)

    This article talk about how to test device driver on JNI. There are two ways to test the device driv ...

  8. ok6410 android driver(6)

    This is a short essay about the mistakes in compiling ok6410 android-2.3 source codes. If there is n ...

  9. ok6410 android driver(1)

    target system : Android (OK6410) host system : Debian Wheezy AMD64 1.Set up android system in ok6410 ...

随机推荐

  1. java Clone之深浅拷贝

    要点: 1.浅度拷贝可以不实现Cloneable接口(自动使用Object.clone)或者不重写Cloneable的clone方法. 2.要被深度拷贝的类必须实现Cloneable接口并重写clon ...

  2. 英語版Windows Server 2012 R2を日本語化する手順

    [スタート]ボタンを押し.[Control Panel]を起動 [Clock, Language and Region]の下の[Add a Language]をクリック [Add a Language ...

  3. Java程序员转Android开发必读经验分享

    小编最近几日偷偷的发现部分Java程序员想转安卓开发,故此加紧补充知识,为大家搜集资料,积极整理前人的经验,希望可以给正处于困惑中的你,带来些许的帮助. 啰哩啰嗦的说说Java和Android程序的区 ...

  4. 手机软件mockup设计工具

    软件界面设计工具 UIDesigner v2.5 详见 http://www.downyi.com/downinfo/26770.html

  5. Gradle 笔记

    网上有一篇文章说的很明白,图文来教你在eclipse下用gradle 来打包Androidhttp://blog.csdn.net/x605940745/article/details/4124268 ...

  6. struts2:拦截器

    拦截器(Interceptor)是Struts 2的核心组件,Struts 2框架的大部分功能都是通过拦截器来完成的,例如数据校验,国际化,文件上传和下载等.为了实现这些功能,Struts 2框架提供 ...

  7. Log4Net简单使用

    一. Log4net是什么.优点 用来记录程序日志,优点:1.提供应用程序运行时的精确环境,可供开发人员尽快找到应用程序中的Bug:2.日志信息可以输出到不同的地方(数据库,文件,邮箱等). 二. L ...

  8. Office 2013 Excel 转换 Word

    最新文章:Virson's Blog 参考文章:百度百科 1.使用Excel打开需要转换的Excel文档: 2.采用另存为*.htm的方式将该Excel文档另存为网页,如下图: 3.找到保存的htm网 ...

  9. Cocos2d-JS项目之一:环境(IDE 运行js-tests、IDE 和 studio 统一工程)

    环境:cocos 引擎(包括 studio)2.2.1 for Mac.cocos2d-js-v3.5.Cocos Code IDE 1.2 for Mac,cocos 引擎指的是下面这个东西: 各种 ...

  10. C头文件和源文件的连

    (http://blog.163.com/yui_program/blog/static/18415541520115177852896/) 一.源文件如何根据#include来关联头文件 1,系统自 ...