Skip to content

Commit

Permalink
ptp2: print human readable EOS event names in log
Browse files Browse the repository at this point in the history
new function ptp_get_eos_event_name()
  • Loading branch information
axxel authored and msmeissn committed Oct 2, 2024
1 parent 4fd7b94 commit 95c6514
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -4470,7 +4470,7 @@ camera_canon_eos_capture (Camera *camera, CameraCaptureType type, CameraFilePath
while (ptp_get_one_eos_event (params, &event)) {
/* if we got at least one event from the last event polling, we reset our back_off_wait counter */
back_off_wait = 0;
GP_LOG_D ("event type %04x", event.type);
GP_LOG_D ("processing event '%s'", ptp_get_eos_event_name(params, event.type));
switch (event.type) {
case PTP_EOSEvent_Unknown:
GP_LOG_D ("event unknown: %s", event.u.info);
Expand Down Expand Up @@ -6054,8 +6054,8 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)

C_PTP_REP_MSG (ptp_check_eos_events (params), _("Canon EOS Get Changes failed"));
while (ptp_get_one_eos_event (params, &event)) {
GP_LOG_D ("while focussing, processing event '%s'", ptp_get_eos_event_name(params, event.type));
foundevents = 1;
GP_LOG_D("focusing - read event type %d", event.type);
if (event.type == PTP_EOSEvent_FocusInfo) {
GP_LOG_D("focusinfo content: %s", event.u.info);
foundfocusinfo = 1;
Expand Down Expand Up @@ -6118,7 +6118,7 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)
do {
ptp_check_eos_events (params);
while (ptp_get_one_eos_event (params, &event)) {
GP_LOG_D ("event type %04x", event.type);
GP_LOG_D ("processing event '%s'", ptp_get_eos_event_name(params, event.type));
if (event.type == PTP_EOSEvent_Unknown && sscanf (event.u.info, "Button %d", &button) == 1) {
GP_LOG_D ("Button %d", button);
switch (button) {
Expand Down Expand Up @@ -6627,8 +6627,8 @@ camera_wait_for_event (Camera *camera, int timeout,
C_PTP_REP_MSG (ptp_check_eos_events (params), _("Canon EOS Get Changes failed"));

while (ptp_get_one_eos_event (params, &event)) {
GP_LOG_D ("processing event '%s'", ptp_get_eos_event_name(params, event.type));
back_off_wait = 0;
GP_LOG_D ("event type %04x", event.type);
switch (event.type) {
case PTP_EOSEvent_ObjectTransfer:
GP_LOG_D ("Found new object! OID 0x%x, name %s", (unsigned int)event.u.object.oid, event.u.object.oi.Filename);
Expand Down
20 changes: 20 additions & 0 deletions camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9232,6 +9232,26 @@ ptp_get_event_code_name(PTPParams* params, uint16_t event_code)
return "Unknown Event";
}

const char*
ptp_get_eos_event_name(PTPParams *params, enum _PTPCanonEOSEventType type)
{
switch (type)
{
case PTP_EOSEvent_Unknown: return "Unknown";
case PTP_EOSEvent_PropertyChanged: return "PropertyChanged";
case PTP_EOSEvent_CameraStatus: return "CameraStatus";
case PTP_EOSEvent_FocusInfo: return "FocusInfo";
case PTP_EOSEvent_FocusMask: return "FocusMask";
case PTP_EOSEvent_ObjectTransfer: return "ObjectTransfer";
case PTP_EOSEvent_ObjectAdded: return "ObjectAdded";
case PTP_EOSEvent_ObjectRemoved: return "ObjectRemoved";
case PTP_EOSEvent_ObjectInfoChanged: return "ObjectInfoChanged";
case PTP_EOSEvent_ObjectContentChanged: return "ObjectContentChanged";
default:
ptp_error (params, "Unknown PTPCanonEOSEventType: bug in libgphoto2");
return "InvalidEOSEventType";
}
}

struct {
uint16_t id;
Expand Down
1 change: 1 addition & 0 deletions camlibs/ptp2/ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4894,6 +4894,7 @@ const char* ptp_get_property_description(PTPParams* params, uint32_t dpc);

const char* ptp_get_opcode_name(PTPParams* params, uint16_t opcode);
const char* ptp_get_event_code_name(PTPParams* params, uint16_t event_code);
const char* ptp_get_eos_event_name(PTPParams *params, enum _PTPCanonEOSEventType type);

int
ptp_render_property_value(PTPParams* params, uint16_t dpc,
Expand Down

0 comments on commit 95c6514

Please sign in to comment.