OSDN Git Service

接続シーケンス部分はこれで。
authorMRSa <mrsa@myad.jp>
Sun, 9 Feb 2020 02:09:22 +0000 (11:09 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 9 Feb 2020 02:09:22 +0000 (11:09 +0900)
app/src/main/java/net/osdn/gokigen/a01d/A01dMain.java
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/connection/CanonCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/connection/CanonConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/status/CanonStatusChecker.java [moved from app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/status/PtpIpStatusChecker.java with 96% similarity]
app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/status/CanonStatusHolder.java [moved from app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/status/PtpIpStatusHolder.java with 96% similarity]
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpCommand.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/messages/PtpIpCommandBase.java

index 7d01a82..c28f2fd 100644 (file)
@@ -3,10 +3,13 @@ package net.osdn.gokigen.a01d;
 import android.Manifest;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.graphics.Typeface;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.WindowManager;
+import android.widget.TextView;
 
 import net.osdn.gokigen.a01d.camera.CameraInterfaceProvider;
 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
@@ -715,7 +718,7 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
     public void updateMessage(final String message, final boolean isBold, final boolean isColor, final int color)
     {
         Log.v(TAG, " updateMessage() : " + message);
-/*
+/**/
         try {
             final TextView messageArea = findViewById(R.id.message);
             runOnUiThread(new Runnable() {
@@ -751,6 +754,6 @@ public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver
         {
             e.printStackTrace();
         }
-*/
+/**/
     }
 }
index 61341fe..6664494 100644 (file)
@@ -31,7 +31,7 @@ import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpAsyncResponseRece
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.IPtpIpRunModeHolder;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpRunMode;
-import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpStatusChecker;
+import net.osdn.gokigen.a01d.camera.canon.wrapper.status.CanonStatusChecker;
 import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
 import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
 import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
@@ -57,7 +57,7 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
     private CanonLiveViewControl liveViewControl;
     private PtpIpAsyncResponseReceiver asyncReceiver;
     private CanonZoomLensControl zoomControl;
-    private PtpIpStatusChecker statusChecker;
+    private CanonStatusChecker statusChecker;
     private ICameraStatusUpdateNotify statusListener;
     private IInformationReceiver informationReceiver;
 
@@ -67,7 +67,7 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
         commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT);
         liveViewControl = new CanonLiveViewControl(context, CAMERA_IP, STREAM_PORT);
         asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
-        statusChecker = new PtpIpStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
+        statusChecker = new CanonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
         canonConnection = new CanonConnection(context, provider, this, statusChecker);
         cameraInformation = new CanonCameraInformation();
         zoomControl = new CanonZoomLensControl();
index daa8e40..36d60c7 100644 (file)
@@ -17,7 +17,7 @@ import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
-import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpStatusChecker;
+import net.osdn.gokigen.a01d.camera.canon.wrapper.status.CanonStatusChecker;
 
 public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallback, IPtpIpMessages
 {
@@ -28,10 +28,10 @@ public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
     private final ICameraStatusReceiver cameraStatusReceiver;
     private final IPtpIpInterfaceProvider interfaceProvider;
     private final IPtpIpCommandPublisher commandIssuer;
-    private final PtpIpStatusChecker statusChecker;
+    private final CanonStatusChecker statusChecker;
     private boolean isDumpLog = true;
 
-    CanonCameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull PtpIpStatusChecker statusChecker)
+    CanonCameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull CanonStatusChecker statusChecker)
     {
         Log.v(TAG, " CanonCameraConnectSequence");
         this.context = context;
@@ -124,38 +124,45 @@ public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
                 break;
 
             case SEQ_OPEN_SESSION:
+                Log.v(TAG, " SEQ_OPEN_SESSION ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting2), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_INIT_SESSION, isDumpLog, 0, 0x902f));
                 break;
 
             case SEQ_INIT_SESSION:
+                Log.v(TAG, " SEQ_INIT_SESSION ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting3), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHANGE_REMOTE, isDumpLog, 0, 0x9114, 4, 0x15));
                 break;
 
             case SEQ_CHANGE_REMOTE:
+                Log.v(TAG, " SEQ_CHANGE_REMOTE ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting4), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_SET_EVENT_MODE, isDumpLog, 0, 0x9115, 4, 0x02));
                 break;
 
             case SEQ_SET_EVENT_MODE:
+                Log.v(TAG, " SEQ_SET_EVENT_MODE ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting5), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT, isDumpLog, 0, 0x913d, 4, 0x0fff));
                 // commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT, isDumpLog, 0, 0x902f, 4, 0x02));
                 break;
 
             case SEQ_GET_EVENT:
+                Log.v(TAG, " SEQ_GET_EVENT ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting6), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT1, isDumpLog, 0, 0x9033, 4, 0x0000));
                 // commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT, isDumpLog, 0, 0x902f, 4, 0x02));
                 break;
 
             case SEQ_GET_EVENT1:
+                Log.v(TAG, " SEQ_GET_EVENT1 ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting7), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_INFORMATION, isDumpLog, 0, 0x1001));
                 break;
 
             case SEQ_DEVICE_INFORMATION:
+                Log.v(TAG, " SEQ_DEVICE_INFORMATION ");
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting8), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_PROPERTY, isDumpLog, 0, 0x9127, 4, 0x0000d1a6));
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_PROPERTY, isDumpLog, 0, 0x9127, 4, 0x0000d169));
@@ -165,18 +172,18 @@ public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
                 break;
 
             case SEQ_DEVICE_PROPERTY:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting9), false, false, 0);
                 Log.v(TAG, " SEQ_DEVICE_PROPERTY ");
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting9), false, false, 0);
                 if ((rx_body[8] == (byte) 0x01)&&(rx_body[9] == (byte) 0x20))
                 {
-                    // コマンドが受け付けられた!
+                    // コマンドが受け付けられたときだけ次に進む
                     try
                     {
-                        // ちょっと(200ms)待つ
-                        Thread.sleep(200);
+                        // ちょっと(250ms)待つ
+                        Thread.sleep(250);
 
                         // コマンド発行
-                        commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY, isDumpLog, 0, 20, 0xd136, 0x00));
+                        commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY, isDumpLog, 0, 150, 0xd136, 0x00));
                     }
                     catch (Exception e)
                     {
@@ -186,44 +193,28 @@ public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
                 break;
 
             case SEQ_SET_DEVICE_PROPERTY:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting10), false, false, 0);
                 Log.v(TAG, " SEQ_SET_DEVICE_PROPERTY ");
