From: hadaq Date: Fri, 29 Oct 2010 18:46:22 +0000 (+0000) Subject: major bug in FIFO_READ_MEM... fixed (wrong static variable) X-Git-Tag: v6.0~189 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=72eef38421d218805e08f204b07ea1862fa6ba61;p=trbnettools.git major bug in FIFO_READ_MEM... fixed (wrong static variable) --- diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index 830342d..1914c0a 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -1,4 +1,4 @@ -const char trbnet_version[] = "$Revision: 2.85 $"; +const char trbnet_version[] = "$Revision: 2.86 $"; #include #include @@ -512,6 +512,9 @@ static int trb_fifo_read(uint8_t channel, /* Read FIFO-Buffer, copy to User-Buffer */ while ((*tmp & MASK_FIFO_VALID) != 0) { + uint32_t* lastHeader = NULL; /* used by FIFO_MODE_REG_READ_MEM Mode */ + uint32_t memLen = 0; /* used by FIFO_MODE_REG_READ_MEM + and FIFO_MODE_IPU_DATA Mode */ fifoDebugCtr++; if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) == FIFO_TYPE_IS_HEADER) { @@ -553,8 +556,8 @@ static int trb_fifo_read(uint8_t channel, } if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != - (counter - 1) % 2) { - /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER and exit */ + (counter - 1) % 2) { + /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER, exit */ fifo_flush(channel); trb_errno = TRB_FIFO_SEQUENZ; return -1; @@ -735,9 +738,6 @@ static int trb_fifo_read(uint8_t channel, case FIFO_MODE_REG_READ_MEM: { - static uint32_t* lastHeader = NULL; - static uint32_t memLen = 0; - switch (headerType) { case HEADER_HDR: if (dataCtr < dsize) { @@ -773,6 +773,7 @@ static int trb_fifo_read(uint8_t channel, case HEADER_TRM: if (lastHeader != NULL) { *lastHeader |= (memLen << 16); + lastHeader = NULL; } break; @@ -787,9 +788,6 @@ static int trb_fifo_read(uint8_t channel, case FIFO_MODE_REGTIME_READ_MEM: { - static uint32_t* lastHeader = NULL; - static uint32_t memLen = 0; - switch (headerType) { case HEADER_HDR: if (dataCtr < dsize) { @@ -826,6 +824,7 @@ static int trb_fifo_read(uint8_t channel, case HEADER_TRM: if (lastHeader != NULL) { *lastHeader |= (memLen << 16); + lastHeader = NULL; } break; @@ -843,13 +842,12 @@ static int trb_fifo_read(uint8_t channel, case FIFO_MODE_IPU_DATA: { - static unsigned int len = 0; unsigned int i; switch (headerType) { case HEADER_TRM: - if ((packageCtr > 0) && (dataCtr != len)) { + if ((packageCtr > 0) && (dataCtr != memLen)) { /* Error invalid length */ fifo_flush(channel); trb_errno = TRB_HDR_DLEN; @@ -863,11 +861,11 @@ static int trb_fifo_read(uint8_t channel, trb_errno = TRB_FIFO_INVALID_HEADER; return -1; } - len = (unsigned int)package.F2; + memLen = (unsigned int)package.F2; break; case HEADER_DAT: - for (i = 0; (i < 2) && (dataCtr < len); i++) { + for (i = 0; (i < 2) && (dataCtr < memLen); i++) { if (dataCtr < dsize) { data[dataCtr++] = (i == 0) ? (((uint32_t)package.F0 << 16) | @@ -1920,7 +1918,7 @@ int network_reset() usleep(1000); write32_to_FPGA(0x10, 0x8000); - sleep(10); + sleep(8); com_reset();