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. BitNami 里有好多开源软件

    https://bitnami.com/stacks BitNami 提供wordpress.joomla.drupal.bbpress等开源程序的傻瓜式安装包下载,所有的安装包内置了服务器环境,就是 ...

  2. XML 文档和数据

    .NET Framework 4.5 其他版本 .NET Framework 提供了一组全面而集成的类,可用来方便地生成可以识别 XML 的应用程序. 通过以下命名空间中的类,可以分析和编写 XML, ...

  3. CentOS 7.0系统安装配置LAMP服务器(Apache+PHP+MariaDB)

    CentOS 7.0接触到的用户是比较少的,今天看了站长写了一篇关于centos7中安装配置LAMP服务器的教程,下面我把文章稍加整理一下转给大家学习交流,希望例子能给各位带来帮助哦.   cento ...

  4. [leetode]Binary Search Tree Iterator

    用个stack模拟递归即可 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * Tr ...

  5. java判断乱码

    开发需要,判断乱码,baidu了一下,基本都是同一份代码 if (!Character.isLetterOrDigit(c)) {        ->  这个有问题,中文文字被识别成字母及数字 ...

  6. python 跳出嵌套循环方法

    class LoopError(Exception):pass rs = '' try: for i in range(1, 3): print i rs = 'one ' if i == 1: fo ...

  7. C#获取内网和外网IP

    写了个小客户端,里面用到了获取内网和外网的IP地址,代码如下: // InnerIP var ipHost = Dns.Resolve(Dns.GetHostName()); ]; innerIP = ...

  8. Python Django 开发 3 数据库CURD

    上一篇表建好后开始对数据进行CURD操作 dos输入: >>>python manage.py shell 以下的命令都是在shell中测试 (C)增: >>>im ...

  9. 【原】Oracle11gR2图文安装

    作者:david_zhang@sh [转载时请以超链接形式标明文章] http://www.cnblogs.com/david-zhang-index/p/4365475.html 本文以看图说话的方 ...

  10. [转载]QString 乱谈(3)-Qt5与中文

    原文地址http://blog.csdn.net/dbzhang800/article/details/7542672?reload 两个月前,简单写过QTextCodec中的setCodecForT ...