summaryrefslogtreecommitdiffstats
path: root/recipes-extended
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2016-12-18 23:51:08 +0900
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2016-12-19 10:53:26 +0000
commitc85d8a963aab816b05db9ee6230dc8da8c9b0569 (patch)
tree40e18f04434ea45315ac776aa8f1e1a12be4c3b8 /recipes-extended
parentc6cc8e564f14a31e5125baf29ebb8550ec20b5d7 (diff)
Add recipe of AGL Demo HMI (HVAC)
This recipe is to deliver AGL Demo Platform for CES2017 AGL Showcase by bitbake integration. To use hmi of HVAC, it should be installed on the target board at least once afer booting. The package of application, hvac.wgt would be installed in /usr/AGL/apps on the target board. To install it, follow these steps from the target console or remote shell. # cd /usr/AGL/apps # afm-util install hvac.wgt Change-Id: I4d90dcae44fc6a5bedf2b26682ae2dcbfd4db6ee Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'recipes-extended')
0 files changed, 0 insertions, 0 deletions
l */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Copyright (C) 2016 "IoT.bzh"
 * Author Fulup Ar Foll <fulup@iot.bzh>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <systemd/sd-event.h>

#include "afb-timer.h"

#define DEFAULT_PAUSE_DELAY 3000
#define DEFAULT_TEST_COUNT 1
typedef struct {
    int value;
    const char *uid;
} AutoTestCtxT;


static int TimerNext (sd_event_source* source, uint64_t timer, void* handle) {
    TimerHandleT *timerHandle = (TimerHandleT*) handle;
    int done;
    uint64_t usec;

    done= timerHandle->callback(timerHandle);
    if (!done) {
        AFB_API_WARNING(timerHandle->api, "TimerNext Callback Fail Tag=%s", timerHandle->uid);
        return -1;
    }

    // Rearm timer if needed
    timerHandle->count --;
    if (timerHandle->count == 0) {
        sd_event_source_unref(source);
        if (timerHandle->freeCB) timerHandle->freeCB(timerHandle->context);
        free (handle);
        return 0;
    }
    else {
        // otherwise validate timer for a new run
        sd_event_now(afb_api_get_event_loop(timerHandle->api), CLOCK_MONOTONIC, &usec);
        sd_event_source_set_enabled(source, SD_EVENT_ONESHOT);
        sd_event_source_set_time(source, usec + timerHandle->delay*1000);
    }

    return 0;
}

void TimerEvtStop(TimerHandleT *timerHandle) {
    sd_event_source_unref(timerHandle->evtSource);
    if (timerHandle->freeCB) timerHandle->freeCB(timerHandle->context);
    free (timerHandle);
}

void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context) {
    uint64_t usec;

    // populate CB handle
    timerHandle->callback=callback;
    timerHandle->context=context;
    timerHandle->api=api;

    // set a timer with ~250us accuracy
    sd_event_now(afb_api_get_event_loop(api), CLOCK_MONOTONIC, &usec);
    sd_event_add_time(afb_api_get_event_loop(api), &timerHandle->evtSource, CLOCK_MONOTONIC, usec+timerHandle->delay*1000, 250, TimerNext, timerHandle);
}

uint64_t LockWait(afb_api_t api, uint64_t utimeout) {
    uint64_t current_usec, pre_usec;

    struct sd_event *event = afb_api_get_event_loop(api);

    sd_event_now(event, CLOCK_MONOTONIC, &pre_usec);
    sd_event_run(event, utimeout);
    sd_event_now(event, CLOCK_MONOTONIC, &current_usec);

    uint64_t diff = current_usec - pre_usec;
    utimeout = utimeout < diff ? 0 : utimeout - diff;
    return utimeout;
}