• R/O
  • HTTP
  • SSH
  • HTTPS

FujiCam: Commit

Fujifilm X Series Remote Control for Android (Prototype)

Fujifilm Xシリーズカメラの遠隔操作アプリ for Android (プロトタイプ)


Commit MetaInfo

Revisão772a4dbd7cbc404ee82d1d939717555bda3cb295 (tree)
Hora2019-05-26 22:40:01
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

なんとなく問題点を明らかにする。(通信回り)

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java
@@ -17,7 +17,7 @@ public class InformationView extends AppCompatImageView
1717 private final String TAG = toString();
1818 private Point focusPoint;
1919 private int sd_remain_size;
20- private String shooting_mode;
20+ private String shooting_mode = null;
2121 private boolean focus_lock;
2222 private boolean isDeviceError;
2323 private int battery_level;
@@ -76,6 +76,15 @@ public class InformationView extends AppCompatImageView
7676 framePaint.setColor(Color.WHITE);
7777 framePaint.setTextSize(24);
7878
79+
80+ if (shooting_mode == null)
81+ {
82+ String message = "NOT CONNECTED";
83+ canvas.drawText(message, centerX, centerY, framePaint);
84+ Log.v(TAG, message);
85+ return;
86+ }
87+
7988 String message = shooting_mode + " REMAIN : " + sd_remain_size + " ISO : " + iso + " BATT: ";
8089 if (battery_level < 0)
8190 {
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Communication.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Communication.java
@@ -143,6 +143,7 @@ class Communication
143143 {
144144 try
145145 {
146+ Thread.sleep(50);
146147 byte[] byte_array = new byte[BUFFER_SIZE];
147148 InputStream is = socket.getInputStream();
148149 if (is != null)
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Connection.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Connection.java
@@ -57,8 +57,7 @@ public class Connection implements IFujiStatusRequest
5757
5858 comm.send_to_camera(sequence.registration_message(), false, false);
5959 rx_bytes = comm.receive_from_camera();
60- dump_bytes(0, rx_bytes);
61- Thread.sleep(50);
60+ dump_bytes("Connect", 0, rx_bytes);
6261
6362 // 応答エラーかどうかをチェックする
6463 if (rx_bytes.getData().length == 8)
@@ -76,67 +75,72 @@ public class Connection implements IFujiStatusRequest
7675 // start_messageを送信
7776 comm.send_to_camera(sequence.start_message(), true, true);
7877 rx_bytes = comm.receive_from_camera();
79- dump_bytes(1, rx_bytes);
80- Thread.sleep(50);
78+ dump_bytes("Connect", 1, rx_bytes);
8179
8280 // なんだろう?? (送信が必要なようだが)
8381 comm.send_to_camera(sequence.start_message2(), true, true);
8482 rx_bytes = comm.receive_from_camera();
85- dump_bytes(2, rx_bytes);
86- Thread.sleep(50);
87-
88- // two_part messageを発行 (その1)
89- comm.send_to_camera(sequence.start_message3_1(), true, true);
90- rx_bytes = comm.receive_from_camera();
91- dump_bytes(3, rx_bytes);
92- Thread.sleep(50);
93-
94- if (rx_bytes.getData().length <= 50)
83+ dump_bytes("Connect", 2, rx_bytes);
84+ byte[] rx_data1 = rx_bytes.getData();
85+ if (rx_data1.length == (int)rx_data1[0])
9586 {
96- // two_part messageを発行 (その2)
97- comm.send_to_camera(sequence.start_message3_2(), false, false);
87+ //// もう一度受信する...
9888 rx_bytes = comm.receive_from_camera();
99- dump_bytes(4, rx_bytes);
100- Thread.sleep(50);
89+ dump_bytes("Connect",99, rx_bytes);
10190 }
10291
92+ // two_part messageを発行
93+ comm.send_to_camera(sequence.start_message3_1(), true, false);
94+ comm.send_to_camera(sequence.start_message3_2(), true, true);
95+
96+ rx_bytes = comm.receive_from_camera();
97+ dump_bytes("Connect", 3, rx_bytes);
98+
10399 // remote mode
104100 comm.send_to_camera(sequence.start_message4(), true, true);
105101 rx_bytes = comm.receive_from_camera();
106- dump_bytes(5, rx_bytes);
107- Thread.sleep(50);
102+/*
103+ dump_bytes("Connect", 4, rx_bytes);
104+ rx_data1 = rx_bytes.getData();
105+ if (rx_data1[4] == (byte) 0x02)
106+ {
107+ //// 受信データが分割されている、、もう一度受信する
108+ rx_bytes = comm.receive_from_camera();
109+ dump_bytes("Connect", 98, rx_bytes);
110+ }
111+*/
108112
109113 if (!isBothLiveView)
110114 {
111- // two_part messageを発行 (その1)
115+ // two_part messageを発行
112116 comm.send_to_camera(sequence.start_message5_1(), true, false);
113- rx_bytes = comm.receive_from_camera();
114- dump_bytes(6, rx_bytes);
115- Thread.sleep(50);
116-
117- // two_part messageを発行 (その2)
118117 comm.send_to_camera(sequence.start_message5_2(), true, true);
119118 rx_bytes = comm.receive_from_camera();
120- dump_bytes(7, rx_bytes);
121- Thread.sleep(50);
119+ dump_bytes("Connect", 5, rx_bytes);
122120
123121 // ????
124- comm.send_to_camera(sequence.start_message6(), true, true);
122+ comm.send_to_camera(sequence.status_request_message(), true, true);
125123 rx_bytes = comm.receive_from_camera();
126- dump_bytes(8, rx_bytes);
127- Thread.sleep(50);
124+ dump_bytes("Connect", 6, rx_bytes);
125+ rx_data1 = rx_bytes.getData();
126+ if (rx_data1[4] == (byte) 0x02)
127+ {
128+ //// 受信データが分割されている場合、、もう一度受信する
129+ rx_bytes = comm.receive_from_camera();
130+ dump_bytes("Connect", 97, rx_bytes);
131+ }
128132
129133 // ????
130134 comm.send_to_camera(sequence.query_camera_capabilities(), true, true);
131135 rx_bytes = comm.receive_from_camera();
132- dump_bytes(9, rx_bytes);
133- Thread.sleep(50);
136+ dump_bytes("Connect", 7, rx_bytes);
134137
138+ /*
135139 // ????
136- comm.send_to_camera(sequence.start_message8(), true, true);
140+ comm.send_to_camera(sequence.status_request_message(), true, true);
137141 rx_bytes = comm.receive_from_camera();
138- dump_bytes(10, rx_bytes);
139- Thread.sleep(50);
142+ dump_bytes("Connect", 8, rx_bytes);
143+*/
140144 }
141145
142146 // リモート制御の開始!
@@ -144,12 +148,10 @@ public class Connection implements IFujiStatusRequest
144148
145149 // 応答OKの場合は、8バイト ({0x03, 0x00, 0x01, 0x20} + {0x10, 0x02, 0x00, 0x00} )が応答されるはず
146150 rx_bytes = comm.receive_from_camera();
147- dump_bytes(11, rx_bytes);
148- Thread.sleep(150);
149-
151+ dump_bytes("Connect", 9, rx_bytes);
150152
151153 // 別のポートもオープンして動作を行う。 (1500ms程度待つといけるみたいだ...)
152- Thread.sleep(2000);
154+ Thread.sleep(1500);
153155 comm.start_stream();
154156 comm.start_response();
155157
@@ -169,9 +171,8 @@ public class Connection implements IFujiStatusRequest
169171 {
170172 comm.send_to_camera(sequence.reset_message(), true, true);
171173 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
172- dump_bytes(0, rx_bytes);
174+ dump_bytes("Reset", -1, rx_bytes);
173175 statusChecker.stop();
174- Thread.sleep(150);
175176 }
176177 catch (Exception e)
177178 {
@@ -221,6 +222,7 @@ public class Connection implements IFujiStatusRequest
221222 if (pauseRequestStatus)
222223 {
223224 // ステータス更新を一時停止する。
225+ Log.v(TAG, "STATUS REQUEST IS PAUSED...");
224226 return (false);
225227 }
226228 try
@@ -232,8 +234,21 @@ public class Connection implements IFujiStatusRequest
232234 // 受信したステータス情報を渡す
233235 statusChecker.statusReceived(rx_bytes);
234236 }
235- dump_bytes(12, rx_bytes);
236-
237+ dump_bytes("Status", 1, rx_bytes);
238+/*
239+ byte[] rx_data1 = rx_bytes.getData();
240+ if (rx_data1[4] == (byte) 0x02)
241+ {
242+ //// 受信データが分割されている、、もう一度受信する
243+ rx_bytes = comm.receive_from_camera();
244+ dump_bytes("Status", 2, rx_bytes);
245+ if (rx_bytes.getData().length > 0)
246+ {
247+ // 受信したステータス情報を渡す
248+ statusChecker.statusReceived(rx_bytes);
249+ }
250+ }
251+*/
237252 return (true);
238253 }
239254 catch (Exception e)
@@ -243,9 +258,13 @@ public class Connection implements IFujiStatusRequest
243258 return (false);
244259 }
245260
246- private void dump_bytes(int indexNumber, ReceivedDataHolder data)
261+ private boolean dump_bytes(String header, int indexNumber, ReceivedDataHolder data)
247262 {
248263 int index = 0;
264+ byte[] targetData = data.getData();
265+ int receivedDataLength = targetData[0] + (targetData[1] << 8) + (targetData[2] << 16) + (targetData[3] << 24);
266+ boolean checkLength = receivedDataLength <= targetData.length;
267+ String logHead = (indexNumber < 0) ? header : header + " " + indexNumber;
249268 StringBuffer message;
250269 message = new StringBuffer();
251270 for (byte item : data.getData())
@@ -254,35 +273,36 @@ public class Connection implements IFujiStatusRequest
254273 message.append(String.format("%02x ", item));
255274 if (index >= 8)
256275 {
257- Log.v(TAG, " RX [" + indexNumber + "] " + message);
276+ Log.v(TAG, " RX [" + logHead + "] " + message);
258277 index = 0;
259278 message = new StringBuffer();
260279 }
261280 }
262281 if (index != 0)
263282 {
264- Log.v(TAG, " RX [" + indexNumber + "] " + message);
283+ Log.v(TAG, " RX [" + logHead + "] " + message);
265284 }
266- System.gc();
285+ //System.gc();
286+ return (checkLength);
267287 }
268288
269289 public boolean execute_focus_point(PointF point)
270290 {
291+ pauseRequestStatus = false;
271292 try
272293 {
273294 byte x = (byte) (0x000000ff & Math.round(point.x));
274295 byte y = (byte) (0x000000ff & Math.round(point.y));
275296 Log.v(TAG, "DRIVE AF (" + x + "," + y + ")");
276-
277297 comm.send_to_camera(sequence.execute_focus_lock(x, y), true, true);
278-
279298 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
280- dump_bytes(16, rx_bytes);
299+ dump_bytes("Focus Point", -1, rx_bytes);
281300 }
282301 catch (Exception e)
283302 {
284303 e.printStackTrace();
285304 }
305+ pauseRequestStatus = false;
286306 return (false);
287307 }
288308
@@ -332,9 +352,8 @@ public class Connection implements IFujiStatusRequest
332352 try
333353 {
334354 comm.send_to_camera(sequence.query_camera_capabilities(), true, true);
335- Thread.sleep(50);
336355 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
337- dump_bytes(21, rx_bytes);
356+ dump_bytes("Capability", -1, rx_bytes);
338357 }
339358 catch (Exception e)
340359 {
@@ -347,33 +366,35 @@ public class Connection implements IFujiStatusRequest
347366
348367 public boolean execute_unlock_focus()
349368 {
369+ pauseRequestStatus = true;
350370 try
351371 {
352372 comm.send_to_camera(sequence.execute_focus_unlock(), true, true);
353-
354373 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
355- dump_bytes(17, rx_bytes);
374+ dump_bytes("Unlock Focus", -1, rx_bytes);
356375 }
357376 catch (Exception e)
358377 {
359378 e.printStackTrace();
360379 }
380+ pauseRequestStatus = false;
361381 return (false);
362382 }
363383
364384 public boolean execute_shutter()
365385 {
386+ pauseRequestStatus = true;
366387 try
367388 {
368389 comm.send_to_camera(sequence.execute_shutter_message(), true, true);
369-
370390 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
371- dump_bytes(14, rx_bytes);
391+ dump_bytes("Shutter", -1, rx_bytes);
372392 }
373393 catch (Exception e)
374394 {
375395 e.printStackTrace();
376396 }
397+ pauseRequestStatus = false;
377398 return (false);
378399 }
379400
@@ -390,23 +411,11 @@ public class Connection implements IFujiStatusRequest
390411 byte data2 = (byte)((0x0000ff00 & setValue) >> 8);
391412 byte data3 = (byte)((0x000000ff & setValue));
392413
393- // two_part messageを発行 (その1)
414+ // two_part messageを発行
394415 comm.send_to_camera(sequence.update_property_1(high, low), true, false);
395- Thread.sleep(50);
396- rx_bytes = comm.receive_from_camera();
397- dump_bytes(19, rx_bytes);
398-/*
399- // two_part messageを発行 (その1) : ダミーでもう一発...!
400- comm.send_to_camera(sequence.update_property_1(high, low), true, false);
401- Thread.sleep(50);
402- rx_bytes = comm.receive_from_camera();
403- dump_bytes(15, rx_bytes);
404-*/
405- // two_part messageを発行 (その2)
406416 comm.send_to_camera((isShort) ? sequence.update_property_2(data2, data3) : sequence.update_property_2(data0, data1, data2, data3), true, true);
407- Thread.sleep(50);
408417 rx_bytes = comm.receive_from_camera();
409- dump_bytes(20, rx_bytes);
418+ dump_bytes("Prop", -1, rx_bytes);
410419 }
411420 catch (Exception e)
412421 {
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/MessageSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/MessageSequence.java
@@ -133,7 +133,7 @@ class MessageSequence
133133 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
134134 (byte)0x01, (byte)0x00,
135135
136- // message_header.type : single_part (0x1015) : GetDevicePropValue
136+ // message_header.type : single_part (0x1015) : 0xdf24
137137 (byte)0x15, (byte)0x10,
138138
139139 // message_id (0~1づつ繰り上がる)
@@ -151,7 +151,7 @@ class MessageSequence
151151 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
152152 (byte)0x01, (byte)0x00,
153153
154- // message_header.type : two_part (0x1016) : SetDevicePropValue
154+ // message_header.type : two_part (0x1016) : 0xdf24
155155 (byte)0x16, (byte)0x10,
156156
157157 // message_id (0~1づつ繰り上がる)
@@ -169,7 +169,7 @@ class MessageSequence
169169 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
170170 (byte)0x02, (byte)0x00,
171171
172- // message_header.type : two_part (0x1016) : SetDevicePropValue
172+ // message_header.type : two_part (0x1016) : 0x00020007
173173 (byte)0x16, (byte)0x10,
174174
175175 // message_id (0~1づつ繰り上がる...けど two-part messageなので同じ)
@@ -180,14 +180,14 @@ class MessageSequence
180180
181181 });
182182 }
183-
183+/*
184184 byte[] start_message6()
185185 {
186186 return (new byte[] {
187187 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
188188 (byte)0x01, (byte)0x00,
189189
190- // message_header.type : single_part (0x1015) : GetDevicePropValue
190+ // message_header.type : single_part (0x1015) : 0xd212 (status_request)
191191 (byte)0x15, (byte)0x10,
192192
193193 // message_id (0~1づつ繰り上がる...)
@@ -198,7 +198,7 @@ class MessageSequence
198198
199199 });
200200 }
201-
201+*/
202202
203203 byte[] query_camera_capabilities()
204204 {
@@ -215,14 +215,14 @@ class MessageSequence
215215 });
216216 }
217217
218-
218+/*
219219 byte[] start_message8()
220220 {
221221 return (new byte[] {
222222 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
223223 (byte)0x01, (byte)0x00,
224224
225- // message_header.type : single_part (0x1015) : GetDevicePropValue
225+ // message_header.type : single_part (0x1015) : 0xd212
226226 (byte)0x15, (byte)0x10,
227227
228228 // message_id (0~1づつ繰り上がる...)
@@ -233,7 +233,7 @@ class MessageSequence
233233
234234 });
235235 }
236-
236+*/
237237
238238
239239 byte[] camera_remote_message()
@@ -242,7 +242,7 @@ class MessageSequence
242242 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
243243 (byte)0x01, (byte)0x00,
244244
245- // message_header.type : camera_remote (0x101c) : InitiateOpenCapture
245+ // message_header.type : camera_remote (0x101c)
246246 (byte)0x1c, (byte)0x10,
247247
248248 // message_id (0~1づつ繰り上がる...)
@@ -263,11 +263,11 @@ class MessageSequence
263263 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
264264 (byte)0x01, (byte)0x00,
265265
266- // message_header.type : single_part (0x1015) : GetDevicePropValue
266+ // message_header.type : single_part (0x1015) : 0xd212 (status_request)
267267 (byte)0x15, (byte)0x10,
268268
269269 // message_id (0~1づつ繰り上がる...)
270- (byte)0x0A, (byte)0x00, (byte)0x00, (byte)0x00,
270+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
271271
272272 // data ...
273273 (byte)0x12, (byte)0xd2, (byte)0x00, (byte)0x00,
@@ -357,7 +357,7 @@ class MessageSequence
357357 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
358358 (byte)0x01, (byte)0x00,
359359
360- // message_header.type : aperture (0xd240)
360+ // message_header.type : shutter speed (0xd240)
361361 (byte)0x40, (byte)0xd2,
362362
363363 // message_id (0~1づつ繰り上がる...
@@ -376,7 +376,7 @@ class MessageSequence
376376 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
377377 (byte)0x01, (byte)0x00,
378378
379- // message_header.type : aperture (0x902e)
379+ // message_header.type : exprev (0x902e)
380380 (byte)0x2e, (byte)0x90,
381381
382382 // message_id (0~1づつ繰り上がる...
Show on old repository browser