X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fsensor.c;h=a3d3f0b4a0c0e75f0f5de2c5d0c84db15cb11b68;hb=69483d953c93566731f72445a077dfcf60e01bf3;hp=f1ec5dc836c1df6ba1a49e117ff8a66f381efa01;hpb=259624013535f3c93315868efb5f6f611ba88470;p=matches%2FMCTX3420.git diff --git a/server/sensor.c b/server/sensor.c index f1ec5dc..a3d3f0b 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -105,13 +105,12 @@ void * Sensor_Main(void * arg) // CRITICAL SECTION (no threads should be able to read/write the file at the same time) pthread_mutex_lock(&(s->mutex)); - // Open binary file and dump buffer into it - FILE * file = fopen(s->filename, "wb"); + // Open binary file in append mode and dump buffer into it + FILE * file = fopen(s->filename, "ab"); if (file == NULL) { - Fatal("Couldn't open file \"%s\" mode wb - %s", s->filename, strerror(errno)); + Fatal("Couldn't open file \"%s\" mode ab - %s", s->filename, strerror(errno)); } - fseek(file, 0, SEEK_END); int amount_written = fwrite(s->buffer, sizeof(DataPoint), SENSOR_DATABUFSIZ, file); if (amount_written != SENSOR_DATABUFSIZ) {