diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs
index ed59347..5f68adb 100644
--- a/ISCamRecorder/MainForm.cs
+++ b/ISCamRecorder/MainForm.cs
@@ -286,9 +286,15 @@
_Cameras.ForEach(c => c.StartRecoding());
_Sensor.StartRecoding(TxtSubjectName.Text);
_Sounds[0].Play();
+ _Sensor.SendSignal('1'); // Vicon同期信号 on
+ Thread.Sleep(100);
+ _Sensor.SendSignal('0'); // Vicon同期信号 off
// 録画終了待機
Task.WaitAll(tasks);
+ _Sensor.SendSignal('1'); // Vicon同期信号 on
+ Thread.Sleep(100);
+ _Sensor.SendSignal('0'); // Vicon同期信号 off
// 保存準備
_Sounds[1].Play();
diff --git a/ISCamRecorder/SensorData.cs b/ISCamRecorder/SensorData.cs
index e1666b9..f5faca7 100644
--- a/ISCamRecorder/SensorData.cs
+++ b/ISCamRecorder/SensorData.cs
@@ -102,8 +102,10 @@
if (_Serial != null) {
var str = _Serial.ReadLine();
var strs = str.Split(',');
- if (strs.Length >= 4) {
+ if (strs.Length == 5) {
values = strs.Select(s => int.Parse(s)).ToArray();
+ } else {
+ values[0] = values[1] = values[2] = values[3] = 0;
}
} else {
Thread.Sleep(50); // センサー未接続時の時間調整
@@ -273,6 +275,16 @@
}
///
+ /// シリアルポートに1文字送信
+ ///
+ ///
+ public void SendSignal(char c) {
+ if (_Serial != null) {
+ _Serial.Write(new char[] { c }, 0, 1);
+ }
+ }
+
+ ///
/// シリアルポート取得
///
///
diff --git a/PhotoReflectorIF/PhotoReflectorIF.ino b/PhotoReflectorIF/PhotoReflectorIF.ino
index a3a9a78..e36eec1 100644
--- a/PhotoReflectorIF/PhotoReflectorIF.ino
+++ b/PhotoReflectorIF/PhotoReflectorIF.ino
@@ -67,7 +67,12 @@
Wire.endTransmission();//I2Cスレーブ データ送信終了
sw = digitalRead(SW_PIN);
- digitalWrite(SYNC_OUT_PIN, 1 - sw);
+ while (Serial.available() > 0) {
+ char c = Serial.read();
+ if (c == '0') digitalWrite(SYNC_OUT_PIN, 0);
+ if (c == '1') digitalWrite(SYNC_OUT_PIN, 1);
+ }
+ // digitalWrite(SYNC_OUT_PIN, 1 - sw);
Serial.print(blue);//「blue」をシリアルモニタに送信
Serial.print(",");//文字列「,」をシリアルモニタに送信