From 7ef7a6717b786b75b1ca93e0fb0f39aec34c9254 Mon Sep 17 00:00:00 2001 From: axxel Date: Tue, 17 Sep 2024 12:15:02 +0200 Subject: [PATCH] ptp2: condense EOS OLCInfo related debug output A full logging excerpt now looks like this ``` event 237: EOS event OLCInfoChanged (size 81, version 0x0b, mask 0x1fff) 0x00: 49 00 00 00 ff 1f 00 00 01 00 01 01 a0 10 00 a0 0x10: 01 01 50 20 2c 01 01 00 00 04 01 01 71 00 00 00 0x20: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x40: 00 00 00 00 00 00 00 00 00 event 237: olcmask 0x0001, 2 bytes: 01 00 event 238: olcmask 0x0002, 6 bytes: 01 01 a0 10 00 a0 event 239: olcmask 0x0004, 5 bytes: 01 01 50 20 2c event 240: olcmask 0x0008, 4 bytes: 01 01 00 00 event 241: olcmask 0x0010, 4 bytes: 04 01 01 71 event 242: olcmask 0x0020, 6 bytes: 00 00 00 00 00 00 event 243: olcmask 0x0040, 8 bytes: 01 00 00 00 00 00 00 00 event 244: olcmask 0x0080, 4 bytes: 00 00 00 00 event 245: olcmask 0x0100, 6 bytes: 00 00 00 00 00 00 event 246: olcmask 0x0200, 5 bytes: 00 00 00 00 00 event 247: olcmask 0x0400, 5 bytes: 00 00 00 00 00 event 248: olcmask 0x0800, 9 bytes: 00 00 00 00 00 00 00 00 00 event 249: mask 0x1000 entry truncated (1 bytes), olcsizes table (8 bytes) wrong? event 249: olcmask 0x1000, 1 bytes: 00 ``` This allows for easy grepping of the log file. See comments for gained insight into olcmask 0x0010 entries. The user visible strings info strings of the UNKNOWN events have changed as well, e.g.: ``` UNKNOWN OLCInfo event 0x0010, 4 bytes: 04 02 06 2f ``` It also introduces a convenient ptp_bytes2str() function to render some bytes into a string for immediate printing/copying. --- camlibs/ptp2/ptp-pack.c | 193 ++++++++++++---------------------------- camlibs/ptp2/ptp.c | 14 +++ camlibs/ptp2/ptp.h | 1 + 3 files changed, 73 insertions(+), 135 deletions(-) diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index 305180c90..3aa874f24 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -34,6 +34,13 @@ #include #endif +#ifndef MAX +# define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + static inline uint16_t htod16p (PTPParams *params, uint16_t var) { @@ -2628,12 +2635,11 @@ static unsigned int olcsizes[0x15][13] = { olcver = sizeof(olcsizes)/sizeof(olcsizes[0])-1; } - ptp_debug (params, "event %d: OLC version is 0x%02x", i, olcver); - ptp_debug (params, "event %d: EOS event OLCInfoChanged (size %d)", i, size); + mask = size >= 14 ? dtoh16a(curdata+8+4) : 0; + ptp_debug (params, "event %d: EOS event OLCInfoChanged (size %d, version 0x%02x, mask 0x%04x)", i, size, olcver, mask); if (size >= 0x8) { /* event info */ - unsigned int k; - for (k=8;k size) break; if (!(mask & curmask)) continue; - if (curoff+olcsizes[olcver][j] > size) { - ptp_debug (params, "event %d: mask 0x%x size of olc entry %d exceeds total size %d", i, mask, curoff+olcsizes[olcver][j], size); - break; - } - ptp_debug (params, "event %d: olcmask 0x%04x", i, curmask); - for (k=0;k