Format, some docs
This commit is contained in:
parent
1d3469e840
commit
aef5bf4797
23
src/cam.c
23
src/cam.c
|
|
@ -90,7 +90,7 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
|
|
||||||
lightship_t* lightship = &facilities.lightship;
|
lightship_t* lightship = &facilities.lightship;
|
||||||
|
|
||||||
if (lightship->use_obd){
|
if (lightship->use_obd) {
|
||||||
it2s_obd_data* shared_message = malloc(sizeof(it2s_obd_data));
|
it2s_obd_data* shared_message = malloc(sizeof(it2s_obd_data));
|
||||||
it2s_obd_read(shared_message);
|
it2s_obd_read(shared_message);
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
cam->cam.camParameters.highFrequencyContainer.present = HighFrequencyContainer_PR_basicVehicleContainerHighFrequency;
|
cam->cam.camParameters.highFrequencyContainer.present = HighFrequencyContainer_PR_basicVehicleContainerHighFrequency;
|
||||||
BasicVehicleContainerHighFrequency_t* bvc_hf = &cam->cam.camParameters.highFrequencyContainer.choice.basicVehicleContainerHighFrequency;
|
BasicVehicleContainerHighFrequency_t* bvc_hf = &cam->cam.camParameters.highFrequencyContainer.choice.basicVehicleContainerHighFrequency;
|
||||||
|
|
||||||
if(lightship->use_obd){
|
if (lightship->use_obd) {
|
||||||
uint8_t ac = 0x00;
|
uint8_t ac = 0x00;
|
||||||
|
|
||||||
// Speed (already getting set bellow)
|
// Speed (already getting set bellow)
|
||||||
|
|
@ -143,7 +143,7 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
// still missing temperature; where is de_temperature ?
|
// still missing temperature; where is de_temperature ?
|
||||||
|
|
||||||
// Acceleration Control (encondig failure)
|
// Acceleration Control (encondig failure)
|
||||||
if(shared_message->b_pedal_value != 1683 && shared_message->s_pedal_value != 1683 && (now/1000 - shared_message->b_pedal_timestamp) <= 1 && (now - shared_message->s_pedal_timestamp) <= 1){
|
if (shared_message->b_pedal_value != 1683 && shared_message->s_pedal_value != 1683 && (now/1000 - shared_message->b_pedal_timestamp) <= 1 && (now - shared_message->s_pedal_timestamp) <= 1){
|
||||||
if(shared_message->b_pedal_value)
|
if(shared_message->b_pedal_value)
|
||||||
ac = ac | 0x80;
|
ac = ac | 0x80;
|
||||||
if(shared_message->s_pedal_value)
|
if(shared_message->s_pedal_value)
|
||||||
|
|
@ -234,12 +234,12 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
|
|
||||||
BasicVehicleContainerLowFrequency_t* bvc_lf = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency;
|
BasicVehicleContainerLowFrequency_t* bvc_lf = &cam->cam.camParameters.lowFrequencyContainer->choice.basicVehicleContainerLowFrequency;
|
||||||
|
|
||||||
if(lightship->use_obd){
|
if (lightship->use_obd) {
|
||||||
uint8_t el = 0x00;
|
uint8_t el = 0x00;
|
||||||
|
|
||||||
// Exterior Lights
|
// Exterior Lights
|
||||||
if(shared_message->lights_value != 1683 && (now/1000 - shared_message->lights_timestamp) <= 1){
|
if (shared_message->lights_value != 1683 && (now/1000 - shared_message->lights_timestamp) <= 1) {
|
||||||
if(shared_message->lights_value)
|
if (shared_message->lights_value)
|
||||||
el = el | 0x80;
|
el = el | 0x80;
|
||||||
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
|
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
|
||||||
memcpy(bvc_lf->exteriorLights.buf, &el, 1);
|
memcpy(bvc_lf->exteriorLights.buf, &el, 1);
|
||||||
|
|
@ -277,6 +277,7 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
|
|
||||||
ph->list.array[i]->pathDeltaTime = calloc(1,sizeof(PathDeltaTime_t));
|
ph->list.array[i]->pathDeltaTime = calloc(1,sizeof(PathDeltaTime_t));
|
||||||
*ph->list.array[i]->pathDeltaTime = (lightship->pos_history[i]->ts - lightship->pos_history[i+1]->ts)/10;
|
*ph->list.array[i]->pathDeltaTime = (lightship->pos_history[i]->ts - lightship->pos_history[i+1]->ts)/10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lightship->last_cam_lfc = now;
|
lightship->last_cam_lfc = now;
|
||||||
|
|
@ -354,19 +355,17 @@ int lightship_init() {
|
||||||
|
|
||||||
lightship_t* lightship = &facilities.lightship;
|
lightship_t* lightship = &facilities.lightship;
|
||||||
|
|
||||||
lightship->protected_zones.pz = calloc(256 , sizeof(void*));
|
lightship->protected_zones.pz = calloc(256, sizeof(void*));
|
||||||
pthread_mutex_init(&lightship->lock, NULL);
|
pthread_mutex_init(&lightship->lock, NULL);
|
||||||
|
|
||||||
lightship->pos_history = malloc(POS_HISTORY_MAX_LEN * sizeof(void*));
|
lightship->pos_history = malloc(POS_HISTORY_MAX_LEN * sizeof(void*));
|
||||||
|
|
||||||
int shm_fd;
|
int shm_fd;
|
||||||
shm_fd = shm_open("it2s-obd", O_RDONLY, 0666);
|
shm_fd = shm_open("it2s-obd", O_RDONLY, 0666);
|
||||||
if(shm_fd == -1){
|
if (shm_fd == -1) {
|
||||||
log_debug("obd shmem not found\n");
|
log_debug("obd shmem not found\n");
|
||||||
lightship->use_obd = 0;
|
lightship->use_obd = 0;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else{
|
|
||||||
log_debug("obd shmem found\n");
|
log_debug("obd shmem found\n");
|
||||||
lightship->use_obd = 1;
|
lightship->use_obd = 1;
|
||||||
close(shm_fd);
|
close(shm_fd);
|
||||||
|
|
@ -700,7 +699,7 @@ static int check_pz() {
|
||||||
return is_inside;
|
return is_inside;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ca_service() {
|
void* ca_service() {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
TransportRequest_t* tr = calloc(1, sizeof(TransportRequest_t));
|
TransportRequest_t* tr = calloc(1, sizeof(TransportRequest_t));
|
||||||
|
|
|
||||||
27
src/cam.h
27
src/cam.h
|
|
@ -86,12 +86,39 @@ typedef struct lightship {
|
||||||
|
|
||||||
} lightship_t;
|
} lightship_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Initializes the main CA struct (lightship)
|
||||||
|
*
|
||||||
|
* @return Always zero
|
||||||
|
*/
|
||||||
int lightship_init();
|
int lightship_init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Checks if a CAM must be sent
|
||||||
|
*
|
||||||
|
* @return True if CAM must be sent, false otherwise
|
||||||
|
*/
|
||||||
int lightship_check();
|
int lightship_check();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Resets the CAM sending timer
|
||||||
|
*
|
||||||
|
* @return Nothing
|
||||||
|
*/
|
||||||
void lightship_reset_timer();
|
void lightship_reset_timer();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Analyzes a received CAM
|
||||||
|
*
|
||||||
|
* @return A CAM check code
|
||||||
|
*/
|
||||||
enum CAM_CHECK_R check_cam(BTPPacketIndication_t* bpi, CAM_t* cam,uint8_t* ssp, uint32_t ssp_len);
|
enum CAM_CHECK_R check_cam(BTPPacketIndication_t* bpi, CAM_t* cam,uint8_t* ssp, uint32_t ssp_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Main CA service
|
||||||
|
*
|
||||||
|
* @return NULL
|
||||||
|
*/
|
||||||
void* ca_service();
|
void* ca_service();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue