import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGenericWithRetry;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.REQUEST_SHUTTER_ON;
Log.v(TAG, " doCapture() ");
// シャッターを切る
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, REQUEST_SHUTTER_ON, isDumpLog, 0, 0x9207, 8, 0xffffffff, 0x00));
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, isDumpLog, 0, 0x90c8));
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_EVENT, isDumpLog, 0, 0x90c7));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, REQUEST_SHUTTER_ON, 50, 300, false, isDumpLog, 0, 0x9207, 8, 0xffffffff, 0x00, 0, 0));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_DEVICE_READY, 50, 300, false, isDumpLog, 0, 0x90c8, 0, 0, 0, 0, 0));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, SEQ_GET_EVENT, 50, 300, false, isDumpLog, 0, 0x90c7, 0, 0, 0, 0, 0));
}
catch (Exception e)
{
import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGenericWithRetry;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
try
{
Log.v(TAG, " Unlock AF ");
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_UNLOCK, isDumpLog, 0, 0x9206));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_UNLOCK, 30, 100, false, isDumpLog, 0, 0x9206, 0, 0, 0, 0, 0));
}
catch (Exception e)
{
public void halfPressShutter(boolean isPressed)
{
//unlockAutoFocus();
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 250, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
//lockAutoFocus(new PointF(0.5f, 0.5f));
}
int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1));
Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
if (!not_support_focus_lock) {
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_LOCK, 30, 250, false, isDumpLog, 0, 0x9205, 8, x, y, 0, 0));
} else {
- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
+ commandPublisher.enqueueCommand(new PtpIpCommandGenericWithRetry(this, FOCUS_MOVE, 30, 250, false, isDumpLog, 0, 0x90c1, 0, 0, 0, 0, 0));
}
}
catch (Exception e)
{
try
{
+ if (rx_body == null)
+ {
+ Log.v(TAG, " RECEIVED BODY IS NULL.");
+ return;
+ }
+
if (rx_body.length < 10)
{
Log.v(TAG, " --- BODY LENGTH IS SHORT : FOCUS OPERATION ---");
socket?.tcpNoDelay = tcpNoDelay
if (tcpNoDelay)
{
+ socket?.tcpNoDelay = true
//socket?.keepAlive = false
socket?.keepAlive = false
//socket?.setPerformancePreferences(0, 1, 2)
- //socket?.setPerformancePreferences(0, 2, 0)
+ socket?.setPerformancePreferences(0, 1, 2)
//socket?.setPerformancePreferences(0, 1, 2)
//socket?.setPerformancePreferences(1, 0, 0)
//socket?.setPerformancePreferences(0, 0, 2)
socket?.trafficClass = 0x80 // 0x80
//socket?.soTimeout = 800
socket?.soTimeout = 0
- //socket?.receiveBufferSize = 8192 // 49152 // 65536 // 32768
- //socket?.sendBufferSize = 8192 // 2048 // 1024 // 2048
+ //socket?.receiveBufferSize = 8192 // 10240 // 16384 // 6144// 8192 // 49152 // 65536 // 32768
+ //socket?.sendBufferSize = 8192 // 4096 // 2048 // 10248
socket?.setSoLinger(true, 3000);
//socket?.setReceiveBufferSize(2097152);
//socket?.setSendBufferSize(524288);
if (readBytes <= 0)
{
// リトライオーバー...
- Log.v(TAG, " RECEIVE : RETRY OVER...")
+ Log.v(TAG, " RECEIVE : RETRY OVER...... : $delayMs ms x ${command.maxRetryCount()} SEQ: $sequenceNumber isRetry: ${command.isRetrySend}")
if (!command.isRetrySend)
{
// 再送しない場合には、応答がないことを通知する
receivedAllMessage(isDumpReceiveLog, id, null, callback)
+ return (false)
}
return (true)
}
if (readBytes <= 0)
{
// リトライオーバー...
- Log.v(TAG, " RECEIVE : RETRY OVER...... : " + delayMs + "ms x " + command.maxRetryCount() + " SEQ: $sequenceNumber")
+ Log.v(TAG, " RECEIVE : RETRY OVER...... : $delayMs ms x ${command.maxRetryCount()} SEQ: $sequenceNumber ")
if (command.isRetrySend)
{
// 要求を再送する場合、、、ダメな場合は受信待ちとする
--- /dev/null
+package net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages
+
+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback
+
+
+class PtpIpCommandGenericWithRetry(private val callback: IPtpIpCommandCallback, private val id: Int, private val delayMs: Int, private val retryCount: Int, private val isRetry: Boolean, private val isDumpLog: Boolean, private val holdId: Int, opcode: Int, private val bodySize: Int, value: Int, value2: Int = 0, value3: Int = 0, value4: Int = 0) : PtpIpCommandBase()
+{
+ private val opCode0: Byte = (0x000000ff and opcode).toByte()
+ private val opCode1: Byte = (0x0000ff00 and opcode shr 8).toByte()
+ private val data0: Byte = (0x000000ff and value).toByte()
+ private val data1: Byte = (0x0000ff00 and value shr 8).toByte()
+ private val data2: Byte = (0x00ff0000 and value shr 16).toByte()
+ private val data3: Byte = (-0x1000000 and value shr 24).toByte()
+ private val data4: Byte = (0x000000ff and value2).toByte()
+ private val data5: Byte = (0x0000ff00 and value2 shr 8).toByte()
+ private val data6: Byte = (0x00ff0000 and value2 shr 16).toByte()
+ private val data7: Byte = (-0x1000000 and value2 shr 24).toByte()
+ private val data8: Byte = (0x000000ff and value3).toByte()
+ private val data9: Byte = (0x0000ff00 and value3 shr 8).toByte()
+ private val dataA: Byte = (0x00ff0000 and value3 shr 16).toByte()
+ private val dataB: Byte = (-0x1000000 and value3 shr 24).toByte()
+ private val dataC: Byte = (0x000000ff and value4).toByte()
+ private val dataD: Byte = (0x0000ff00 and value4 shr 8).toByte()
+ private val dataE: Byte = (0x00ff0000 and value4 shr 16).toByte()
+ private val dataF: Byte = (-0x1000000 and value4 shr 24).toByte()
+
+ override fun responseCallback(): IPtpIpCommandCallback {
+ return callback
+ }
+
+ override fun getId(): Int {
+ return id
+ }
+
+ override fun estimatedReceiveDataSize(): Int {
+ return -1
+ }
+
+ override fun commandBody(): ByteArray {
+ return if (bodySize == 2) {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data ...
+ data0, data1)
+ } else if (bodySize == 4) {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data ...
+ data0, data1, data2, data3)
+ } else if (bodySize == 8) {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data ...
+ data0, data1, data2, data3,
+ data4, data5, data6, data7)
+ } else if (bodySize == 12) {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data ...
+ data0, data1, data2, data3,
+ data4, data5, data6, data7,
+ data8, data9, dataA, dataB)
+ } else if (bodySize == 16) {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data ...
+ data0, data1, data2, data3,
+ data4, data5, data6, data7,
+ data8, data9, dataA, dataB,
+ dataC, dataD, dataE, dataF)
+ } else // ボディ長が 2, 4, 8, 12 以外の場合... (ボディなし)
+ {
+ byteArrayOf( // packet type
+ 0x06.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // data phase info
+ 0x01.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), // operation code
+ opCode0, opCode1, // sequence number
+ 0x00.toByte(), 0x00.toByte(), 0x00.toByte(), 0x00.toByte())
+ }
+ }
+
+ override fun receiveDelayMs(): Int {
+ return delayMs
+ }
+
+ override fun getHoldId(): Int {
+ return holdId
+ }
+
+ override fun maxRetryCount(): Int {
+ return retryCount
+ }
+
+ override fun isRetrySend(): Boolean {
+ return isRetry
+ }
+
+ override fun dumpLog(): Boolean {
+ return isDumpLog
+ }
+}