trace list: show a negative frame delay time instead of wrapping it

The -r and --frame delay was an unsigned difference, so a frame starting
before the end of the previous one, or after the timer restarted, eg
between the sessions of traces/hf_14b_xerox_info.trace or the frames of
traces/lf_HitagS256_dump.trace, showed as about 4294967296 instead of
-83024 or -117.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 14:59:13 +07:00
1 parent fcd66c39e8
commit d11643c8f2
1 file changed
+8 -6
+8 -6
View File
@@ -1141,7 +1141,8 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
// wait-cycle annotation already puts it, between the frames it separates.
if (prev_eot && (previous_end_of_transmission_timestamp != hdr->timestamp)) {
uint32_t fdt = hdr->timestamp - previous_end_of_transmission_timestamp;
// signed, a frame can start before the previous one ended or the timer restarted
int64_t fdt = (int64_t)hdr->timestamp - previous_end_of_transmission_timestamp;
// Carry the column rules through, so the row does not break the table.
//
@@ -1154,8 +1155,8 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
visible = snprintf(NULL, 0, " Frame Delay Time %.1f", (float)fdt / 13.56);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%.1f"), (float)fdt / 13.56);
} else {
visible = snprintf(NULL, 0, " Frame Delay Time %u", fdt);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%u"), fdt);
visible = snprintf(NULL, 0, " Frame Delay Time %" PRId64, fdt);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%" PRId64), fdt);
}
int fdt_pad = str_padder + (int)strlen(fdt_txt) - visible;
@@ -1368,15 +1369,16 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
// Same column rules as a data row, so the table is not broken. The pad
// is corrected for the colour escapes, which %-*s counts but the terminal
// does not draw.
uint32_t fdt = next_hdr->timestamp - end_of_transmission_timestamp;
// signed, a frame can start before the previous one ended or the timer restarted
int64_t fdt = (int64_t)next_hdr->timestamp - end_of_transmission_timestamp;
char fdt_txt[160] = {0};
int visible;
if (use_us) {
visible = snprintf(NULL, 0, " Frame Delay Time %.1f", (float)fdt / 13.56);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%.1f"), (float)fdt / 13.56);
} else {
visible = snprintf(NULL, 0, " Frame Delay Time %u", fdt);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%u"), fdt);
visible = snprintf(NULL, 0, " Frame Delay Time %" PRId64, fdt);
snprintf(fdt_txt, sizeof(fdt_txt), " Frame Delay Time " _CYAN_("%" PRId64), fdt);
}
int fdt_pad = 72 + (int)strlen(fdt_txt) - visible;