Skip to content
Snippets Groups Projects
Commit b91afa21 authored by burneykb's avatar burneykb
Browse files

only creates new log file when loging new data

parent 8222f023
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,7 @@ fd_set rfds_master;
int max_fd = 0;
static FILE * quadlog_file;
static int quadlog_file_open;
static char user_specified_log_name[256] = "";
pthread_mutex_t quadResponseMutex, cliInputMutex ;
......@@ -211,6 +212,7 @@ int main(int argc, char **argv)
printf("Creating log file '%s'...\n",log_file);
quadlog_file = fopen(log_file, "a");
quadlog_file_open = 1;
// Tell the quad we are ready to send it vrpn data
sendStartPacket();
......@@ -795,6 +797,12 @@ static void quad_recv() {
switch (m.msg_type) {
case LOG_ID:
if (!quadlog_file_open) {
char log_file[256];
create_log_name(log_file, 256);
printf("New log file created: '%s'\n", log_file);
quadlog_file = fopen(log_file, "a");
}
/* something like this */
printf("(Quad) : Log found\n");
fwrite((char *) data, sizeof(char), m.data_len, quadlog_file);
......@@ -808,11 +816,10 @@ static void quad_recv() {
handleResponse(&m, data);
break;
case LOG_END_ID:
fclose(quadlog_file);
char log_file[256];
create_log_name(log_file, 256);
printf("New log file created: '%s'\n", log_file);
quadlog_file = fopen(log_file, "a");
if (quadlog_file_open) {
fclose(quadlog_file);
quadlog_file_open = 0;
}
break;
default:
printf("(Backend): message type %d ignored from quad\n", m.msg_type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment