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. Ext4,Ext3的特点和区别(转)

    Linux kernel 自 2.6.28 开始正式支持新的文件系统 Ext4. Ext4 是 Ext3 的改进版,修改了 Ext3 中部分重要的数据结构,而不仅仅像 Ext3 对 Ext2 那样,只 ...

  2. asp 时间倒数后按钮可用

    <asp:Button runat="server" ID="btn" Text="免费获取验证码" onclick="bt ...

  3. 地铁沉降观测数据分析之巧用VBA编程处理

    地铁沉降观测数据分析之巧用VBA编程处理 当你观测了一天累的要死了,回来看着成百上千的测量数据,还要做报表.如果是三五页报表还好说,如果是2000个点的报表 按照一页纸张报30个点就得大约70页的报表 ...

  4. Android-NDK编译:cocos2d-x(二)

    看了看NDK的文档....里面总是莫名的会提下windows需要cygwin环境... 但是cocos2d-x3.0alpha1 中, 编译samples的python脚本 cocos2d-x3/bu ...

  5. Duilib技巧:背景图片平铺

    贴图的描述 方式有两种    // 1.aaa.jpg    // 2.file='aaa.jpg' res='' restype='0' dest='0,0,0,0' source='0,0,0,0 ...

  6. spring中bean配置和bean注入

    1 bean与spring容器的关系 Bean配置信息定义了Bean的实现及依赖关系,Spring容器根据各种形式的Bean配置信息在容器内部建立Bean定义注册表,然后根据注册表加载.实例化Bean ...

  7. IPv4分析

    IPv4的头部格式: 1. Version 版本号,默认是4. 2. IHL(Internet Header Length) 就是IPv4头部长度.这个长度的单位是32bit,一般是5,那么头部的长度 ...

  8. coreData 深入理解4 --总结 (线程安全与同步--iOS5 前后对比)

    Core Data是iOS中很重要的一个部分,可以理解为基于SQLite(当然也可以是其他的Storage,如In-memory,只是SQLite比较常见)的一个ORM实现,所以有关系数据库的特性,又 ...

  9. ASP.NET 如何发现问题的方法

    1.打开IntelliTrace,查看遇到的问题: 2.打开IE8以上,按F12,启动js调试,查看遇到的错误:

  10. IOS UIScrollView + UIButton 实现segemet页面和顶部标签页水平滚动效果

    很长一段时间没有写博客了,最近在学习iOS开发,看了不少的代码,自己用UIScrollView和UIButton实现了水平滚动的效果,有点类似于今日头条的主界面框架,效果如下: 代码如下: MyScr ...