From 2eb5dec7d293c16ef3919e55a7ce316af39a1499 Mon Sep 17 00:00:00 2001 From: MRSa Date: Sun, 16 Feb 2020 01:28:59 +0900 Subject: [PATCH] =?utf8?q?AF=E5=8B=95=E4=BD=9C=E6=8C=87=E7=A4=BA=E3=81=A7?= =?utf8?q?=E5=BF=9C=E7=AD=94=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B?= =?utf8?q?=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4=E3=81=99=E3=82=8B=E3=80=82?= =?utf8?q?=E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B=E3=82=92=E8=AA=BF=E6=95=B4?= =?utf8?q?=E3=81=99=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../canon/operation/CanonFocusingControl.java | 23 ++++++++++++++-------- .../wrapper/command/PtpIpCommandPublisher.java | 16 ++++++++++----- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java index 1e57a4f..77a9279 100644 --- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java +++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java @@ -11,8 +11,6 @@ import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; import net.osdn.gokigen.a01d.camera.IFocusingControl; -import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.messages.FocusLock; -import net.osdn.gokigen.a01d.camera.fujix.wrapper.command.messages.FocusUnlock; import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback; import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher; import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric; @@ -20,8 +18,6 @@ import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay; import net.osdn.gokigen.a01d.liveview.IIndicatorControl; import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor; -import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_GET_VIEWFRAME; - public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCallback { private final String TAG = this.toString(); @@ -39,6 +35,7 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall private float maxPointLimitWidth; private float maxPointLimitHeight; private RectF preFocusFrameRect = null; + private boolean isDumpLog = false; public CanonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator) { @@ -119,7 +116,7 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall try { Log.v(TAG, " Unlock AF "); - commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_UNLOCK, false, 0, 0x9160)); + commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_UNLOCK, isDumpLog, 0, 0x9160)); } catch (Exception e) { @@ -141,9 +138,9 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall int x = (0x0000ffff & (Math.round(point.x * maxPointLimitWidth) + 1)); int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1)); Log.v(TAG, "Lock AF: [" + x + ","+ y + "]"); - commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK_PRE, false, 0, 0x9160)); - commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, 25, false, 0, 0x915b, 16, 0x03, x, y, 0x01)); - commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, false, 0, 0x9154)); + commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK_PRE, isDumpLog, 0, 0x9160)); + commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, 25, isDumpLog, 0, 0x915b, 16, 0x03, x, y, 0x01)); + commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x9154)); } catch (Exception e) { @@ -201,6 +198,16 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall { try { + + + if ((rx_body.length > 10)&&((rx_body[8] != (byte) 0x01)||(rx_body[9] != (byte) 0x20))) + { + Log.v(TAG, " --- RECEIVED NG REPLY. : FOCUS OPERATION ---"); + hideFocusFrame(); + preFocusFrameRect = null; + return; + } + if ((id == FOCUS_LOCK)||(id == FOCUS_LOCK_PRE)) { Log.v(TAG, "FOCUS LOCKED"); diff --git a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java index 23f4b9c..e1672bb 100644 --- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java +++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java @@ -472,6 +472,14 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm int target_length = parseDataLength(byte_array, read_bytes); int received_length = read_bytes; + if (target_length <= 0) + { + // 受信サイズ異常の場合... + Log.v(TAG, " WRONG LENGTH. : " + target_length); + callback.receivedMessage(id, null); + return (false); + } + // 一時的な処理 if (callback != null) { @@ -530,12 +538,10 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm Log.v(TAG, " --- receive_multi : " + id + " (" + read_bytes + ") [" + maxRetryCount + "] " + receive_message_buffer_size + " (" + received_length + ") "); callback.receivedMessage(id, null); } - System.gc(); } catch (Throwable e) { e.printStackTrace(); - System.gc(); } return (false); } @@ -543,15 +549,15 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm private int parseDataLength(byte[] byte_array, int read_bytes) { int lenlen = 0; - int packetType = 0; + //int packetType = 0; try { if ((read_bytes > 20)&&((int) byte_array[4] == 0x09)) { lenlen = ((((int) byte_array[15]) & 0xff) << 24) + ((((int) byte_array[14]) & 0xff) << 16) + ((((int) byte_array[13]) & 0xff) << 8) + (((int) byte_array[12]) & 0xff); - packetType = (((int)byte_array[16]) & 0xff); + //packetType = (((int)byte_array[16]) & 0xff); } - Log.v(TAG, " --- parseDataLength() length: " + lenlen + " TYPE: " + packetType + " read_bytes: " + read_bytes); + //Log.v(TAG, " --- parseDataLength() length: " + lenlen + " TYPE: " + packetType + " read_bytes: " + read_bytes); } catch (Exception e) { -- 2.11.0