diff --git a/src/cam.c b/src/cam.c index 8e1e79f..8e72eb2 100644 --- a/src/cam.c +++ b/src/cam.c @@ -142,23 +142,28 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len) // Speed (already getting set bellow) // bvc_hf.speed.speedValue = ceil(shared_message->speed_value รท 0.036); + // bvc_hf_speed.speedConfidence = 1; // Steering Wheel Angle - bvc_hf->steeringWheelAngle = malloc(sizeof(SteeringWheelAngle_t)); - bvc_hf->steeringWheelAngle->steeringWheelAngleValue = shared_message->w_angle_value; - + if(shared_message->w_angle_value != -1){ + bvc_hf->steeringWheelAngle = malloc(sizeof(SteeringWheelAngle_t)); + bvc_hf->steeringWheelAngle->steeringWheelAngleValue = shared_message->w_angle_value; + bvc_hf->steeringWheelAngle->steeringWheelAngleConfidence = 1; + } // still missing temperature; where is de_temperature ? // Acceleration Control - if(shared_message->b_pedal_value) - ac = ac | 0x01; - if(shared_message->s_pedal_value) - ac = ac | 0x02; - bvc_hf->accelerationControl = malloc(sizeof(AccelerationControl_t)); - bvc_hf->accelerationControl->buf = malloc(sizeof(uint8_t)); - memcpy(bvc_hf->accelerationControl->buf, &ac, 1); - bvc_hf->accelerationControl->size = 1; - bvc_hf->accelerationControl->bits_unused = 0; + if(shared_message->b_pedal_value != -1 && shared_message->s_pedal_value != -1){ + if(shared_message->b_pedal_value) + ac = ac | 0x01; + if(shared_message->s_pedal_value) + ac = ac | 0x02; + bvc_hf->accelerationControl = malloc(sizeof(AccelerationControl_t)); + bvc_hf->accelerationControl->buf = malloc(sizeof(uint8_t)); + memcpy(bvc_hf->accelerationControl->buf, &ac, 1); + bvc_hf->accelerationControl->size = 1; + bvc_hf->accelerationControl->bits_unused = 0; + } } // Set speed @@ -243,12 +248,14 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len) uint8_t el = 0x00; // Exterior Lights - if(shared_message->lights_value) - el = el | 0x01; - bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t)); - memcpy(bvc_lf->exteriorLights.buf, &el, 1); - bvc_lf->exteriorLights.size = 1; - bvc_lf->exteriorLights.bits_unused = 0; + if(shared_message->lights_value != -1){ + if(shared_message->lights_value) + el = el | 0x01; + bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t)); + memcpy(bvc_lf->exteriorLights.buf, &el, 1); + bvc_lf->exteriorLights.size = 1; + bvc_lf->exteriorLights.bits_unused = 0; + } } PathHistory_t* ph = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency.pathHistory;