Bug debugging for sensor in high-pass non-ADSP architecture

Source: Internet
Author: User
    • Qualcomm sensor from native to Hal
    • High-pass HAL layer of sensor HAL
    • Bmp18x.cpp of the high-pass HAL Layer
Problem phenomenon:

After hibernation, when the preesure sensor is opened again, there will be a period of time after the APK will appear data; (data can sometimes be difficult to show)

Problem Analysis:

From the above sections, we can know that the framework to HAL is removed by invoking the call sensors.msm8909.so into the function PressureSensor::readEvents ;

int pressuresensor::readevents (sensors_event_t* data, int count) {int i = 0;    if (count < 1) return-einval;        if (mhaspendingevent) {mhaspendingevent = false;        Mpendingevent.timestamp = Gettimestamp ();        *data = mpendingevent; Return menabled?    1:0;        } if (mhaspendingmetadata) {mhaspendingmetadata--;        Meta_data.timestamp = Gettimestamp ();        *data = Meta_data; Return menabled?    1:0;    } ssize_t n = Minputreader.fill (DATA_FD);    if (n < 0) return n;    int numeventreceived = 0; Input_event const* event; #if Fetch_full_event_before_returnagain: #endif while (Count &&        Minputreader.readevent (&event)) {int type = event->type;            if (type = = Ev_abs) {Float value = event->value;            Mpendingevent.pressure = value * convert_pressure;        Alogi ("The Pressure is%f\n", mpendingevent.pressure); } else if (type = = Ev_syn) {SwitCH (event->code) {case syn_time_sec:museabstimestamp = true;                    Report_time = event->value*1000000000ll;                Break                    Case Syn_time_nsec:museabstimestamp = true;                    Mpendingevent.timestamp = report_time+event->value;                Break Case Syn_report:if (Museabstimestamp! = True) {Mpendingevent.timestamp = Timeva                    Ltonano (Event->time); } if (menabled) {//Alogi ("timestamp =%ld Menabledtime =%ld Museabstimestamp =% D Enable here\n ", Mpendingevent.timestamp, Menabledtime, museabstimestamp);//if (mpendingevent.times                            Tamp >= menabledtime) {*data = mpendingevent; Alogi ("Data pressure is%f\n", data->pressure);//DAta++;                        numeventreceived++;                    } count--;            } break; }} else {Aloge ("Pressuresensor:unknown event (type=%d, code=%d)", type, event->        code);    } minputreader.next (); } #if Fetch_full_event_before_return/* If we didn ' t read a complete EVENT, see if we can fill and try again inste Ad of returning with nothing and redoing poll.        */if (numeventreceived = = 0 && menabled = = 1) {n = Minputreader.fill (DATA_FD);    if (n) goto again;    } #endif Alogi ("End the data the pressure is%f\n", mpendingevent.pressure); return numeventreceived;}

Increasing if (mPendingEvent.timestamp >= mEnabledTime) judgment is to judge SYN_REPORT the situation without delay;

mPendingEvent.timestampHere is the value assigned:

input_event const* event;//这个可以一直进来if(mUseAbsTimeStamp != true) {  mPendingEvent.timestamp = timevalToNano(event->time);}

event->timeRepresents the keystroke time, which can be used to struct timeval get the system time.
input_eventand the timeval structure of the body is as follows:

struct input_event {struct timeval time; //按键时间__u16 type; //类型,在下面有定义__u16 code; //要模拟成什么按键__s32 value;//是按下还是释放};struct timeval {   __kernel_time_t        tv_sec;     /* seconds */  __kernel_suseconds_t    tv_usec;    /* microseconds */};
//将时间转换为nsstatic int64_t timevalToNano(timeval const& t) {      return t.tv_sec*1000000000LL + t.tv_usec*1000;}

By printing can know that the problem occurs when the time mPendingEvent.timestamp is less than mEnabledTime the judgment, so the upper layer will not be able to obtain the corresponding data;

mEnabledTimeis implemented in a int PressureSensor::enable(int32_t, int en) function:

....    mEnabledTime = getTimestamp() + IGNORE_EVENT_TIME;....
int64_t SensorBase::getTimestamp() {    struct timespec t;    t.tv_sec = t.tv_nsec = 0;    clock_gettime(CLOCK_BOOTTIME, &t);    return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;}//不过CLOCK_BOOTTIME计算系统suspend的时间,也就是说,不论是running还是suspend(这些都算是启动时间),CLOCK_BOOTTIME都会累积计时,直到系统reset或者shutdown。

So in the sleep mEnabledTime will be greater than mPendingEvent.timestamp , so at this time there is no reporting data, the judgment can be removed;

Patch Address

Patch

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.