Only spawn CP thread if dissemination.active

This commit is contained in:
emanuel 2022-10-12 12:39:24 +01:00
parent d9ee59ced4
commit 3d8a851263
3 changed files with 7 additions and 3 deletions

View File

@ -708,7 +708,7 @@ void *cp_service(){
/* Reads from the radar */
i32_recv_bytes = recv(raw_socket.raw_fd, &au8_readBuffer, READ_BUFFER_SIZE, 0);
if (dissemination_check(1) && facilities.dissemination.active){
if (dissemination_check(1)) {
if(is_radar_connected){
/* Information parsing from radar */
parse_input(au8_readBuffer,i32_recv_bytes);

View File

@ -839,7 +839,8 @@ int main() {
pthread_create(&facilities.infrastructure_service, NULL, infrastructure_service, NULL);
// CP
pthread_create(&facilities.cp_service, NULL, cp_service, NULL);
if (facilities.dissemination.active)
pthread_create(&facilities.cp_service, NULL, cp_service, NULL);
// SA
pthread_create(&facilities.sa_service, NULL, sa_service, NULL);
@ -942,7 +943,8 @@ cleanup:
pthread_join(facilities.ca_service, NULL);
pthread_join(facilities.den_service, NULL);
pthread_join(facilities.infrastructure_service, NULL);
pthread_join(facilities.cp_service, NULL);
if (facilities.dissemination.active)
pthread_join(facilities.cp_service, NULL);
pthread_join(facilities.sa_service, NULL);
itss_queue_trigger(facilities.tx_queue);
pthread_join(facilities.transmitting, NULL);

View File

@ -24,10 +24,12 @@ int tpm_is_inside_zone(tolling_info_t* ti) {
int rv = 0;
double point[2];
int16_t heading;
itss_space_lock();
itss_space_get();
point[0] = epv.space.latitude/1.0e7;
point[1] = epv.space.longitude/1.0e7;
heading = epv.space.heading;
itss_space_unlock();
if (itss_is_inside_polygon(point, ti->zone.polygon, ti->zone.polygon_len)) {