diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index 56ce675..65f1bb6 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -139,7 +139,8 @@ /// シリアル通信スレッド /// private void SerialThread() { - if (!_Sensor.Connect()) return; + //if (!_Sensor.Connect()) return; + _Sensor.Connect(); _Sensor.Loop(); } diff --git a/ISCamRecorder/SensorData.cs b/ISCamRecorder/SensorData.cs index c1ff9af..14aeca3 100644 --- a/ISCamRecorder/SensorData.cs +++ b/ISCamRecorder/SensorData.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Threading; using System.IO.Ports; using System.Management; using System.Diagnostics; @@ -90,10 +90,16 @@ while (_MF.State != STATE.Exit) { // データ受信 - var str = _Serial.ReadLine(); - var strs = str.Split(','); - if (strs.Length < 5) continue; - var values = strs.Select(s => int.Parse(s)).ToArray(); + var values = new int[] { 60, 80, 100, 20, 0 }; + if (_Serial != null) { + var str = _Serial.ReadLine(); + var strs = str.Split(','); + if (strs.Length >= 4) { + values = strs.Select(s => int.Parse(s)).ToArray(); + } + } else { + Thread.Sleep(50); + } // ボタン状態 var buttonState = (1 - values[4]);