Updater msg send fix
This commit is contained in:
parent
b5bb610043
commit
a857272acb
|
@ -10,6 +10,7 @@
|
||||||
#define delete_p(p) do { free(p); p = NULL; } while(0)
|
#define delete_p(p) do { free(p); p = NULL; } while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
/* Updater states */
|
/* Updater states */
|
||||||
/********************/
|
/********************/
|
||||||
|
@ -120,4 +121,6 @@ int test_set_code(uint8_t* BO_BUF, const char* dbgfname,size_t bcode_size);
|
||||||
|
|
||||||
void destroy_updater();
|
void destroy_updater();
|
||||||
|
|
||||||
|
int is_msg_present();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,7 @@ static int no_of_robot;
|
||||||
static char* dbgf_name;
|
static char* dbgf_name;
|
||||||
static const char* bzz_file;
|
static const char* bzz_file;
|
||||||
static int neigh=0;
|
static int neigh=0;
|
||||||
|
static int updater_msg_ready ;
|
||||||
void init_update_monitor(const char* bo_filename, const char* stand_by_script,int barrier){
|
void init_update_monitor(const char* bo_filename, const char* stand_by_script,int barrier){
|
||||||
fprintf(stdout,"intiialized file monitor.\n");
|
fprintf(stdout,"intiialized file monitor.\n");
|
||||||
fd=inotify_init1(IN_NONBLOCK);
|
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));
|
updater->mode=(int*)malloc(sizeof(int));
|
||||||
*(int*)updater->mode=CODE_RUNNING;
|
*(int*)updater->mode=CODE_RUNNING;
|
||||||
no_of_robot=barrier;
|
no_of_robot=barrier;
|
||||||
|
updater_msg_ready=0;
|
||||||
//neigh = 0;
|
//neigh = 0;
|
||||||
//updater->outmsg_queue=
|
//updater->outmsg_queue=
|
||||||
// update_table->barrier=nvs;
|
// update_table->barrier=nvs;
|
||||||
|
@ -153,6 +154,7 @@ void code_message_outqueue_append(){
|
||||||
fp=fopen("update.bo", "wb");
|
fp=fopen("update.bo", "wb");
|
||||||
fwrite((updater->bcode), updater->bcode_size, 1, fp);
|
fwrite((updater->bcode), updater->bcode_size, 1, fp);
|
||||||
fclose(fp);*/
|
fclose(fp);*/
|
||||||
|
updater_msg_ready=1;
|
||||||
*(uint16_t*)updater->outmsg_queue->size=size;
|
*(uint16_t*)updater->outmsg_queue->size=size;
|
||||||
|
|
||||||
//fprintf(stdout,"out mes append transfer code %d\n", transfer_code);
|
//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->queue);
|
||||||
delete_p(updater->outmsg_queue->size);
|
delete_p(updater->outmsg_queue->size);
|
||||||
delete_p(updater->outmsg_queue);
|
delete_p(updater->outmsg_queue);
|
||||||
|
updater_msg_ready=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_update_mode(){
|
int get_update_mode(){
|
||||||
return *(int*)updater->mode;
|
return *(int*)updater->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_msg_present(){
|
||||||
|
return updater_msg_ready;
|
||||||
|
}
|
||||||
void destroy_updater(){
|
void destroy_updater(){
|
||||||
delete_p(updater->bcode);
|
delete_p(updater->bcode);
|
||||||
delete_p(updater->bcode_size);
|
delete_p(updater->bcode_size);
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace buzz_utility{
|
||||||
tot += sizeof(uint16_t);
|
tot += sizeof(uint16_t);
|
||||||
uint8_t updater_msg_pre = 0;
|
uint8_t updater_msg_pre = 0;
|
||||||
uint16_t updater_msgSize= 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);
|
//fprintf(stdout,"transfer code %d\n", transfer_code);
|
||||||
updater_msg_pre =1;
|
updater_msg_pre =1;
|
||||||
//transfer_code=0;
|
//transfer_code=0;
|
||||||
|
|
Loading…
Reference in New Issue