Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log readability #1033

Merged
merged 3 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -5990,11 +5990,14 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)
else
CR( camera_canon_eos_update_capture_target(camera, context, -1));

/* Get the initial bulk set of event data, otherwise
* capture might return busy. */
/* Get all pending event data from the camera, otherwise capture might return busy. */
ptp_check_eos_events (params);
while (ptp_get_one_eos_event (params, &entry))
GP_LOG_D("discarding event type %d", entry.type);

/* Discard all collected events before starting the next capture. */
GP_LOG_D("discarding %d EOS events", params->nrofbacklogentries);
free (params->backlogentries);
params->backlogentries = NULL;
params->nrofbacklogentries = 0;

if (params->eos_camerastatus == 1)
return GP_ERROR_CAMERA_BUSY;
Expand Down
30 changes: 10 additions & 20 deletions camlibs/ptp2/ptp-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,32 +2263,21 @@ static unsigned int olcsizes[0x15][13] = {
{0,0,0,0,0, 0,0,0,0,0, 0,0,0 }, /* 0x4 */
{0,0,0,0,0, 0,0,0,0,0, 0,0,0 }, /* 0x5 */
{0,0,0,0,0, 0,0,0,0,0, 0,0,0 }, /* 0x6 */
{2,6,5,4,4, 6,7,4,6,5, 5,8,1 }, /* 0x7 */ /* CONFIRMED: EOS 100D, 5D Mark 3 */
{2,6,5,4,4, 6,7,4,6,7, 7,8,1 }, /* 0x8 */ /* CONFIRMED: EOS M10, PowerShot SX720HS: only report 0x1, 0x2, 0x4 and 0x8 masks, separately */
{2,6,5,4,4, 6,7,4,6,5, 5,8,1 }, /* 0x7 */ /* CONFIRMED: 100D, 5Dm3, 650D, 6D */
{2,6,5,4,4, 6,7,4,6,7, 7,8,1 }, /* 0x8 */ /* CONFIRMED: 70D, M10, PowerShot SX720HS: only report 0x1, 0x2, 0x4 and 0x8 masks, separately */
{2,6,5,4,4, 6,7,4,6,7, 7,8,1 }, /* 0x9 */ /* guessed */
{2,6,5,4,4, 6,7,4,6,7, 7,8,1 }, /* 0xa */ /* guessed */
{2,6,5,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xb */ /* CONFIRMED: EOS 750D, 5Ds */
{2,6,5,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xb */ /* CONFIRMED: 750D, 5Ds */
{2,6,5,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xc */ /* guessed */
{2,6,5,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xd */ /* guessed */
{2,6,5,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xe */ /* guessed */
{2,7,6,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xf */ /* guessed */
{2,7,6,4,4, 6,8,4,6,5, 5,9,1 }, /* 0xf */ /* CONFIRMED: 200D */
{2,7,6,4,4, 6,8,4,6,5, 5,9,1 }, /* 0x10 */ /* guessed */
{2,7,6,6,4, 6,8,4,6,5, 5,9,8 }, /* 0x11 */ /* CONFIRMED: EOS R */
{2,7,9,6,4, 6,8,5,7,5, 5,9,8 }, /* 0x12 */ /* CONFIRMED: EOS M6 Mark II */
{2,7,9,7,4, 6,8,5,7,5, 5,9,8 }, /* 0x13 */ /* CONFIRMED: EOS R5 C info from user Ingmar */
{2,9,9,7,4, 6,8,5,7,5, 5,9,8 }, /* 0x14 */ /* CONFIRMED: EOS R8, R10. confirmed by trace from Marc Wetli */
{2,7,6,6,4, 6,8,4,6,5, 5,9,8 }, /* 0x11 */ /* CONFIRMED: R */
{2,7,9,6,4, 6,8,5,7,5, 5,9,8 }, /* 0x12 */ /* CONFIRMED: M6m2 */
{2,7,9,7,4, 6,8,5,7,5, 5,9,8 }, /* 0x13 */ /* CONFIRMED: R5, R5 C, M50m2 */
{2,9,9,7,4, 6,8,5,7,5, 5,9,8 }, /* 0x14 */ /* CONFIRMED: R8, R10, R5m2 */
};
/* one more information record handed to us */
/* Versions seen: (d199)
* 100D, 5d Mark 3, 650D, 6D: 7 (original reference)
* M10, 70D: 8
* 5Dsr, 750D: b
* 200D: f
* EOS R: 0x11
* EOS M6 Mark2 0x12
* EOS R5, R5 C, M50m2: 0x13
* EOS R10: 0x14
*/
/* still unclear what OLC stands for */
case PTP_EC_CANON_EOS_OLCInfoChanged: {
uint32_t len, curoff;
Expand Down Expand Up @@ -2433,7 +2422,8 @@ static unsigned int olcsizes[0x15][13] = {
0.942222 4 bytes: 04 02 06 2f
0.942969 4 bytes: 04 01 06 2f
This suggests that the very last bit indicates the readiness to process commands
and the second byte may be related to accessing storage.
and the second byte may be related to accessing storage. The latter might be true
the former does not hold true when repeating captures.
*/
case 0x0020:
/* mask 0x0020: 6 bytes, 00 00 00 00 00 00 observed.
Expand Down
16 changes: 13 additions & 3 deletions camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,26 @@ ptp_bytes2str(const uint8_t *data, int data_size, const char *fmt)
static char line[16 * 3 + 1];
int pos = 0;
for (int i = 0; i < data_size && pos < (int)sizeof(line); ++i) {
pos += snprintf(line + pos, sizeof(line) - pos, fmt, data[i]);
if (data[i] || fmt)
pos += snprintf(line + pos, sizeof(line) - pos, fmt ? fmt : "%02x ", data[i]);
else
pos += snprintf(line + pos, sizeof(line) - pos, " - ");
}
return line;
}

void
ptp_debug_data(PTPParams *params, const uint8_t* data, int size)
{
for (int k = 0; k < size; k += 16)
ptp_debug (params, " 0x%03x: %s", k, ptp_bytes2str(data + k, MIN(16, size - k), "%02x "));
uint8_t zeros[16] = { 0 };
int zero_lines = 0;
for (int k = 0; k < size; k += 16) {
zero_lines = (size - k > 16 && memcmp(data + k, zeros, 16) == 0) ? zero_lines + 1 : 0;
if (zero_lines < 2)
ptp_debug (params, " 0x%03x: %s", k, ptp_bytes2str(data + k, MIN(16, size - k), NULL));
else if (zero_lines == 2)
ptp_debug (params, " [...]: %s", ""); //ptp_bytes2str(zeros, 16, "%02x "));
}
}

/* Pack / unpack functions */
Expand Down
Loading