-                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY_2, isDumpLog, 0, 20, 0xd136, 0x01));
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting10), false, false, 0);
+                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY_2, isDumpLog, 0, 150, 0xd136, 0x01));
                 break;
 
             case SEQ_SET_DEVICE_PROPERTY_2:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting10), false, false, 0);
                 Log.v(TAG, " SEQ_SET_DEVICE_PROPERTY_2 ");
-                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY_3, isDumpLog, 0, 20, 0xd136, 0x00));
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting11), false, false, 0);
+                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY_3, isDumpLog, 0, 150, 0xd136, 0x00));
                 break;
 
             case SEQ_SET_DEVICE_PROPERTY_3:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting11), false, false, 0);
                 Log.v(TAG, " SEQ_SET_DEVICE_PROPERTY_3 ");
-                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_DEVICE_PROPERTY_FINISHED, isDumpLog, 0, 20, 0xd1b0, 0x08));
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting12), false, false, 0);
+                commandIssuer.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_DEVICE_PROPERTY_FINISHED, isDumpLog, 0, 300, 0xd1b0, 0x08));
                 break;
 
             case SEQ_DEVICE_PROPERTY_FINISHED:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting12), false, false, 0);
                 Log.v(TAG, " SEQ_DEVICE_PROPERTY_FINISHED ");
-/*
-                if (rx_body.length <= 80)
-                {
-                    // 『仮』: OP CODE: 0x9116 の応答データが80バイト以下なら、再度イベントを要求する
-                    Log.v(TAG, "  TRY AGAIN ... : " + rx_body.length);
-                    interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting5), false, false, 0);
-                    //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_PROPERTY_FINISHED, isDumpLog, 0, 0x9116));
-                }
-                else
- */
-                {
-                    interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connect_finished), false, false, 0);
-                    connectFinished();
-                    Log.v(TAG, "CHANGED MODE : DONE.");
-                }
-
-                // 実験...
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_VIEWFRAME, isDumpLog, 0, 0x9153, 12, 0x00200000, 0x01, 0x00));
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connect_finished), false, false, 0);
+                connectFinished();
+                Log.v(TAG, "CHANGED MODE : DONE.");
                 break;
 
             default:
@@ -283,8 +274,8 @@ public class CanonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
             // ちょっと待つ
             Thread.sleep(1000);
 
