diff --git a/include/buzz_update.h b/include/buzz_update.h index 3e99d86..c4bd963 100644 --- a/include/buzz_update.h +++ b/include/buzz_update.h @@ -10,6 +10,7 @@ #define delete_p(p) do { free(p); p = NULL; } while(0) + /*********************/ /* Updater states */ /********************/ @@ -120,4 +121,6 @@ int test_set_code(uint8_t* BO_BUF, const char* dbgfname,size_t bcode_size); void destroy_updater(); +int is_msg_present(); + #endif diff --git a/src/buzz_update.cpp b/src/buzz_update.cpp index a877945..c78e3c9 100644 --- a/src/buzz_update.cpp +++ b/src/buzz_update.cpp @@ -24,7 +24,7 @@ static int no_of_robot; static char* dbgf_name; static const char* bzz_file; static int neigh=0; - +static int updater_msg_ready ; void init_update_monitor(const char* bo_filename, const char* stand_by_script,int barrier){ fprintf(stdout,"intiialized file monitor.\n"); fd=inotify_init1(IN_NONBLOCK); @@ -90,6 +90,7 @@ void init_update_monitor(const char* bo_filename, const char* stand_by_script,in updater->mode=(int*)malloc(sizeof(int)); *(int*)updater->mode=CODE_RUNNING; no_of_robot=barrier; + updater_msg_ready=0; //neigh = 0; //updater->outmsg_queue= // update_table->barrier=nvs; @@ -153,6 +154,7 @@ void code_message_outqueue_append(){ fp=fopen("update.bo", "wb"); fwrite((updater->bcode), updater->bcode_size, 1, fp); fclose(fp);*/ + updater_msg_ready=1; *(uint16_t*)updater->outmsg_queue->size=size; //fprintf(stdout,"out mes append transfer code %d\n", transfer_code); @@ -343,12 +345,16 @@ void destroy_out_msg_queue(){ delete_p(updater->outmsg_queue->queue); delete_p(updater->outmsg_queue->size); delete_p(updater->outmsg_queue); +updater_msg_ready=0; } int get_update_mode(){ return *(int*)updater->mode; } +int is_msg_present(){ +return updater_msg_ready; +} void destroy_updater(){ delete_p(updater->bcode); delete_p(updater->bcode_size); diff --git a/src/buzz_utility.cpp b/src/buzz_utility.cpp index 9932676..f882d3f 100644 --- a/src/buzz_utility.cpp +++ b/src/buzz_utility.cpp @@ -128,7 +128,7 @@ namespace buzz_utility{ tot += sizeof(uint16_t); uint8_t updater_msg_pre = 0; uint16_t updater_msgSize= 0; - if((int)get_update_mode()!=CODE_RUNNING){ + if((int)get_update_mode()!=CODE_RUNNING && is_msg_present()){ //fprintf(stdout,"transfer code %d\n", transfer_code); updater_msg_pre =1; //transfer_code=0;