OSDN Git Service

AF動作指示で応答を確認するよう変更する。ログ出力を調整する。
authorMRSa <mrsa@myad.jp>
Sat, 15 Feb 2020 16:28:59 +0000 (01:28 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 15 Feb 2020 16:28:59 +0000 (01:28 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java

index 1e57a4f..77a9279 100644 (file)
@@ -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");
index 23f4b9c..e1672bb 100644 (file)
@@ -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)
         {