読むシリアルポート体重枢機卿規模、C#の私は自分のコンピュータへのインジケータのデータを表示することができました210
出力ルックのような、この
「[SPACE] [SPACE] 978 0キロ」
[SPACE]は(空の)スペース、テキスト、私は数字だけを表示したい
、ある
次のスクリプトを使用します。最後の数字のゼロが入力されていません
private delegate void Closure();
private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
{
if (InvokeRequired) //<-- Makes sure the function is invoked to work properly in the UI-Thread
BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); })); //<-- Function invokes itself
else
{
while (_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
{
String tampung = _serialPort.ReadExisting();
Regex regex = new Regex(@"[^\d|\.]");
tampung = regex.Replace(tampung, "");
textBox1.Text += string.Format("{0:X2} ", tampung);
}
}
}
が、それは不完全な数字を表示し、
出力:
私はインジケータをhttp://www.cardinalscale.com/cs_product/210-storm/
が使用しています何か間違っている?