@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)
@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
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)
{
@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() {
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)
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
{
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
{
@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);
{
return;
}
- int first_offset = 416;
int length = rx_body.length;
int data_position = 0;
if (!receivedFirstData)
// データを最初に読んだとき。ヘッダ部分を読み飛ばす
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)
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)
{
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
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)
{
{
// リトライオーバー...
Log.v(TAG, " RECEIVE : RETRY OVER......");
- return (true);
+ if (command.isRetrySend())
+ {
+ // 要求を再送する場合、、、ダメな場合は受信待ちとする
+ return (true);
+ }
}
// 初回データの読み込み
{
if (isLogOutput)
{
- Log.v(TAG, " is.available() WAIT... ");
+ Log.v(TAG, "waitForReceive:: is.available() WAIT... : " + delayMs + "ms");
isLogOutput = false;
}
retry_count--;
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;
void stored(boolean result);
void restored(boolean result);
}
-*****/
+*/
}
<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>
<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>
<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" />