• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

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


Commit MetaInfo

Revisãofe567e242a7940a6370d27089a6300e4d89c5ee3 (tree)
Hora2020-03-06 00:01:43
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

安定性調査中。

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
@@ -63,7 +63,7 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6363 public CanonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
6464 {
6565 this.activity = context;
66- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT);
66+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
6767 liveViewControl = new CanonLiveViewControl(context, this, 10); //
6868 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
6969 statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT);
--- 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
@@ -125,7 +125,8 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
125125 @Override
126126 public void halfPressShutter(boolean isPressed)
127127 {
128- unlockAutoFocus();
128+ //unlockAutoFocus();
129+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
129130 //lockAutoFocus(new PointF(0.5f, 0.5f));
130131 }
131132
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
@@ -63,8 +63,8 @@ public class NikonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6363 public NikonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
6464 {
6565 this.activity = context;
66- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT);
67- liveViewControl = new NikonLiveViewControl(context, this, 40);
66+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
67+ liveViewControl = new NikonLiveViewControl(context, this, 20);
6868 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
6969 statusChecker = new NikonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
7070 canonConnection = new NikonConnection(context, provider, this, statusChecker);
--- 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
@@ -70,7 +70,7 @@ public class NikonLiveViewRequestMessage extends PtpIpCommandBase
7070 @Override
7171 public int maxRetryCount()
7272 {
73- return (1);
73+ return (7);
7474 }
7575
7676 @Override
--- 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
@@ -14,6 +14,7 @@ import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
1414 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpResponseReceiver;
1515 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
1616 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
17+import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
1718 import net.osdn.gokigen.a01d.liveview.liveviewlistener.IImageDataReceiver;
1819 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
1920
@@ -21,7 +22,10 @@ import java.util.Arrays;
2122 import java.util.Map;
2223
2324 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_AFDRIVE;
25+import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_CHECK_EVENT;
2426 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_DEVICE_READY;
27+import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_GET_DEVICE_PROP1;
28+import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_GET_DEVICE_PROP2;
2529 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_START_LIVEVIEW;
2630 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_STOP_LIVEVIEW;
2731
@@ -185,7 +189,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
185189 //SimpleLogDumper.dump_bytes(" [LVLV] " + ": ", Arrays.copyOfRange(data, 0, (0 + 512)));
186190 //dataReceiver.setImageData(data, metadata);
187191 int offset = searchJpegHeader(data);
188- if (data.length > 8)
192+ if ((data.length > 8)&&(offset < data.length))
189193 {
190194 dataReceiver.setImageData(Arrays.copyOfRange(data, offset, data.length), metadata); // ヘッダ部分を切り取って送る
191195 }
@@ -195,6 +199,8 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
195199 {
196200 e.printStackTrace();
197201 }
202+ //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
203+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
198204 commandIssued = false;
199205 }
200206
@@ -234,15 +240,25 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
234240 @Override
235241 public void receivedMessage(int id, byte[] rx_body)
236242 {
237- Log.v(TAG, " NikonLiveViewControl::receivedMessage() : ");
243+ Log.v(TAG, " NikonLiveViewControl::receivedMessage() [id:" + id + "]");
238244 try
239245 {
240246 if (rx_body.length < 10)
241247 {
248+ Log.v(TAG, " NikonLiveViewControl::receivedMessage() : BODY LENGTH IS TOO SHORT. SEND RETRY MESSAGE");
242249 retrySendMessage(id);
243250 return;
244251 }
252+/**/
245253 int responseCode = (rx_body[8] & 0xff) + ((rx_body[9] & 0xff) * 256);
254+ if (id == SEQ_CHECK_EVENT)
255+ {
256+ // 応答にはデータが含まれているので....受信データの末尾を拾う
257+ //SimpleLogDumper.dump_bytes("CHECK EVENT", Arrays.copyOfRange(rx_body, 0, Math.min(rx_body.length, 128)));
258+ responseCode = (rx_body[rx_body.length - 6] & 0xff) + ((rx_body[rx_body.length - 5] & 0xff) * 256);
259+ }
260+/**/
261+ //int responseCode = (rx_body[rx_body.length - 6] & 0xff) + ((rx_body[rx_body.length - 5] & 0xff) * 256);
246262 if (responseCode != 0x2001)
247263 {
248264 // NG応答を受信...同じコマンドを再送する
@@ -251,7 +267,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
251267 return;
252268 }
253269
254- Log.v(TAG, String.format(" OK REPLY (ID : %d) ", id));
270+ Log.v(TAG, String.format(" ----- OK REPLY (ID : %d) ----- ", id));
255271 if (id == SEQ_START_LIVEVIEW)
256272 {
257273 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
@@ -260,10 +276,23 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
260276 {
261277 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
262278 }
263- else
279+ else if (id == SEQ_CHECK_EVENT)
280+ {
281+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
282+ }
283+ else if (id == SEQ_GET_DEVICE_PROP1)
284+ {
285+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, 30, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
286+ }
287+ else if (id == SEQ_GET_DEVICE_PROP2)
288+ {
289+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
290+ }
291+ else // SEQ_AFDRIVE
264292 {
265293 // ライブビューの開始。
266- startLiveviewImpl();
294+ //startLiveviewImpl();
295+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 80, isDumpLog));
267296 }
268297 }
269298 catch (Exception e)
@@ -272,10 +301,23 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
272301 }
273302 }
274303
304+ private void waitSleep()
305+ {
306+ try
307+ {
308+ Thread.sleep(delayMs);
309+ }
310+ catch (Exception e)
311+ {
312+ e.printStackTrace();
313+ }
314+ }
315+
275316 private void retrySendMessage(int id)
276317 {
277318 try
278319 {
320+ waitSleep();
279321 if (id == SEQ_START_LIVEVIEW)
280322 {
281323 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 30, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
@@ -284,6 +326,18 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
284326 {
285327 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
286328 }
329+ else if (id == SEQ_CHECK_EVENT)
330+ {
331+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
332+ }
333+ else if (id == SEQ_GET_DEVICE_PROP1)
334+ {
335+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x5007, 4, 0x5007, 0x00, 0x00, 0x00));
336+ }
337+ else if (id == SEQ_GET_DEVICE_PROP2)
338+ {
339+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, 30, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
340+ }
287341 else
288342 {
289343 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpMessages.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/IPtpIpMessages.java
@@ -25,6 +25,9 @@ public interface IPtpIpMessages
2525 int SEQ_STOP_LIVEVIEW = 20;
2626 int SEQ_DEVICE_READY = 21;
2727 int SEQ_AFDRIVE = 22;
28+ int SEQ_CHECK_EVENT = 23;
29+ int SEQ_GET_DEVICE_PROP1 = 24;
30+ int SEQ_GET_DEVICE_PROP2 = 25;
2831
2932 int GET_STORAGE_ID = 101;
3033 int GET_STORAGE_INFO = 102;
--- 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
@@ -32,6 +32,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
3232
3333 private boolean isStart = false;
3434 private boolean isHold = false;
35+ private boolean tcpNoDelay;
3536 private int holdId = 0;
3637 private Socket socket = null;
3738 private DataOutputStream dos = null;
@@ -40,10 +41,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
4041 private Queue<IPtpIpCommand> commandQueue;
4142 private Queue<IPtpIpCommand> holdCommandQueue;
4243
43- public PtpIpCommandPublisher(@NonNull String ip, int portNumber)
44+ public PtpIpCommandPublisher(@NonNull String ip, int portNumber, boolean tcpNoDelay)
4445 {
4546 this.ipAddress = ip;
4647 this.portNumber = portNumber;
48+ this.tcpNoDelay = tcpNoDelay;
4749 this.commandQueue = new ArrayDeque<>();
4850 this.holdCommandQueue = new ArrayDeque<>();
4951 commandQueue.clear();
@@ -63,6 +65,10 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
6365 {
6466 Log.v(TAG, " connect()");
6567 socket = new Socket(ipAddress, portNumber);
68+ socket.setTcpNoDelay(tcpNoDelay);
69+ socket.setKeepAlive(true);
70+ //socket.setReceiveBufferSize(32768);
71+ //socket.setTrafficClass(0x10);
6672 return (true);
6773 }
6874 catch (Exception e)
Show on old repository browser