From 9c077ac5a15d1617056478b502ca19528a74f0d8 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 13 Aug 2009 13:43:16 +0000 Subject: [PATCH] bugfix . --- libtrbnet/trbnet.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index 366ee30..b39fc30 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -382,6 +382,7 @@ static int trb_fifo_read(uint8_t channel, unsigned int counter = 0; unsigned int dataCtr = 0; int packageCtr = -1; + int fifoDebugCtr = -1; unsigned int endPointCtr = 0; unsigned int timeout = 0; @@ -417,14 +418,12 @@ static int trb_fifo_read(uint8_t channel, /* Read FIFO-Buffer, copy to User-Buffer */ while ((*tmp & MASK_FIFO_VALID) != 0) { - - /* DEBUG INFO */ - if (trb_debug > 1) { - fprintf(stderr, "FIFO_%03d: 0x%08x\n", - packageCtr * 5 + counter, *tmp); - } + fifoDebugCtr++; if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) == FIFO_TYPE_IS_HEADER) { + /* TRBNet HEADER */ + + if ((counter % 5) == 0) { /* New Package begins */ if (trb_debug > 0) { @@ -433,16 +432,36 @@ static int trb_fifo_read(uint8_t channel, } packageCtr++; counter = 0; + + /* DEBUG INFO */ + if (trb_debug > 1) { + fprintf(stderr, "FIFO_%03d: 0x%08x\n", + fifoDebugCtr, *tmp); + } } else { /* Error: invalid buffer content, flush FIFO-BUFFER and exit */ + + /* DEBUG INFO */ + if (trb_debug > 1) { + fprintf(stderr, "FIFO_%03d: 0x%08x\n", + fifoDebugCtr, *tmp); + } + fifo_flush(channel); trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE; return -1; } } else { - /* Data Word */ + /* TRBNet Data Word */ + + /* DEBUG INFO */ + if (trb_debug > 1) { + fprintf(stderr, "FIFO_%03d: 0x%08x\n", + fifoDebugCtr, *tmp); + } + if ((trb_lazy == 0) && - (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != + (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != (counter - 1) % 2)) { /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER and exit */ fifo_flush(channel); -- 2.43.0