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,14 +142,18 @@ 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
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 != -1 && shared_message->s_pedal_value != -1){
if(shared_message->b_pedal_value)
ac = ac | 0x01;
if(shared_message->s_pedal_value)
@ -160,6 +164,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
bvc_hf->accelerationControl->size = 1;
bvc_hf->accelerationControl->bits_unused = 0;
}
}
// Set speed
bvc_hf->speed.speedValue = facilities->epv.space.speed;
@ -243,6 +248,7 @@ 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 != -1){
if(shared_message->lights_value)
el = el | 0x01;
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
@ -250,6 +256,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
bvc_lf->exteriorLights.size = 1;
bvc_lf->exteriorLights.bits_unused = 0;
}
}
PathHistory_t* ph = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency.pathHistory;