From e52e8e37c241109ddc51776a8b603b3710b83988 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 11 Nov 2009 22:18:48 +0000 Subject: [PATCH] buffer bug fixed --- trbrich/pulser.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/trbrich/pulser.c b/trbrich/pulser.c index b571e0c..3070de4 100644 --- a/trbrich/pulser.c +++ b/trbrich/pulser.c @@ -11,20 +11,23 @@ #include #include -static const char pulser_version[] = "$Revision: 1.5 $"; +static const char pulser_version[] = "$Revision: 1.6 $"; -#define bufferSize 16385 +/* 1MByte for 6 Sectors should be enough */ +#define BUFFER_SIZE (1024 * 1024 / 4) /* ------ MAIN ---------------------------------------------------------- */ static FILE *hldFile = NULL; static unsigned int evtCounter = 0; +static uint32_t *buffer = NULL; static void atexit0() { if (hldFile != NULL) { fclose(hldFile); } + free(buffer); fprintf(stderr, "%d Triggers were send\n", evtCounter); } @@ -60,7 +63,6 @@ int main(int argc, char ** argv) uint8_t triggerType = 0; uint8_t input = 0; unsigned int numEvts = UINT_MAX; - uint32_t buffer[bufferSize]; sigset_t blockSet; int size; int writeToStdout = 0; @@ -132,6 +134,10 @@ int main(int argc, char ** argv) exit(EXIT_FAILURE); } + /* allocate buffer */ + buffer = (uint32_t*)malloc(sizeof(uint32_t) * BUFFER_SIZE); + if (buffer == NULL) abort(); + trg_number = 0; srand(time(NULL)); @@ -152,7 +158,7 @@ int main(int argc, char ** argv) } size = trb_ipu_data_read(triggerType, 0xcc, 0xdd, 0x0001, - buffer, bufferSize); + buffer, BUFFER_SIZE); if (size == -1) { trb_error("Error IPU Read"); exit(EXIT_FAILURE); -- 2.43.0