• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

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


Commit MetaInfo

Revisão0045f990bba728c9c3489dca5308a106e2f90781 (tree)
Hora2020-02-24 01:04:17
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

リトライ待ち時間を変更可能にする。

Mudança Sumário

Diff

--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/command/messages/specific/NikonLiveViewRequestMessage.java
@@ -0,0 +1,76 @@
1+package net.osdn.gokigen.a01d.camera.nikon.wrapper.command.messages.specific;
2+
3+import androidx.annotation.NonNull;
4+
5+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
6+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandBase;
7+
8+public class NikonLiveViewRequestMessage extends PtpIpCommandBase
9+{
10+ private final IPtpIpCommandCallback callback;
11+ private final boolean isDumpLog;
12+ private final int delayMs;
13+
14+ public NikonLiveViewRequestMessage(@NonNull IPtpIpCommandCallback callback,int delayMs, boolean isDumpLog)
15+ {
16+ this.callback = callback;
17+ this.delayMs = delayMs;
18+ this.isDumpLog = isDumpLog;
19+ }
20+
21+ @Override
22+ public IPtpIpCommandCallback responseCallback()
23+ {
24+ return (callback);
25+ }
26+
27+ @Override
28+ public int getId()
29+ {
30+ return (SEQ_GET_VIEWFRAME);
31+ }
32+
33+ @Override
34+ public byte[] commandBody()
35+ {
36+ return (new byte[]{
37+
38+ // packet type
39+ (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
40+
41+ // data phase info
42+ (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
43+
44+ // operation code
45+ (byte) 0x03, (byte) 0x92,
46+
47+ // sequence number
48+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
49+ });
50+ }
51+
52+ @Override
53+ public boolean dumpLog()
54+ {
55+ return (isDumpLog);
56+ }
57+
58+ @Override
59+ public int receiveDelayMs()
60+ {
61+ return (delayMs);
62+ }
63+
64+ @Override
65+ public boolean isRetrySend()
66+ {
67+ return (true);
68+ }
69+
70+ @Override
71+ public int maxRetryCount()
72+ {
73+ return (5);
74+ }
75+
76+}
--- 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
@@ -6,6 +6,7 @@ import android.util.Log;
66 import androidx.annotation.NonNull;
77
88 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
9+import net.osdn.gokigen.a01d.camera.nikon.wrapper.command.messages.specific.NikonLiveViewRequestMessage;
910 import net.osdn.gokigen.a01d.camera.ptpip.IPtpIpInterfaceProvider;
1011 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandPublisher;
1112 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
@@ -21,7 +22,6 @@ import java.util.Map;
2122
2223 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_AFDRIVE;
2324 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_DEVICE_READY;
24-import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_GET_VIEWFRAME;
2525 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_START_LIVEVIEW;
2626 import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_STOP_LIVEVIEW;
2727
@@ -34,7 +34,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
3434 private IImageDataReceiver dataReceiver = null;
3535 private boolean liveViewIsReceiving = false;
3636 private boolean commandIssued = false;
37- private boolean isDumpLog = false;
37+ private boolean isDumpLog = true;
3838
3939 public NikonLiveViewControl(@NonNull Activity context, @NonNull IPtpIpInterfaceProvider interfaceProvider, int delayMs)
4040 {
@@ -104,7 +104,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
104104 if (!commandIssued)
105105 {
106106 commandIssued = true;
107- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(imageReceiver, SEQ_GET_VIEWFRAME, 80, true, 0, 0x9203, 0, 0x00, 0x00, 0x00, 0x00));
107+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 90, isDumpLog));
108108 }
109109 try
110110 {
--- 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
@@ -55,4 +55,7 @@ public interface IPtpIpCommand
5555
5656 // リトライオーバー発生時、コマンドを再送するか?
5757 boolean isRetrySend();
58+
59+ // 受信待ち再試行回数
60+ int maxRetryCount();
5861 }
--- 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
@@ -4,8 +4,6 @@ import android.util.Log;
44
55 import androidx.annotation.NonNull;
66
7-import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
8-
97 import java.io.BufferedReader;
108 import java.io.ByteArrayOutputStream;
119 import java.io.DataOutputStream;
@@ -393,7 +391,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
393391 }
394392
395393 // 初回データが受信バッファにデータが溜まるまで待つ...
396- int read_bytes = waitForReceive(is, delayMs);
394+ int read_bytes = waitForReceive(is, delayMs, command.maxRetryCount());
397395 if (read_bytes < 0)
398396 {
399397 // リトライオーバー...
@@ -444,7 +442,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
444442 private boolean receive_multi(@NonNull IPtpIpCommand command, int delayMs)
445443 {
446444 //int estimatedSize = command.estimatedReceiveDataSize();
447- int maxRetryCount = 20;
445+ int maxRetryCount = command.maxRetryCount();
448446 int id = command.getId();
449447 IPtpIpCommandCallback callback = command.responseCallback();
450448
@@ -461,7 +459,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
461459 }
462460
463461 // 初回データが受信バッファにデータが溜まるまで待つ...
464- int read_bytes = waitForReceive(is, delayMs);
462+ int read_bytes = waitForReceive(is, delayMs, command.maxRetryCount());
465463 if (read_bytes < 0)
466464 {
467465 // リトライオーバー...
@@ -522,7 +520,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
522520 }
523521 //byteStream.write(byte_array, 0, read_bytes);
524522
525- maxRetryCount = 20;
523+ maxRetryCount = command.maxRetryCount();
526524 //do
527525 {
528526 sleep(delayMs);
@@ -542,7 +540,14 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
542540 if (callback != null)
543541 {
544542 Log.v(TAG, " --- receive_multi : " + id + " (" + read_bytes + ") [" + maxRetryCount + "] " + receive_message_buffer_size + " (" + received_length + ") ");
545- callback.receivedMessage(id, null);
543+ try
544+ {
545+ callback.receivedMessage(id, Arrays.copyOfRange(byte_array, 0, received_length));
546+ }
547+ catch (Exception e)
548+ {
549+ e.printStackTrace();
550+ }
546551 }
547552 }
548553 catch (Throwable e)
@@ -589,7 +594,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
589594 if (packetType == 0x09)
590595 {
591596 lenlen = ((((int) byte_array[15]) & 0xff) << 24) + ((((int) byte_array[14]) & 0xff) << 16) + ((((int) byte_array[13]) & 0xff) << 8) + (((int) byte_array[12]) & 0xff);
592- packetType = (((int) byte_array[16]) & 0xff);
597+ //packetType = (((int) byte_array[16]) & 0xff);
593598 }
594599 // Log.v(TAG, " --- RECEIVED MESSAGE : " + len + " bytes (BUFFER: " + byte_array.length + " bytes)" + " length : " + lenlen + " TYPE : " + packetType + " --- ");
595600 if (lenlen == 0)
@@ -603,8 +608,8 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
603608 while (position < limit)
604609 {
605610 lenlen = ((((int) byte_array[position + 3]) & 0xff) << 24) + ((((int) byte_array[position + 2]) & 0xff) << 16) + ((((int) byte_array[position + 1]) & 0xff) << 8) + (((int) byte_array[position]) & 0xff);
606- packetType = (((int) byte_array[position + 4]) & 0xff);
607611 /*
612+ packetType = (((int) byte_array[position + 4]) & 0xff);
608613 if (packetType != 0x0a)
609614 {
610615 Log.v(TAG, " <><><> PACKET TYPE : " + packetType + " LENGTH : " + lenlen);
@@ -624,10 +629,9 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
624629 return (receivedBuffer);
625630 }
626631
627- private int waitForReceive(InputStream is, int delayMs)
632+ private int waitForReceive(InputStream is, int delayMs, int retry_count)
628633 {
629634 boolean isLogOutput = true;
630- int retry_count = 50;
631635 int read_bytes = 0;
632636 try
633637 {
--- 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
@@ -113,4 +113,10 @@ public class PtpIpCommandBase implements IPtpIpCommand, IPtpIpMessages
113113 {
114114 return (true);
115115 }
116+
117+ @Override
118+ public int maxRetryCount()
119+ {
120+ return (20);
121+ }
116122 }
Show on old repository browser