From f68d4c04ba23d89f3984f398d8d4298885d7b794 Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Wed, 7 May 2025 02:36:24 -0700 Subject: Fix first time start offset==0 cause read_data read data from remote and write duplicate data to local --- remote_plot.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/remote_plot.c b/remote_plot.c index f7031b3..fcd018a 100644 --- a/remote_plot.c +++ b/remote_plot.c @@ -263,6 +263,8 @@ typedef struct { char *filename; // only read from local .csv file or not bool local; + // just start up the program + bool just_start; }DATA; static gboolean read_data(gpointer user_data) @@ -273,8 +275,10 @@ static gboolean read_data(gpointer user_data) DATA *data=user_data; bool new_entry=false; - if(data->local) + if(data->local || data->just_start) { + data->just_start=false; + //printf("read_data check local pass\n"); FILE *fp; if((fp=fopen(data->filename,"r"))!=NULL) @@ -923,6 +927,7 @@ int main (int argc, char **argv) data.from_time_entered=false; data.offset=0; data.local=false; + data.just_start=true; //printf("after init\n"); -- cgit v1.2.3-70-g09d2