• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Revisãoc879e0d5d92d1d9606fa201cc81fbb9e6c847015 (tree)
Hora2020-03-01 16:49:55
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

とりあえず保管。

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
@@ -137,8 +137,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
137137 int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1));
138138 Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
139139 commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
140- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
141-
140+ //commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
142141 }
143142 catch (Exception e)
144143 {
@@ -215,6 +214,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
215214 if ((id == FOCUS_LOCK)||(id == FOCUS_LOCK_PRE))
216215 {
217216 Log.v(TAG, "FOCUS LOCKED");
217+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1)); // OKのときは駆動
218218 if (preFocusFrameRect != null)
219219 {
220220 // showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 1.0); // 1秒だけ表示
@@ -251,6 +251,6 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
251251 @Override
252252 public boolean isReceiveMulti()
253253 {
254- return (false);
254+ return (true);
255255 }
256256 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/command/messages/specific/NikonLiveViewRequestMessage.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/command/messages/specific/NikonLiveViewRequestMessage.java
@@ -73,4 +73,10 @@ public class NikonLiveViewRequestMessage extends PtpIpCommandBase
7373 return (5);
7474 }
7575
76+ @Override
77+ public boolean isIncrementSequenceNumberToRetry()
78+ {
79+ return (true);
80+ }
81+
7682 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
@@ -11,7 +11,6 @@ import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
1111 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
1212 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
1313 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
14-import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpResponseReceiver;
1514 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpResponseReceiver;
1615 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
1716 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
@@ -103,7 +102,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
103102 if (!commandIssued)
104103 {
105104 commandIssued = true;
106- commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 90, isDumpLog));
105+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 30, isDumpLog));
107106 }
108107 try
109108 {
@@ -185,7 +184,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
185184 //Log.v(TAG, " ---+++--- RECEIVED LV IMAGE ---+++--- : " + data.length + " bytes.");
186185 //SimpleLogDumper.dump_bytes(" [LVLV] " + ": ", Arrays.copyOfRange(data, 0, (0 + 512)));
187186 //dataReceiver.setImageData(data, metadata);
188- int offset = 384;
187+ int offset = searchJpegHeader(data);
189188 if (data.length > 8)
190189 {
191190 dataReceiver.setImageData(Arrays.copyOfRange(data, offset, data.length), metadata); // ヘッダ部分を切り取って送る
@@ -199,6 +198,32 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
199198 commandIssued = false;
200199 }
201200
201+ private int searchJpegHeader(byte[] data)
202+ {
203+ try
204+ {
205+ int pos = 0;
206+
207+ // 先頭の 1024bytesまで
208+ int limit = (data.length < 1024) ? (data.length - 1): 1024;
209+ while (pos < limit)
210+ {
211+ if ((data[pos] == (byte) 0xff)&&(data[pos + 1] == (byte) 0xd8))
212+ {
213+
214+ return (pos);
215+ }
216+ pos++;
217+ }
218+ }
219+ catch (Exception e)
220+ {
221+ e.printStackTrace();
222+ }
223+ return (384);
224+ }
225+
226+
202227 @Override
203228 public void onErrorOccurred(Exception e)
204229 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewImageReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewImageReceiver.java
@@ -5,8 +5,10 @@ import android.util.Log;
55 import androidx.annotation.NonNull;
66 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
77 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
8+import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
89
910 import java.io.ByteArrayOutputStream;
11+import java.util.Arrays;
1012
1113 public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
1214 {
@@ -30,12 +32,70 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
3032 @Override
3133 public void receivedMessage(int id, byte[] rx_body)
3234 {
35+ if (isReceiveMulti())
36+ {
37+ receivedMessage_multi(id, rx_body);
38+ }
39+ else
40+ {
41+ receivedMessage_single(id, rx_body);
42+ }
43+ }
44+
45+ @Override
46+ public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] rx_body)
47+ {
48+ int body_length = 0;
49+ if (rx_body != null)
50+ {
51+ body_length = rx_body.length;
52+ }
53+ Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes + " LENGTH: " + body_length + " bytes.");
54+
55+ // 受信したデータから、通信のヘッダ部分を削除する
56+ cutHeader(rx_body);
57+ }
58+
59+ private void receivedMessage_single(int id, byte[] rx_body)
60+ {
3361 try
3462 {
63+ if (rx_body != null)
64+ {
65+ Log.v(TAG, "receivedMessage_single() : " + rx_body.length + " bytes.");
66+ if (rx_body.length > 64)
67+ {
68+ SimpleLogDumper.dump_bytes(" LV (FIRST) : ", Arrays.copyOfRange(rx_body, 0, 64));
69+ SimpleLogDumper.dump_bytes(" LV (-END-) : ", Arrays.copyOfRange(rx_body, (rx_body.length - 64), rx_body.length));
70+ }
71+ callback.onCompleted(rx_body, null);
72+ }
73+ else
74+ {
75+ Log.v(TAG, "receivedMessage_single() : NULL");
76+ }
77+ }
78+ catch (Exception e)
79+ {
80+ e.printStackTrace();
81+ }
82+ }
83+
84+ private void receivedMessage_multi(int id, byte[] rx_body)
85+ {
86+ try
87+ {
88+ int body_length = 0;
89+ if (rx_body != null)
90+ {
91+ body_length = rx_body.length;
92+ }
93+ Log.v(TAG, " receivedMessage_multi() id[" + id + "] size : " + body_length + " target length : " + target_image_size + " ");
94+
3595 // end of receive sequence.
36- byte [] thumbnail = byteStream.toByteArray();
96+ //byte [] thumbnail = byteStream.toByteArray();
3797 //byte [] thumbnail = rx_body;
38- Log.v(TAG, " TransferComplete() RECEIVED id[" + id + "] size : " + target_image_size + " (" + thumbnail.length + ")");
98+ //Log.v(TAG, " TransferComplete() RECEIVED id[" + id + "] size : " + target_image_size + " (" + thumbnail.length + ")");
3999 //SimpleLogDumper.dump_bytes(" [xxxxx]", Arrays.copyOfRange(thumbnail, 0, (512)));
40100 //SimpleLogDumper.dump_bytes(" [zzzzz]", Arrays.copyOfRange(thumbnail, (thumbnail.length - 128), (thumbnail.length)));
41101 callback.onCompleted(byteStream.toByteArray(), null);
@@ -55,15 +115,6 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
55115 }
56116 }
57117
58- @Override
59- public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] rx_body)
60- {
61- //Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes);
62-
63- // 受信したデータから、通信のヘッダ部分を削除する
64- cutHeader(rx_body);
65- }
66-
67118 private void cutHeader(byte[] rx_body)
68119 {
69120 if (rx_body == null)
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpCommand.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpCommand.java
@@ -58,4 +58,8 @@ public interface IPtpIpCommand
5858
5959 // 受信待ち再試行回数
6060 int maxRetryCount();
61+
62+ // リトライオーバーで再送するとき、SeqNoをインクリメントするか
63+ boolean isIncrementSequenceNumberToRetry();
64+
6165 }
--- 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
@@ -275,8 +275,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
275275 // コマンドを再送信しない場合はここで抜ける
276276 break;
277277 }
278- // 再送信...のために、シーケンス番号を戻す...
279- sequenceNumber--;
278+ if (!command.isIncrementSequenceNumberToRetry())
279+ {
280+ // 再送信...のために、シーケンス番号を戻す...
281+ sequenceNumber--;
282+ }
280283 }
281284 }
282285 }
@@ -387,6 +390,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
387390 if (is == null)
388391 {
389392 Log.v(TAG, " InputStream is NULL... RECEIVE ABORTED.");
393+ receivedAllMessage(isDumpReceiveLog, id, null, callback);
390394 return (false);
391395 }
392396
@@ -396,6 +400,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
396400 {
397401 // リトライオーバー...
398402 Log.v(TAG, " RECEIVE : RETRY OVER...");
403+ if (!command.isRetrySend())
404+ {
405+ // 再送しない場合には、応答がないことを通知する
406+ receivedAllMessage(isDumpReceiveLog, id, null, callback);
407+ }
399408 return (true);
400409 }
401410
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/messages/PtpIpCommandBase.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/messages/PtpIpCommandBase.java
@@ -119,4 +119,11 @@ public class PtpIpCommandBase implements IPtpIpCommand, IPtpIpMessages
119119 {
120120 return (20);
121121 }
122+
123+ @Override
124+ public boolean isIncrementSequenceNumberToRetry()
125+ {
126+ return (false);
127+ }
128+
122129 }
Show on old repository browser