OSDN Git Service

NIKON対応ひととおり。
authorMRSa <mrsa@myad.jp>
Sun, 23 Feb 2020 15:29:28 +0000 (00:29 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 23 Feb 2020 15:29:28 +0000 (00:29 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonCaptureControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewImageReceiver.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java
app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_nikon.xml

index 4d70535..0b8611c 100644 (file)
@@ -49,12 +49,17 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
     @Override
     public void receivedMessage(int id, byte[] rx_body)
     {
-        Log.v(TAG, " CanonCaptureControl::receivedMessage() : ");
+        Log.v(TAG, " NikonCaptureControl::receivedMessage() : ");
         try
         {
-            if ((rx_body.length > 10)&&((rx_body[8] != (byte) 0x01)||(rx_body[9] != (byte) 0x20)))
+            int responseCode = (rx_body[8] & 0xff) + ((rx_body[9] & 0xff) * 256);
+            if ((rx_body.length > 10) && (responseCode != 0x2001))
             {
-                Log.v(TAG, " --- RECEIVED NG REPLY. : " + id);
+                Log.v(TAG, String.format(" RECEIVED NG REPLY ID : %d, RESPONSE CODE : 0x%04x ", id, responseCode));
+            }
+            else
+            {
+                Log.v(TAG, String.format(" OK REPLY (ID : %d) ", id));
             }
         }
         catch (Exception e)
@@ -66,7 +71,7 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
     @Override
     public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
     {
-        Log.v(TAG, " CanonCaptureControl::onReceiveProgress() : " + currentBytes + "/" + totalBytes);
+        Log.v(TAG, " NikonCaptureControl::onReceiveProgress() : " + currentBytes + "/" + totalBytes);
     }
 
     @Override
index 42d4ec4..2169542 100644 (file)
@@ -45,7 +45,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
         try
         {
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
-            String focusPoint = preferences.getString(IPreferencePropertyAccessor.CANON_FOCUS_XY, IPreferencePropertyAccessor.CANON_FOCUS_XY_DEFAULT_VALUE);
+            String focusPoint = preferences.getString(IPreferencePropertyAccessor.NIKON_FOCUS_XY, IPreferencePropertyAccessor.NIKON_FOCUS_XY_DEFAULT_VALUE);
             String[] focus = focusPoint.split(",");
             if (focus.length == 2)
             {
@@ -70,11 +70,11 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
     @Override
     public boolean driveAutoFocus(final MotionEvent motionEvent)
     {
-        Log.v(TAG, "driveAutoFocus()");
         if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
         {
             return (false);
         }
+        Log.v(TAG, "driveAutoFocus()");
         Thread thread = new Thread(new Runnable() {
             @Override
             public void run() {
index 71db62b..140b74a 100644 (file)
@@ -79,7 +79,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             if (liveViewIsReceiving)
             {
                 liveViewIsReceiving = false;
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_STOP_LIVEVIEW, 20, isDumpLog, 0, 0x9202, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_STOP_LIVEVIEW, 30, isDumpLog, 0, 0x9202, 0, 0x00, 0x00, 0x00, 0x00));
             }
         }
         catch (Exception e)
@@ -104,7 +104,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
                             if (!commandIssued)
                             {
                                 commandIssued = true;
-                                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(imageReceiver, SEQ_GET_VIEWFRAME, 40, true, 0, 0x9203, 0, 0x00, 0x00, 0x00, 0x00));
+                                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(imageReceiver, SEQ_GET_VIEWFRAME, 80, true, 0, 0x9203, 0, 0x00, 0x00, 0x00, 0x00));
                             }
                             try
                             {
index 0527953..10fb5dd 100644 (file)
@@ -5,10 +5,8 @@ import android.util.Log;
 import androidx.annotation.NonNull;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
-import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
 
 import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
 
 public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
 {
@@ -60,7 +58,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
     @Override
     public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] rx_body)
     {
-        Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
+        //Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
 
         // 受信したデータから、通信のヘッダ部分を削除する
         cutHeader(rx_body);
@@ -72,7 +70,6 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
         {
             return;
         }
-        int first_offset = 416;
         int length = rx_body.length;
         int data_position = 0;
         if (!receivedFirstData)
@@ -80,7 +77,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
             // データを最初に読んだとき。ヘッダ部分を読み飛ばす
             receivedFirstData = true;
             data_position = (int) rx_body[0] & (0xff);
-            Log.v(TAG, " FIRST DATA POS. : " + data_position);
+            //Log.v(TAG, " FIRST DATA POS. : " + data_position);
             //SimpleLogDumper.dump_bytes(" [sssXXXsss]", Arrays.copyOfRange(rx_body, first_offset, (first_offset + 64)));
         }
         else if (received_remain_bytes > 0)
@@ -113,30 +110,8 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 break;
             }
 
-            int forward_length = data_position;
-
             // 受信データ(のヘッダ部分)をダンプする
-            Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
-            try
-            {
-                while (forward_length < rx_body.length)
-                {
-
-                    if ((rx_body[forward_length] == (byte) 0xff)&&(rx_body[forward_length + 1] == (byte) 0xd8))
-                    {
-                        break;
-                    }
-                    forward_length++;
-                }
-                if (forward_length >= rx_body.length)
-                {
-                    forward_length = data_position + 12;
-                }
-            }
-            catch (Exception e)
-            {
-                e.printStackTrace();
-            }
+            //Log.v(TAG, " RX DATA : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] (" + received_total_bytes + ")");
 
             if ((data_position + body_size) > length)
             {
@@ -145,7 +120,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + (12)), copysize);
                 received_remain_bytes = body_size - copysize - (12);  // マイナス12は、ヘッダ分
                 received_total_bytes = received_total_bytes + copysize;
-                Log.v(TAG, " ----- copy : " + (data_position + (12)) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
+                //Log.v(TAG, " ----- copy : " + (data_position + (12)) + " " + copysize + " remain : " + received_remain_bytes + "  body size : " + body_size);
                 break;
             }
             try
@@ -153,7 +128,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
                 byteStream.write(rx_body, (data_position + (12)), (body_size - (12)));
                 data_position = data_position + body_size;
                 received_total_bytes = received_total_bytes + (12);
-                Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - (12)) + " remain : " + received_remain_bytes);
+                //Log.v(TAG, " --- COPY : " + (data_position + 12) + " " + (body_size - (12)) + " remain : " + received_remain_bytes);
             }
             catch (Exception e)
             {
index 72f9d4d..20e413d 100644 (file)
@@ -466,7 +466,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
             {
                 // リトライオーバー...
                 Log.v(TAG, " RECEIVE : RETRY OVER......");
-                return (true);
+                if (command.isRetrySend())
+                {
+                    // 要求を再送する場合、、、ダメな場合は受信待ちとする
+                    return (true);
+                }
             }
 
             // 初回データの読み込み
@@ -635,7 +639,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 {
                     if (isLogOutput)
                     {
-                        Log.v(TAG, " is.available() WAIT... ");
+                        Log.v(TAG, "waitForReceive:: is.available() WAIT... : " + delayMs + "ms");
                         isLogOutput = false;
                     }
                     retry_count--;
index 2cd4213..9b80768 100644 (file)
@@ -76,7 +76,10 @@ public interface IPreferencePropertyAccessor
     String CANON_ZOOM_RESOLUTION = "canon_zoom_resolution";
     String CANON_ZOOM_RESOLUTION_DEFAULT_VALUE = "25";
 
-    /*
+    String NIKON_FOCUS_XY = "nikon_focus_xy";
+    String NIKON_FOCUS_XY_DEFAULT_VALUE = "6000,4000";
+
+ /*
     int CHOICE_SPLASH_SCREEN = 10;
 
     int SELECT_SAMPLE_IMAGE_CODE = 110;
@@ -91,6 +94,6 @@ public interface IPreferencePropertyAccessor
         void stored(boolean result);
         void restored(boolean result);
     }
-*****/
+*/
 
 }
index 788f494..e879522 100644 (file)
@@ -39,6 +39,8 @@
     <string name="pref_summary_fujix_focus_xy">フォーカス点数を指定します</string>
     <string name="pref_canon_focus_xy">フォーカス点数 (default: 6000,4000)</string>
     <string name="pref_summary_canon_focus_xy">フォーカス点数を指定します</string>
+    <string name="pref_nikon_focus_xy">フォーカス点数 (default: 6000,4000)</string>
+    <string name="pref_summary_nikon_focus_xy">フォーカス点数を指定します</string>
     <string name="pref_fujix_liveview_wait">LV画像受信待ち間隔(default: 80)</string>
     <string name="pref_summary_fujix_liveview_wait">ライブビュー画像受信間隔を指定します</string>
     <string name="pref_fujix_command_polling_wait">コマンド間隔(default: 500)</string>
     <string name="pref_use_pentax_autofocus">PENTAX一眼カメラの制御</string>
     <string name="pref_use_pentax_autofocus_summary">PENTAX一眼カメラ用の命令を使って制御します。</string>
 
-
     <string name="dialog_http_command_title_command">HTTPメッセージ送信</string>
     <string name="dialog_ricoh_command_title_command">メッセージ送信(RICOH)</string>
     <string name="dialog_panasonic_command_title_command">メッセージ送信(Panasonic)</string>
index 7e8a9ee..0bbb7f8 100644 (file)
@@ -40,6 +40,8 @@
     <string name="pref_summary_fujix_focus_xy"> </string>
     <string name="pref_canon_focus_xy">Number of Focus Point X,Y (default: 6000,4000)</string>
     <string name="pref_summary_canon_focus_xy"> </string>
+    <string name="pref_nikon_focus_xy">Number of Focus Point X,Y (default: 6000,4000)</string>
+    <string name="pref_summary_nikon_focus_xy"> </string>
     <string name="pref_fujix_liveview_wait">Liveview receive wait (default: 80)</string>
     <string name="pref_summary_fujix_liveview_wait"> </string>
     <string name="pref_fujix_command_polling_wait">Status polling wait (default: 500)</string>
index 4871a9a..41eee8a 100644 (file)
     <PreferenceCategory
         android:title="@string/pref_cat_camera">
 
+        <EditTextPreference
+            android:key="nikon_focus_xy"
+            android:title="@string/pref_nikon_focus_xy"
+            android:defaultValue="6000,4000"
+            android:summary="@string/pref_summary_nikon_focus_xy" />
+
         <CheckBoxPreference
             android:key="capture_both_camera_and_live_view"
             android:title="@string/pref_capture_both_camera_and_live_view" />