placed mutex lock on tsb iin map_vis

This commit is contained in:
karthikmurakonda 2022-10-26 11:04:32 +05:30
parent a9b3081782
commit 1a80ce316d
4 changed files with 16 additions and 7 deletions

View File

@ -43,6 +43,7 @@ pthread_mutex_t mutex_file; /* To lock PMU Setup File */
pthread_mutex_t mutex_Lower_Layer_Details; /* To lock objects of connection table that hold lower layer PMU/PDC ip and protocol */
pthread_mutex_t mutex_Upper_Layer_Details; /* To lock objects of connection table that hold upper layer PDC ip and protocol */
pthread_mutex_t mutex_status_change;
pthread_mutex_t mutex_on_TSB;
unsigned char *cfgframe,*dataframe;

View File

@ -56,7 +56,7 @@
int i;
int front = -1;
int rear = -1;
pthread_mutex_t mutex_on_TSB = PTHREAD_MUTEX_INITIALIZER;
/* ---------------------------------------------------------------------------- */

View File

@ -1,4 +1,6 @@
#include <stdlib.h>
#include <pthread.h>
#include "global.h"
#include "align_sort.h"
#include "map_vis.h"
#include "parser.h"
@ -15,6 +17,8 @@ int loops = 0;
gboolean update_images(gpointer* pars){
int match=0,id;
myParameters* parameters = (myParameters*) pars;
pthread_mutex_lock(&mutex_on_TSB);
struct data_frame *df = TSB[0].first_data_frame;
struct Lower_Layer_Details *LLptr;
@ -23,14 +27,15 @@ gboolean update_images(gpointer* pars){
}
if (curr_measurement==0)
{
int i = 0;
int i = 0, k = 0;
float freq;
while (df!=NULL){
freq = to_intconvertor(df->dpmu[i]->freq)*0.001+50;
live_chart_serie_add(serie, freq*1e-1);
loops++;
printf("loops: %d\n", loops);
id = to_intconvertor(TSB[0].idlist[i].idcode);
id = to_intconvertor(df->idcode);
printf("id = %d\n",id);
LLptr = LLfirst;
@ -50,9 +55,9 @@ gboolean update_images(gpointer* pars){
float freq = to_intconvertor(df->dpmu[i]->freq)*0.001+50;
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
}
// if(parameters->g_last_image != 0){
// // osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
// }
if (freq > 50.300){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
}else{
@ -68,9 +73,11 @@ gboolean update_images(gpointer* pars){
// }
}
df = df->dnext;
i++;
// i++;
k++;
}
}
pthread_mutex_unlock(&mutex_on_TSB);
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;

View File

@ -71,6 +71,7 @@ void recreate_cfg_objects(){
pthread_mutex_init(&mutex_status_change, NULL);
pthread_mutex_init(&mutex_Lower_Layer_Details, NULL);
pthread_mutex_init(&mutex_Upper_Layer_Details, NULL);
pthread_mutex_init(&mutex_on_TSB, NULL);
CMDSYNC[0] = 0xaa;
CMDSYNC[1] = 0x41;