-            //interfaceProvider.getAsyncEventCommunication().connect();
-            //interfaceProvider.getCameraStatusWatcher().startStatusWatch(interfaceProvider.getStatusListener());  ステータスの定期確認は実施しない
+            // // ステータスの監視はイベント受信時のみに実施する
+            // interfaceProvider.getCameraStatusWatcher().startStatusWatch(interfaceProvider.getStatusListener());
 
             // 接続成功!のメッセージを出す
             interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connected), false, false, 0);
index 1438f46..b13c9cf 100644 (file)
@@ -19,7 +19,7 @@ import net.osdn.gokigen.a01d.R;
 import net.osdn.gokigen.a01d.camera.ICameraConnection;
 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
-import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.PtpIpStatusChecker;
+import net.osdn.gokigen.a01d.camera.canon.wrapper.status.CanonStatusChecker;
 
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
@@ -32,10 +32,10 @@ public class CanonConnection implements ICameraConnection
     private final IPtpIpInterfaceProvider interfaceProvider;
     private final BroadcastReceiver connectionReceiver;
     private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
-    private final PtpIpStatusChecker statusChecker;
+    private final CanonStatusChecker statusChecker;
     private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN;
 
-    public CanonConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull PtpIpStatusChecker statusChecker)
+    public CanonConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IPtpIpInterfaceProvider interfaceProvider, @NonNull CanonStatusChecker statusChecker)
     {
         Log.v(TAG, "CanonConnection()");
         this.context = context;
@@ -1,4 +1,4 @@
-package net.osdn.gokigen.a01d.camera.ptpip.wrapper.status;
+package net.osdn.gokigen.a01d.camera.canon.wrapper.status;
 
 import android.app.Activity;
 import android.util.Log;
@@ -25,16 +25,15 @@ import java.util.List;
 
 import static net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper.dump_bytes;
 
-public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusWatcher, ICameraStatus
+public class CanonStatusChecker implements IPtpIpCommandCallback, ICameraStatusWatcher, ICameraStatus
 {
     private final String TAG = toString();
 
     private static final int BUFFER_SIZE = 1024 * 1024 + 8;
     private static final int STATUS_MESSAGE_HEADER_SIZE = 14;
-    private int sleepMs;
     private final IPtpIpCommandPublisher issuer;
     private ICameraStatusUpdateNotify notifier = null;
-    private PtpIpStatusHolder statusHolder;
+    private CanonStatusHolder statusHolder;
     private boolean whileFetching = false;
     private boolean logcat = false;
     private final String ipAddress;
@@ -45,13 +44,12 @@ public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusW
     private BufferedReader bufferedReader = null;
     private int eventConnectionNumber = 0;
 
-    public PtpIpStatusChecker(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher issuer, @NonNull String ip, int portNumber)
+    public CanonStatusChecker(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher issuer, @NonNull String ip, int portNumber)
     {
         this.issuer = issuer;
-        this.statusHolder = new PtpIpStatusHolder();
+        this.statusHolder = new CanonStatusHolder();
         this.ipAddress = ip;
         this.portNumber = portNumber;
-        Log.v(TAG, "POLLING WAIT : " + sleepMs);
     }
 
     @Override
@@ -85,7 +83,6 @@ public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusW
                 Log.v(TAG, "received status length is short. (" + data.length + " bytes.)");
                 return;
             }
-/*
             int nofStatus = (data[13] * 256) + data[12];
             int statusCount = 0;
             int index = STATUS_MESSAGE_HEADER_SIZE;
@@ -96,7 +93,6 @@ public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusW
                 index = index + 6;
                 statusCount++;
             }
-*/
         }
         catch (Exception e)
         {
@@ -502,15 +498,12 @@ public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusW
                 int parameter1 = ((((int) received_message[17]) & 0xff) << 24) + ((((int) received_message[16]) & 0xff) << 16) + ((((int) received_message[15]) & 0xff) << 8) + (((int) received_message[14]) & 0xff);
                 int parameter2 = ((((int) received_message[21]) & 0xff) << 24) + ((((int) received_message[20]) & 0xff) << 16) + ((((int) received_message[19]) & 0xff) << 8) + (((int) received_message[18]) & 0xff);
                 int parameter3 = ((((int) received_message[25]) & 0xff) << 24) + ((((int) received_message[24]) & 0xff) << 16) + ((((int) received_message[23]) & 0xff) << 8) + (((int) received_message[22]) & 0xff);
-
+                Log.v(TAG, String.format(" event : 0x%x, code: 0x%x, prm1: 0x%x, prm2: 0x%x, prm3 : 0x%x", packetType, eventCode, parameter1, parameter2, parameter3));
                 if (eventCode == 0xc101)
                 {
-                    // イベント受信指示
-                    issuer.enqueueCommand(new PtpIpCommandGeneric(this, IPtpIpMessages.SEQ_GET_STATUS, true, 0, 0x9116));
-                    issuer.enqueueCommand(new PtpIpCommandGeneric(this, IPtpIpMessages.SEQ_GET_STATUS, true, 0, 0x9116));
+                    // イベントの受信指示
                     issuer.enqueueCommand(new PtpIpCommandGeneric(this, IPtpIpMessages.SEQ_GET_STATUS, true, 0, 0x9116));
                 }
-
             }
         }
         catch (Exception e)
