[subexp-daq] NURDLIB - Problem in parser of caen_v1n90

Weber, Guenter Dr. g.weber at hi-jena.gsi.de
Tue Apr 16 07:11:32 CEST 2024


Dear friends,


yesterday I managed to get the DAQ starting (using the updated software and howto instructions). However, the readout of the TDC module V1190A failed:


2024-04-15 14:29:36.979260 i  RIO4L-2/MAIN    crate_init(POLARIMETER) }
+0200 CEST :f_user.c:1257:
2024-04-15 14:29:36.979280 E  RIO4L-2/MAIN    had readout error, ret=0x2, trigger=1, prev=1
+0200 CEST :module/caen_v1n90/caen_v1n90.c:651:
2024-04-15 14:29:36.979684 E  RIO4L-2/MAIN    Trailer corrupt (ofs=0x00000010,u8[4]=0x0900032f).
+0200 CEST :crate/crate.c:2074:
2024-04-15 14:29:36.979712 E  RIO4L-2/MAIN    POLARIMETER[3]=CAEN_V1190 parse error=0x00000002, dumping data:
+0200 CEST :crate/crate.c:2083:
2024-04-15 14:29:36.979724 i  RIO4L-2/MAIN    ---[ Dump begin ]---
+0200 CEST :crate/crate.c:2083:
2024-04-15 14:29:36.979734 i  RIO4L-2/MAIN    Start=0x3005ef08  Bytes=44=0x2c
+0200 CEST :crate/crate.c:2083:
2024-04-15 14:29:36.979755 i  RIO4L-2/MAIN        0: 40000003 0800032f 00702106 18000003 0900032f 19000002 0a00032f 1a000002
+0200 CEST :crate/crate.c:2083:
2024-04-15 14:29:36.979770 i  RIO4L-2/MAIN       20: 0b00032f 1b000002 80000163
+0200 CEST :crate/crate.c:2083:
2024-04-15 14:29:36.979780 i  RIO4L-2/MAIN    ---[  Dump end  ]---
+0200 CEST :crate/crate.c:1554:
2024-04-15 14:29:36.979810 E  RIO4L-2/MAIN    POLARIMETER: readout failed!
+0200 CEST :crate/crate.c:1598:
2024-04-15 14:29:36.979823 E  RIO4L-2/MAIN    POLARIMETER: had problems, re-initializing.


To us it looks like the parser does not account for the fact that the module contains several individual TDC units which each will produce a TDC header plus payload. And only after all TDC units were readout, finally the trailer will appear.


(As I can see, the 1n90 series ranges from 16 channels to 128 channels with the high channel number modules having several individual TDC units. Maybe, this whole issue was overlooked when writing the parser code?)


In the attachment, I send a modified version of the parser where for testing purposes it is assumed that the module has four TDC units (as should be the case for our module). Compilation of this code works, but it fails in the unit test with the following errors:


