From: Philipp Klaus Date: Mon, 29 May 2017 08:15:31 +0000 (+0200) Subject: C unpacker: upgraded extract_info X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=b6168ce89f973f442caa4aa4b8a820d8da15701c;p=mvd_soft.git C unpacker: upgraded extract_info --- diff --git a/normalmode/c_standalone/extract_info.c b/normalmode/c_standalone/extract_info.c index e7ff482..dc1aabe 100644 --- a/normalmode/c_standalone/extract_info.c +++ b/normalmode/c_standalone/extract_info.c @@ -17,33 +17,40 @@ uint32_t num_events = 0; int read_frame(unsigned long *pos, FILE *ptr_file) { uint16_t frame_length, sensor_id; - uint32_t frame_start, frame_counter; + uint32_t frame_start, frame_counter, trailer; uint16_t senlen; + uint8_t header_found, trailer_found; fread(&frame_length, sizeof(uint16_t), 1, ptr_file); frame_length = ntohs(frame_length); fread(&sensor_id, sizeof(uint16_t), 1, ptr_file); sensor_id = ntohs(sensor_id); fseek(ptr_file, 12, SEEK_CUR); fread(&frame_start, sizeof(uint32_t), 1, ptr_file); - if (frame_start != 0x55555555) - { - print1("Bad header!\n"); - return 1; - } + if (frame_start == 0x55555555) + header_found = 1; + else + header_found = 0; fread(&frame_counter, sizeof(uint32_t), 1, ptr_file); - frame_counter = ntohs(frame_counter); + frame_counter = ntohl(frame_counter); fread(&senlen, sizeof(uint16_t), 1, ptr_file); senlen = ntohs(senlen); + fseek(ptr_file, 2+senlen*4, SEEK_CUR); + fread(&trailer, sizeof(uint32_t), 1, ptr_file); + trailer = ntohl(trailer); + if (trailer == 0x80018001) + trailer_found = 1; + else + trailer_found = 0; // from global state: uint32_t seqnr = event_header[3]; uint32_t trignr = subevent_header[3]; uint16_t roc = ntohs(subsubevent_header[1]); trignr = ntohl(trignr); // output - //print1("seqnr: 0x%08X trignr: 0x%08X mkd_timestamp: 0x%08X frame_length: 0x%04X sensor_id: 0x%02X sensor_frame_cnt: 0x%08X senlen: 0x%04X\n", - // seqnr, trignr, marker_timestamp, frame_length, sensor_id, frame_counter, senlen); - print1("%"PRIu32" %"PRIu32" %"PRIu16" %"PRIu32" %"PRIu16" %"PRIu16" %"PRIu32" %"PRIu16"\n", - seqnr, trignr, roc, marker_timestamp, frame_length, sensor_id, frame_counter, senlen); + print2("seqnr: 0x%08X trignr: 0x%08X roc: 0x%04X mkd_timestamp: 0x%08X frame_length: 0x%04X sensor_id: 0x%02X sensor_frame_cnt: 0x%08X senlen: 0x%04X cntr: 0x%08X mkd: %d header_found: %d trailer_found: %d\n", + seqnr, trignr, roc, marker_timestamp, frame_length, sensor_id, frame_counter, senlen, frame_timestamp, frame_marked, header_found, trailer_found); + print1("%"PRIu32" %"PRIu32" %"PRIu16" %"PRIu32" %"PRIu16" %"PRIu16" %"PRIu32" %"PRIu16" %"PRIu32" %"PRIu8" %"PRIu8" %"PRIu8"\n", + seqnr, trignr, roc, marker_timestamp, frame_length, sensor_id, frame_counter, senlen, frame_timestamp, frame_marked, header_found, trailer_found); return 0; } @@ -65,7 +72,7 @@ int main(int argc, char **argv) return 1; } - print1("seqnr trignr roc mkd_timestamp frame_length sensor_id sensor_frame_cnt senlen\n"); + print1("seqnr trignr roc mkd_timestamp frame_length sensor_id sensor_frame_cnt senlen cntr mkd header_found trailer_found\n"); pos = 0; while (read_event(&pos, ptr_myfile, &read_frame) == 0) { diff --git a/normalmode/c_standalone/extract_info.h b/normalmode/c_standalone/extract_info.h index 85084be..27931c1 100644 --- a/normalmode/c_standalone/extract_info.h +++ b/normalmode/c_standalone/extract_info.h @@ -12,3 +12,4 @@ uint32_t extern event_header[EVENT_HEADERSIZE]; uint32_t extern subevent_header[SUBEVENT_HEADERSIZE]; uint16_t extern subsubevent_header[SUBSUBEVENT_HEADERSIZE*2]; uint32_t extern marker_timestamp, frame_timestamp; +uint8_t extern frame_marked; diff --git a/normalmode/c_standalone/hld.c b/normalmode/c_standalone/hld.c index 56386f9..eceb513 100644 --- a/normalmode/c_standalone/hld.c +++ b/normalmode/c_standalone/hld.c @@ -8,6 +8,7 @@ uint32_t event_header[EVENT_HEADERSIZE]; uint32_t subevent_header[SUBEVENT_HEADERSIZE]; uint16_t subsubevent_header[SUBSUBEVENT_HEADERSIZE*2]; uint32_t marker_timestamp, frame_timestamp; +uint8_t frame_marked; int read_event(unsigned long *pos, FILE *ptr_file, int (*sensor_callback)(unsigned long *pos, FILE *ptr_file)) { @@ -54,20 +55,22 @@ int read_subsubevent(unsigned long *pos, FILE *ptr_file, int (*sensor_callback)( header_version = roc_header[0]; data_version = roc_header[1]; header_size = roc_header[3]; - BOOL frame_marked = FALSE; + frame_marked = 0; marker_timestamp = 0; frame_timestamp = 0; if (header_size >= 1) { if (!fread(&marker_timestamp, 4, 1, ptr_file)) return 1; marker_timestamp = ntohl(marker_timestamp); - frame_marked = marker_timestamp & 0x80000000; + frame_marked = (marker_timestamp & 0x80000000) >> 31; marker_timestamp &= 0x00FFFFFF; } if (header_size >= 2) { if (!fread(&frame_timestamp, 4, 1, ptr_file)) return 1; frame_timestamp = ntohl(frame_timestamp); + //frame_marked = frame_timestamp & 0x80000000; + frame_timestamp &= 0x00FFFFFF; } if (header_size >= 3) {