@@ -519,4 +512,3 @@ public class PtpIpStatusChecker implements IPtpIpCommandCallback, ICameraStatusW
         }
     }
 }
-
@@ -1,4 +1,4 @@
-package net.osdn.gokigen.a01d.camera.ptpip.wrapper.status;
+package net.osdn.gokigen.a01d.camera.canon.wrapper.status;
 
 import android.util.Log;
 import android.util.SparseIntArray;
@@ -6,19 +6,20 @@ import android.util.SparseIntArray;
 import androidx.annotation.NonNull;
 import androidx.collection.SparseArrayCompat;
 
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.status.IPtpIpCameraProperties;
 import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
-class PtpIpStatusHolder implements IPtpIpCameraProperties
+class CanonStatusHolder implements IPtpIpCameraProperties
 {
     private final String TAG = toString();
     private SparseIntArray statusHolder;
     private SparseArrayCompat<String> statusNameArray;
 
-    PtpIpStatusHolder()
+    CanonStatusHolder()
     {
         statusHolder = new SparseIntArray();
         statusHolder.clear();
@@ -67,6 +68,8 @@ class PtpIpStatusHolder implements IPtpIpCameraProperties
     {
         try
         {
+            Log.v(TAG, " updateValue() ");
+/*
             int value = ((((int) data3) & 0xff) << 24) + ((((int) data2) & 0xff) << 16) + ((((int) data1) & 0xff) << 8) + (((int) data0) & 0xff);
             int currentValue = statusHolder.get(id, -1);
             Log.v(TAG, "STATUS  ID: " + id + "  value : " + value + " (" + currentValue + ")");
@@ -79,6 +82,7 @@ class PtpIpStatusHolder implements IPtpIpCameraProperties
                     updateDetected(notifier, id, currentValue, value);
                 }
             }
+*/
         }
         catch (Exception e)
         {
index 392acb5..73bdd54 100644 (file)
@@ -52,4 +52,7 @@ public interface IPtpIpCommand
 
     // デバッグ用: ログ(logcat)に通信結果を残すかどうか
     boolean dumpLog();
+
+    // リトライオーバー発生時、コマンドを再送するか?
+    boolean isRetrySend();
 }
index dbeef88..2049d1d 100644 (file)
@@ -22,7 +22,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
     private static final int SEQUENCE_START_NUMBER = 1;
     private static final int BUFFER_SIZE = 1024 * 1024 + 16;  // 受信バッファは 256kB
     private static final int COMMAND_SEND_RECEIVE_DURATION_MS = 5;
-    private static final int COMMAND_SEND_RECEIVE_DURATION_MAX = 1000;
+    private static final int COMMAND_SEND_RECEIVE_DURATION_MAX = 3000;
     private static final int COMMAND_POLL_QUEUE_MS = 5;
 
     private final String ipAddress;
@@ -267,6 +267,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 retry_over = receive_from_camera(command);
                 if ((retry_over)&&(commandBody != null))
                 {
+                    if (!command.isRetrySend())
+                    {
+                        //  コマンドを再送信しない場合はここで抜ける
+                        break;
+                    }
                     // 再送信...のために、シーケンス番号を戻す...
                     sequenceNumber--;
                 }
@@ -595,6 +600,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
 
     private int waitForReceive(InputStream is, int delayMs)
     {
+        boolean isLogOutput = true;
         int retry_count = 50;
         int read_bytes = 0;
         try
@@ -605,7 +611,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 read_bytes = is.available();
                 if (read_bytes == 0)
                 {
-                    Log.v(TAG, " is.available() WAIT... ");
+                    if (isLogOutput)
+                    {
+                        Log.v(TAG, " is.available() WAIT... ");
+                        isLogOutput = false;
+                    }
                     retry_count--;
                     if (retry_count < 0)
                     {
index a00ef84..bcd50e2 100644 (file)
@@ -107,4 +107,10 @@ public class PtpIpCommandBase implements IPtpIpCommand, IPtpIpMessages
     {
         return (true);
     }
+
+    @Override
+    public boolean isRetrySend()
+    {
+        return (true);
+    }
 }