make: Warning: File `build_cc_ppc-linux_4.2.2_debug/module/caen_v1n90/caen_v1n90.d' has modification time 45 s in the future
CC    build_cc_ppc-linux_4.2.2_debug/module/caen_v1n90/caen_v1n90.o
LD    build_cc_ppc-linux_4.2.2_debug/test
TEST  build_cc_ppc-linux_4.2.2_debug/test_ok
[tests/argmatch.c:127: Shorts]
[tests/argmatch.c:128: Longs]
[tests/argmatch.c:129: Combos]
[tests/argmatch.c:130: ShortsWithValues]
[tests/argmatch.c:131: LongsWithValues]
[tests/argmatch.c:132: MissingValue]
[tests/base.c:110: MemoryCheck]
[tests/base.c:111: EventBufferAdvance]
2024-04-15,20:11:37:ERRR: Invalid pointer to advance event buffer. [tests/base.c:47]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:47]
2024-04-15,20:11:37:ERRR: Invalid pointer to advance event buffer. [tests/base.c:56]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:56]
2024-04-15,20:11:37:ERRR: Tried to advance outside event buffer. [tests/base.c:72]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:72]
[tests/base.c:112: EventBufferInvariant]
2024-04-15,20:11:37:ERRR: Event-buffer inconsistent (0x103ae008:11 != 0x103ae008:10). [tests/base.c:87]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:87]
2024-04-15,20:11:37:ERRR: Event-buffer inconsistent (0x103ae008:9 != 0x103ae008:10). [tests/base.c:91]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:91]
2024-04-15,20:11:37:ERRR: Event-buffer inconsistent (0x103ae009:10 != 0x103ae008:10). [tests/base.c:95]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:95]
2024-04-15,20:11:37:ERRR: Event-buffer inconsistent (0x103ae007:10 != 0x103ae008:10). [tests/base.c:99]
2024-04-15,20:11:37:ERRR: Calling abort()... [tests/base.c:99]


For comparison, I also send the parser from the NURDLIB version that Bastian had set up for us.



It would be really great if you could have a look into this. Most probably this is the last issue that we are facing, before the DAQ is fine again.




Thank you very much!



Best greetings

Günter





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.chalmers.se/pipermail/subexp-daq/attachments/20240416/8f120509/attachment-0001.html>
-------------- next part --------------
uint32_t
caen_v1n90_parse_data(struct CaenV1n90Module const *a_v1n90, struct
    EventConstBuffer const *a_event_buffer, int a_do_pedestals)
{
	uint32_t const *p;
	uint32_t const *end;
	uint32_t result;
	unsigned event_no;

	(void)a_v1n90;
	(void)a_do_pedestals;

	LOGF(spam)(LOGL, NAME" parse_data {");

	result = 0;
	if (0 != a_event_buffer->bytes % sizeof(uint32_t)) {
		log_error(LOGL, "Event buffer size not 32-bit aligned.");
		result = CRATE_READOUT_FAIL_DATA_CORRUPT;
		goto caen_v1n90_parse_data_done;
	}
	/* TODO: This parser is horrible. */
	p = a_event_buffer->ptr;
	end = p + a_event_buffer->bytes / sizeof(uint32_t);
	while (end > p && DMA_FILLER == *p) {
		++p;
	}
	for (event_no = 0;; ++event_no) {
		uint32_t const *event_start;
		unsigned count;

		if (end == p) {
			break;
		}
		event_start = p;
		if (0x40000000 != (TYPE_MASK & *p)) {
			module_parse_error(LOGL, event_no, a_event_buffer, p,
			    "Global header corrupt");
			result = CRATE_READOUT_FAIL_DATA_CORRUPT;
			goto caen_v1n90_parse_data_done;
		}
		++p;
		for (;;) {
			uint32_t top;

			if (end <= p) {
				log_error(LOGL, "Unexpected end of data.");
				result = CRATE_READOUT_FAIL_DATA_MISSING;
				goto caen_v1n90_parse_data_done;
			}
			top = TYPE_MASK & *p;
			if (0x08000000 == top) {
				/*module_parse_error(LOGL, event_no,
				    a_event_buffer, p,
				    "TDC headers should be disabled");
				result = CRATE_READOUT_FAIL_DATA_CORRUPT;
				goto caen_v1n90_parse_data_done;*/
			} else if (0x00000000 == top) {
				/* Data. */
			} else if (0x18000000 == top) {
				/*module_parse_error(LOGL, event_no,
				    a_event_buffer, p,
				    "TDC footers should be disabled");
				result = CRATE_READOUT_FAIL_DATA_CORRUPT;
				goto caen_v1n90_parse_data_done;*/
			} else if (0x20000000 == top) {
				/* TODO: Is this really enough? No. */
				LOGF(info)(LOGL, NAME" TDC error 0x%8x.", *p);
			} else if (0x40000000 == top) {
				/* TODO: Is this really enough? No. */
				LOGF(info)(LOGL,
				    NAME" Header again ?? 0x%8x 0x%8x.", *p,
				    *(p-1));
			}
			else if (0x88000000 == top) {
				/* Extended trigger time tag. */
			} else if (0x80000000 == top) {
				break;
			} else {
				module_parse_error(LOGL, event_no,
				    a_event_buffer, p,
				    "TDC data corrupt");
				result = CRATE_READOUT_FAIL_DATA_CORRUPT;
				goto caen_v1n90_parse_data_done;
			}
			++p;
		}
		count = (0x001fffe0 & *p) >> 5;
		++p;
		if ((unsigned)(p - event_start) != count) {
			log_error(LOGL, "EOB count=%d != actual count=%d.",
			    (int)(p - event_start), count);
			result = CRATE_READOUT_FAIL_DATA_CORRUPT;
			goto caen_v1n90_parse_data_done;
		}
	}

caen_v1n90_parse_data_done:
	LOGF(spam)(LOGL, NAME" parse_data(0x%08x) }", result);
	return result;
}
-------------- next part --------------
uint32_t
caen_v1n90_parse_data(struct CaenV1n90Module *a_v1n90, struct EventConstBuffer
    const *a_event_buffer, int a_do_pedestals)
{
    uint32_t const *p32;
    uint32_t const *end;
    uint32_t result;
    uint32_t tdc_num;
 
    (void)a_do_pedestals;
 
    LOGF(spam)(LOGL, NAME" parse_data {");
 
    result = 0;
    if (0 != a_event_buffer->bytes % sizeof(uint32_t)) {
        log_error(LOGL, "Event buffer size not 32-bit aligned.");
        result = CRATE_READOUT_FAIL_DATA_CORRUPT;
        goto caen_v1n90_parse_data_done;
    }
    p32 = a_event_buffer->ptr;
    end = p32 + a_event_buffer->bytes / sizeof(uint32_t);
    tdc_num = 0;
    for (; p32 < end; ++p32) {
        uint32_t u32;
 
        u32 = *p32;
        switch (a_v1n90->parse.expect) {
        case EXPECT_DMA_HEADER:
            if (DMA_FILLER == u32) {
            } else if (0x40000000 == (TYPE_MASK & u32)) {
                uint32_t count;
 
                count = (u32 & BITS_MASK(5, 26)) >> 5;
                (void)count;
                /* TODO: Check this counter + GEO? */
                /* TODO: If disabled, go to payload. */
                a_v1n90->parse.expect = EXPECT_TDC_HEADER;
                tdc_num++;
            } else {
                module_parse_error(LOGL, a_event_buffer, p32,
                    "Global header corrupt");
                result = CRATE_READOUT_FAIL_DATA_CORRUPT;
                goto caen_v1n90_parse_data_done;
            }
            break;
        case EXPECT_TDC_HEADER:
            if (0x08000000 == (TYPE_MASK & u32)) {
                /* TODO: Check Event-ID and Bunch-ID? */
                a_v1n90->parse.expect = EXPECT_TDC_PAYLOAD;
            } else {
                module_parse_error(LOGL, a_event_buffer, p32,
                    "TDC header corrupt");
                result = CRATE_READOUT_FAIL_DATA_CORRUPT;
                goto caen_v1n90_parse_data_done;
            }
            break;
        case EXPECT_TDC_PAYLOAD:
            if (0x00000000 == (TYPE_MASK & u32)) {
            } else if (0x20000000 == (TYPE_MASK & u32)) {
                /* TODO: This is optional. */
                LOGF(info)(LOGL, NAME" TDC [%1x] reports error 0x%4x.", ((u32 >> 24) & 0x3), (u32 & 0x3FF));
            } else if (0x18000000 == (TYPE_MASK & u32)) {
                /* TODO: Check event-ID and word-count! */
                if ( tdc_num == 4 )
                    a_v1n90->parse.expect = EXPECT_TIMETAG_TRAILER;
                else
                    a_v1n90->parse.expect = EXPECT_TDC_HEADER;
            } else {
                module_parse_error(LOGL, a_event_buffer, p32,
                    "TDC payload corrupt");
                result = CRATE_READOUT_FAIL_DATA_CORRUPT;
                goto caen_v1n90_parse_data_done;
            }
            break;
        case EXPECT_TIMETAG_TRAILER:
            if (0x88000000 == (TYPE_MASK & u32)) {
            } else if (0x80000000 == (TYPE_MASK & u32)) {
                /* TODO: Check word-count and geo! */
                a_v1n90->parse.expect = EXPECT_DMA_HEADER;
            } else {
                module_parse_error(LOGL, a_event_buffer, p32,
                    "Trailer corrupt");
                result = CRATE_READOUT_FAIL_DATA_CORRUPT;
                goto caen_v1n90_parse_data_done;
            }
            break;
        }
    }

caen_v1n90_parse_data_done:
	LOGF(spam)(LOGL, NAME" parse_data(0x%08x) }", result);
	return result;
}


More information about the subexp-daq mailing list