fctom1215
2020-08-28 cff87234c496f0a4522cd2ac57941f14c729b6ad
lib/src/main/cpp/test_common/car_sensor.cpp
@@ -76,6 +76,7 @@
    memset(SensorConfig, 0, sizeof(SensorConfig));
    memset(CarStatus, 0, sizeof(CarStatus));
    CarStatus[DOOR] = DOOR_CLOSE;
    memset(&Sensor, 0, sizeof(Sensor));
@@ -88,36 +89,36 @@
void SetSensorCfg(int (*sensor)[3], int sensorNum)
{
    DEBUG("加入传感器配置 sensorNum %d", sensorNum);
    pthread_mutex_lock(&sonser_mutex);
    SensorNum = sensorNum;
    for (int i = 0; i < sensorNum; ++i) {
        DEBUG("    配置<%d>: id %d - fun %d - lvl %d", i, sensor[i][0], sensor[i][1], sensor[i][2]);
        SensorConfig[i].gpioId = sensor[i][0];
        SensorConfig[i].funId = sensor[i][1];
        if (sensor[i][2] > 0) {
            SensorConfig[i].validLvl = 1;
        } else {
            SensorConfig[i].validLvl = 0;
        }
        int level = 0;
        if (gpioStore & BV(SensorConfig[i].gpioId)) {
            level = 1;
        }
        if (level == SensorConfig[i].validLvl) {
            SensorChanged(SensorConfig[i].funId, 1);
        } else {
            SensorChanged(SensorConfig[i].funId, 0);
        }
    }
    pthread_mutex_unlock(&sonser_mutex);
//    DEBUG("加入传感器配置 sensorNum %d", sensorNum);
//
//    pthread_mutex_lock(&sonser_mutex);
//
//    SensorNum = sensorNum;
//    for (int i = 0; i < sensorNum; ++i) {
//        DEBUG("    配置<%d>: id %d - fun %d - lvl %d", i, sensor[i][0], sensor[i][1], sensor[i][2]);
//
//        SensorConfig[i].gpioId = sensor[i][0];
//        SensorConfig[i].funId = sensor[i][1];
//        if (sensor[i][2] > 0) {
//            SensorConfig[i].validLvl = 1;
//        } else {
//            SensorConfig[i].validLvl = 0;
//        }
//
//        int level = 0;
//
//        if (gpioStore & BV(SensorConfig[i].gpioId)) {
//            level = 1;
//        }
//
//        if (level == SensorConfig[i].validLvl) {
//            SensorChanged(SensorConfig[i].funId, 1);
//        } else {
//            SensorChanged(SensorConfig[i].funId, 0);
//        }
//    }
//
//    pthread_mutex_unlock(&sonser_mutex);
}
void UpdateSensor(uint16_t gpio, uint16_t speed, uint16_t rpm)
@@ -187,8 +188,8 @@
    if (s->handBreak != Sensor.handBreak && s->handBreak != '#') {
        SensorChanged(SENSOR_HANDBREAK, BX(s->handBreak));
    }
    if (s->lock != Sensor.lock && s->lock != '#') {
        SensorChanged(SENSOR_DOOR, BX(s->lock));
    if (s->door != Sensor.door && s->door != '#') {
        SensorChanged(SENSOR_DOOR, BX(s->door));
    }
    if (s->surround1 != Sensor.surround1 && s->surround1 != '#') {
        SensorChanged(SENSOR_SURROUND_CAR_1, BX(s->surround1));