• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

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


Commit MetaInfo

Revisão03fb1a9b152cfb0578bb84c8621dca4206c20f9c (tree)
Hora2020-03-01 23:30:10
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

安定性検討中。

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonCaptureControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonCaptureControl.java
@@ -19,7 +19,7 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
1919 private final String TAG = this.toString();
2020 private final PtpIpCommandPublisher commandPublisher;
2121 //private final IAutoFocusFrameDisplay frameDisplayer;
22- private boolean isDumpLog = true;
22+ private boolean isDumpLog = false;
2323
2424 public NikonCaptureControl(@NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer)
2525 {
--- 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
@@ -34,7 +34,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
3434 private float maxPointLimitWidth;
3535 private float maxPointLimitHeight;
3636 private RectF preFocusFrameRect = null;
37- private boolean isDumpLog = true;
37+ private boolean isDumpLog = false;
3838
3939 public NikonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
4040 {
@@ -251,6 +251,6 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
251251 @Override
252252 public boolean isReceiveMulti()
253253 {
254- return (true);
254+ return (false);
255255 }
256256 }
--- 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
@@ -64,7 +64,7 @@ public class NikonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6464 {
6565 this.activity = context;
6666 commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT);
67- liveViewControl = new NikonLiveViewControl(context, this, 20);
67+ liveViewControl = new NikonLiveViewControl(context, this, 40);
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 (5);
73+ return (1);
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
@@ -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 = true;
37+ private boolean isDumpLog = false;
3838
3939 public NikonLiveViewControl(@NonNull Activity context, @NonNull IPtpIpInterfaceProvider interfaceProvider, int delayMs)
4040 {
@@ -60,7 +60,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
6060 Log.v(TAG, " startLiveView() ");
6161 try
6262 {
63- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 20, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
63+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 30, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
6464 }
6565 catch (Exception e)
6666 {
@@ -102,7 +102,7 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
102102 if (!commandIssued)
103103 {
104104 commandIssued = true;
105- commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 30, isDumpLog));
105+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 65, isDumpLog));
106106 }
107107 try
108108 {
@@ -254,11 +254,11 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
254254 Log.v(TAG, String.format(" OK REPLY (ID : %d) ", id));
255255 if (id == SEQ_START_LIVEVIEW)
256256 {
257- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 20, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
257+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
258258 }
259259 else if (id == SEQ_DEVICE_READY)
260260 {
261- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 20, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
261+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
262262 }
263263 else
264264 {
@@ -278,15 +278,15 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
278278 {
279279 if (id == SEQ_START_LIVEVIEW)
280280 {
281- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 20, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
281+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 30, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
282282 }
283283 else if (id == SEQ_DEVICE_READY)
284284 {
285- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 20, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
285+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
286286 }
287287 else
288288 {
289- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 20, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
289+ commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
290290 }
291291 }
292292 catch (Exception e)
--- 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
@@ -19,7 +19,7 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
1919 private int received_total_bytes = 0;
2020 private int received_remain_bytes = 0;
2121
22- private int target_image_size = 0;
22+ //private int target_image_size = 0;
2323 private boolean receivedFirstData = false;
2424 private ByteArrayOutputStream byteStream;
2525
@@ -90,7 +90,8 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
9090 {
9191 body_length = rx_body.length;
9292 }
93- Log.v(TAG, " receivedMessage_multi() id[" + id + "] size : " + body_length + " target length : " + target_image_size + " ");
93+ Log.v(TAG, " receivedMessage_multi() id[" + id + "] size : " + body_length + " ");
94+ //Log.v(TAG, " receivedMessage_multi() id[" + id + "] size : " + body_length + " target length : " + target_image_size + " ");
9495
9596 // end of receive sequence.
9697 //byte [] thumbnail = byteStream.toByteArray();
@@ -98,12 +99,12 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
9899 //Log.v(TAG, " TransferComplete() RECEIVED id[" + id + "] size : " + target_image_size + " (" + thumbnail.length + ")");
99100 //SimpleLogDumper.dump_bytes(" [xxxxx]", Arrays.copyOfRange(thumbnail, 0, (512)));
100101 //SimpleLogDumper.dump_bytes(" [zzzzz]", Arrays.copyOfRange(thumbnail, (thumbnail.length - 128), (thumbnail.length)));
101- callback.onCompleted(byteStream.toByteArray(), null);
102102 //callback.onCompleted(rx_body, null);
103+ callback.onCompleted(byteStream.toByteArray(), null);
103104 receivedFirstData = false;
104105 received_remain_bytes = 0;
105106 received_total_bytes = 0;
106- target_image_size = 0;
107+ //target_image_size = 0;
107108 byteStream.reset();
108109 }
109110 catch (Exception e)
@@ -155,7 +156,8 @@ public class NikonLiveViewImageReceiver implements IPtpIpCommandCallback
155156 int body_size = (rx_body[data_position] & 0xff) + ((rx_body[data_position + 1] & 0xff) << 8) + ((rx_body[data_position + 2] & 0xff) << 16) + ((rx_body[data_position + 3] & 0xff) << 24);
156157 if (body_size <= 12)
157158 {
158- Log.v(TAG, " --- BODY SIZE IS SMALL : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] " + rx_body.length + " (" + target_image_size + ")");
159+ Log.v(TAG, " ----- BODY SIZE IS SMALL : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] " + rx_body.length + " ");
160+ //Log.v(TAG, " --- BODY SIZE IS SMALL : " + data_position + " (" + body_size + ") [" + received_remain_bytes + "] " + rx_body.length + " (" + target_image_size + ")");
159161 //int startpos = (data_position > 48) ? (data_position - 48) : 0;
160162 //SimpleLogDumper.dump_bytes(" [xxx]", Arrays.copyOfRange(rx_body, startpos, (data_position + 48)));
161163 break;
--- 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,6 +4,8 @@ import android.util.Log;
44
55 import androidx.annotation.NonNull;
66
7+import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
8+
79 import java.io.BufferedReader;
810 import java.io.ByteArrayOutputStream;
911 import java.io.DataOutputStream;
@@ -472,7 +474,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
472474 if (read_bytes < 0)
473475 {
474476 // リトライオーバー...
475- Log.v(TAG, " RECEIVE : RETRY OVER......");
477+ Log.v(TAG, " RECEIVE : RETRY OVER...... : " + delayMs + "ms x " + command.maxRetryCount());
476478 if (command.isRetrySend())
477479 {
478480 // 要求を再送する場合、、、ダメな場合は受信待ちとする
@@ -480,23 +482,34 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
480482 }
481483 }
482484
483- // 初回データの読み込み
484- read_bytes = is.read(byte_array, 0, receive_message_buffer_size);
485- int target_length = parseDataLength(byte_array, read_bytes);
486- int received_length = read_bytes;
485+ boolean read_retry = false;
486+ int target_length = 0;
487+ int received_length = 0;
487488
488- if (target_length <= 0)
489+ do
489490 {
490- // 受信サイズ異常の場合...
491- Log.v(TAG, " WRONG LENGTH. : " + target_length);
492- callback.receivedMessage(id, null);
493- return (false);
494- }
491+ // 初回データの読み込み...
492+ read_bytes = is.read(byte_array, 0, receive_message_buffer_size);
493+ target_length = parseDataLength(byte_array, read_bytes);
494+ received_length = read_bytes;
495+ if (target_length <= 0)
496+ {
497+ // 受信サイズ異常の場合...
498+ if (received_length > 0)
499+ {
500+ SimpleLogDumper.dump_bytes("WRONG DATA : ", Arrays.copyOfRange(byte_array, 0, (Math.min(received_length, 64))));
501+ }
502+ Log.v(TAG, " WRONG LENGTH. : " + target_length + " READ : " + received_length + " bytes.");
503+ callback.receivedMessage(id, null);
504+ return (false);
505+ }
506+
507+ } while (read_retry);
495508
496509 // 一時的な処理
497510 if (callback != null)
498511 {
499- Log.v(TAG, " --- 1st CALL : read_bytes : "+ read_bytes + "(" + received_length + ") : target_length : " + target_length + " buffer SIZE : " + byte_array.length);
512+ Log.v(TAG, " -=-=-=- 1st CALL : read_bytes : "+ read_bytes + "(" + received_length + ") : target_length : " + target_length + " buffer SIZE : " + byte_array.length);
500513 callback.onReceiveProgress(received_length, target_length, Arrays.copyOfRange(byte_array, 0, received_length));
501514 }
502515
@@ -568,16 +581,26 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
568581
569582 private int parseDataLength(byte[] byte_array, int read_bytes)
570583 {
584+ int offset = 0;
571585 int lenlen = 0;
572586 //int packetType = 0;
573587 try
574588 {
575- if ((read_bytes > 20)&&((int) byte_array[4] == 0x09))
589+ if (read_bytes > 20)
576590 {
577- lenlen = ((((int) byte_array[15]) & 0xff) << 24) + ((((int) byte_array[14]) & 0xff) << 16) + ((((int) byte_array[13]) & 0xff) << 8) + (((int) byte_array[12]) & 0xff);
578- //packetType = (((int)byte_array[16]) & 0xff);
591+ if ((int) byte_array[offset + 4] == 0x07)
592+ {
593+ // 前の応答が入っていると考える...
594+ offset = 14;
595+ }
596+
597+ if (((int) byte_array[offset + 4] == 0x09))
598+ {
599+ lenlen = ((((int) byte_array[offset + 15]) & 0xff) << 24) + ((((int) byte_array[offset + 14]) & 0xff) << 16) + ((((int) byte_array[offset + 13]) & 0xff) << 8) + (((int) byte_array[offset + 12]) & 0xff);
600+ //packetType = (((int)byte_array[offset + 16]) & 0xff);
601+ }
579602 }
580- //Log.v(TAG, " --- parseDataLength() length: " + lenlen + " TYPE: " + packetType + " read_bytes: " + read_bytes);
603+ //Log.v(TAG, " --- parseDataLength() length: " + lenlen + " TYPE: " + packetType + " read_bytes: " + read_bytes + " offset : " + offset);
581604 }
582605 catch (Exception e)
583606 {
@@ -624,7 +647,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
624647 Log.v(TAG, " <><><> PACKET TYPE : " + packetType + " LENGTH : " + lenlen);
625648 }
626649 */
627- int copyByte = ((lenlen - 12) > (limit - (position + 12))) ? (limit - (position + 12)) : (lenlen - 12);
650+ int copyByte = Math.min((limit - (position + 12)), (lenlen - 12));
628651 outputStream.write(byte_array, (position + 12), copyByte);
629652 position = position + lenlen;
630653 }
@@ -648,7 +671,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
648671 {
649672 sleep(delayMs);
650673 read_bytes = is.available();
651- if (read_bytes == 0)
674+ if (read_bytes <= 0)
652675 {
653676 if (isLogOutput)
654677 {
Show on old repository browser