Android simulator framework and driver sensor 2 (Generate Test tool)

Source: Internet
Author: User

We have prepared our own driver before, and now we want to test our tool in android.
 
 
 
 
Here, I use extern to compile and generate a tool, which can be executed in the adb shell to capture our temperature value.
 
 
 
 
This step is relatively simple and can be seen as a linux application with code:
 
/External/temperature. c
 
<Strong> <span style = "color: # cc33cc;" >#include <stdio. h>
# Include <stdlib. h>
# Include <fcntl. h>
# Include <linux/input. h>
 
/*
Struct input_event
{
Struct timeval time;
_ 2010type;
_ 2010code;
_ S32 value;
};*/
 
Int main (void)
{
Struct input_event ev_temp;
Int fd = open ("/dev/input/event2", O_RDWR );
 
While (1)
{
Int count = read (fd, & ev_temp, sizeof (struct input_event ));
If (EV_ABS = ev_temp.type & ABS_PRESSURE = ev_temp.code)
{
Printf ("time: % ld, % d", ev_temp.time. TV _sec, ev_temp.time. TV _usec );
Printf ("Current Temperature: % d \ n", ev_temp.value );
}
}
Return 0;
} </Span> </strong>
I won't talk much about it here. Everyone can understand it. Next is the makefile for android,
<Strong> <span style = "color: # cc33cc;" >#include <stdio. h>
# Include <stdlib. h>
# Include <fcntl. h>
# Include <linux/input. h>
 
/*
Struct input_event
{
Struct timeval time;
_ 2010type;
_ 2010code;
_ S32 value;
};*/
 
Int main (void)
{
Struct input_event ev_temp;
Int fd = open ("/dev/input/event2", O_RDWR );
 
While (1)
{
Int count = read (fd, & ev_temp, sizeof (struct input_event ));
If (EV_ABS = ev_temp.type & ABS_PRESSURE = ev_temp.code)
{
Printf ("time: % ld, % d", ev_temp.time. TV _sec, ev_temp.time. TV _usec );
Printf ("Current Temperature: % d \ n", ev_temp.value );
}
}
Return 0;
} </Span> </strong>
I won't talk much about it here. Everyone can understand it. Next we will talk about makefile for android,/external/temperature/Android. mk.
/External/temperature/Android. mk <pre name = "code" class = "cpp"> <strong> <span style = "color: # cc33cc;"> LOCAL_PATH :=$ (call my-dir)
 
Include $ (CLEAR_VARS)
 
LOCAL_MODULE_TAGS: = optional
 
LOCAL_MODULE: = temperature
 
LOCAL_SRC_FILES: = $ (call all-subdir-c-files)
 
Include $ (BUILD_EXECUTABLE) </span> </strong>
<Pre name = "code" class = "cpp"> <strong> <span style = "color: # cc33cc;"> LOCAL_PATH :=$ (call my-dir)
 
Include $ (CLEAR_VARS)
 
LOCAL_MODULE_TAGS: = optional
 
LOCAL_MODULE: = temperature
 
LOCAL_SRC_FILES: = $ (call all-subdir-c-files)
 
Include $ (BUILD_EXECUTABLE) </span> </strong>
After compilation, the tool will be generated under out/.../generic/system/bin,
 
 
Run the following command in the adb shell:
Run the following command on the adb shell: <pre name = "code" class = "cpp"> <span style = "color: # cc33cc; "> <strong> root @ jay:/home/jay # adb shell
#
#
#
#
# Temperature
Time: 81,292 520 Current Temperature: 1
Time: 84,409 53 Current Temperature: 2
Time: 86,617 26 Current Temperature: 3
Time: 88,423 23 Current Temperature: 4
Time: 90,618 05 Current Temperature: 5
^ C
# </Strong> </span>
<Pre name = "code" class = "cpp"> <span style = "color: # cc33cc;"> <strong> root @ jay:/home/jay # adb shell
#
#
#
#
# Temperature
Time: 81,292 520 Current Temperature: 1
Time: 84,409 53 Current Temperature: 2
Time: 86,617 26 Current Temperature: 3
Time: 88,423 23 Current Temperature: 4
Time: 90,618 05 Current Temperature: 5
^ C
# </Strong> </span>
This is done. The following is the HAL of temperature, so stay tuned...
 

From the column zhangjie201412

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.