From 4e212b3df3c250fe9af644e8f99094b372b3d1a8 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 19 Dec 2022 13:55:03 +0100 Subject: if we fail to spot a direction, use single stepping instead. https://github.com/gphoto/libgphoto2/issues/694 --- camlibs/ptp2/config.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 42b3dc0b9..693ca2915 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -5281,11 +5281,24 @@ _put_Sony_ShutterSpeed(CONFIG_PUT_ARGS) { break; } - // Calculating jump width - if (direction > 0) - value.u8 = 0x00 + position_new - position_current; - else - value.u8 = 0x100 + position_new - position_current; + /* If something failed, fall back to single step, https://github.com/gphoto/libgphoto2/issues/694 */ + if (position_current == position_new) { + GP_LOG_D ("posNew and pos_current both %d, fall back to single step", position_current); + if (old > new) { + value.u8 = 0x01; + direction = 1; + } + else { + value.u8 = 0xff; + direction = -1; + } + } else { + // Calculating jump width + if (direction > 0) + value.u8 = 0x00 + position_new - position_current; + else + value.u8 = 0x100 + position_new - position_current; + } a = dpd->CurrentValue.u32>>16; b = dpd->CurrentValue.u32&0xffff; -- cgit v1.2.1