Exemplo n.º 1
0
END_TEST

START_TEST (test_encode_can_signal_rounding_precision)
{
    uint64_t value = encodeCanSignal(&SIGNALS[3], 50);
    ck_assert_int_eq(value, 0x061a800000000000LLU);
}
Exemplo n.º 2
0
END_TEST

START_TEST (test_encode_can_signal)
{
    uint64_t value = encodeCanSignal(&SIGNALS[1], 0);
    ck_assert_int_eq(value, 0);
}
Exemplo n.º 3
0
uint64_t booleanWriter(CanSignal* signal, CanSignal* signals,
        int signalCount, cJSON* value, bool* send, uint64_t data) {
    checkWritePermission(signal, send);
    int intValue = 0;
    if(value->type == cJSON_False) {
        intValue = 0;
    } else if(value->type == cJSON_True) {
        intValue = 1;
    }
    return encodeCanSignal(signal, intValue, data);
}
Exemplo n.º 4
0
uint64_t stateWriter(CanSignal* signal, CanSignal* signals,
        int signalCount, const char* value, bool* send, uint64_t data) {
    if(value == NULL) {
        debug("Can't write state of NULL -- not sending\r\n");
    } else {
        CanSignalState* signalState = lookupSignalState(value, signal, signals,
                signalCount);
        if(signalState != NULL) {
            checkWritePermission(signal, send);
            return encodeCanSignal(signal, signalState->value, data);
        } else {
            debug("Couldn't find a valid signal state for \"%s\"", value);
        }
    }
    *send = false;
    return 0;
}
Exemplo n.º 5
0
uint64_t encodeCanSignal(CanSignal* signal, float value) {
    return encodeCanSignal(signal, value, 0);
}
Exemplo n.º 6
0
uint64_t numberWriter(CanSignal* signal, CanSignal* signals,
        int signalCount, cJSON* value, bool* send, uint64_t data) {
    checkWritePermission(signal, send);
    return encodeCanSignal(signal, value->valuedouble, data);
}