Truncate nrL1_stats.log before writing

Without this, the remainder of the file remains in place, and this can
be confusing if the total file size reduces.
This commit is contained in:
Robert Schmidt
2025-10-29 08:11:50 +01:00
parent 48faffc131
commit 93cadc9d63
+4 -1
View File
@@ -314,13 +314,16 @@ void *nrL1_stats_thread(void *param) {
reset_meas(&gNB->dlsch_precoding_stats);
while (!oai_exit) {
sleep(1);
if (ftruncate(fileno(fd), 0) != 0 || fseek(fd, 0, SEEK_SET) != 0) {
LOG_E(NR_MAC, "error while writing nrL1_stats.log: %d, %s\n", errno, strerror(errno));
break;
}
dump_nr_I0_stats(fd,gNB);
dump_pdsch_stats(fd,gNB);
dump_pusch_stats(fd,gNB);
dump_L1_meas_stats(gNB, ru, output, L1STATSSTRLEN);
fprintf(fd,"%s\n",output);
fflush(fd);
fseek(fd,0,SEEK_SET);
}
fclose(fd);
return(NULL);