少し問題があります。COMポートからデータを読み取ろうとすると、次のような「不良」データを受け取ります。
0 Fl- 1 i 2 3?4メートル?5 6 7 8 9 10?11 12 13 d 14 D 15
ポートを開くコードは次のとおりです。
_port = new SerialPort(Settings.Default.COM, 9600, Parity.None, 8, StopBits.One);
_port.DataReceived += PortDataReceived;
_port.Open();
データを読み取るコードは次のとおりです。
private void PortDataReceived(object sender, SerialDataReceivedEventArgs e)
{
string s = _port.ReadExisting();
_reportBuffer = _reportBuffer + s;
_counter++;
if (_counter == _messageLength)
{
//action
}
}
どんなアイデアでも大歓迎です!前もって感謝します!