check for valid shmem values

This commit is contained in:
David Rocha 2022-01-20 13:46:21 +00:00
parent 0205c1b16a
commit f4f9ab8359
1 changed files with 25 additions and 18 deletions

View File

@ -142,23 +142,28 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
// Speed (already getting set bellow) // Speed (already getting set bellow)
// bvc_hf.speed.speedValue = ceil(shared_message->speed_value ÷ 0.036); // bvc_hf.speed.speedValue = ceil(shared_message->speed_value ÷ 0.036);
// bvc_hf_speed.speedConfidence = 1;
// Steering Wheel Angle // Steering Wheel Angle
bvc_hf->steeringWheelAngle = malloc(sizeof(SteeringWheelAngle_t)); if(shared_message->w_angle_value != -1){
bvc_hf->steeringWheelAngle->steeringWheelAngleValue = shared_message->w_angle_value; 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 ? // still missing temperature; where is de_temperature ?
// Acceleration Control // Acceleration Control
if(shared_message->b_pedal_value) if(shared_message->b_pedal_value != -1 && shared_message->s_pedal_value != -1){
ac = ac | 0x01; if(shared_message->b_pedal_value)
if(shared_message->s_pedal_value) ac = ac | 0x01;
ac = ac | 0x02; if(shared_message->s_pedal_value)
bvc_hf->accelerationControl = malloc(sizeof(AccelerationControl_t)); ac = ac | 0x02;
bvc_hf->accelerationControl->buf = malloc(sizeof(uint8_t)); bvc_hf->accelerationControl = malloc(sizeof(AccelerationControl_t));
memcpy(bvc_hf->accelerationControl->buf, &ac, 1); bvc_hf->accelerationControl->buf = malloc(sizeof(uint8_t));
bvc_hf->accelerationControl->size = 1; memcpy(bvc_hf->accelerationControl->buf, &ac, 1);
bvc_hf->accelerationControl->bits_unused = 0; bvc_hf->accelerationControl->size = 1;
bvc_hf->accelerationControl->bits_unused = 0;
}
} }
// Set speed // 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; uint8_t el = 0x00;
// Exterior Lights // Exterior Lights
if(shared_message->lights_value) if(shared_message->lights_value != -1){
el = el | 0x01; if(shared_message->lights_value)
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t)); el = el | 0x01;
memcpy(bvc_lf->exteriorLights.buf, &el, 1); bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
bvc_lf->exteriorLights.size = 1; memcpy(bvc_lf->exteriorLights.buf, &el, 1);
bvc_lf->exteriorLights.bits_unused = 0; bvc_lf->exteriorLights.size = 1;
bvc_lf->exteriorLights.bits_unused = 0;
}
} }
PathHistory_t* ph = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency.pathHistory; PathHistory_t* ph = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency.pathHistory;