I'm currently working with 4 devices:
- 1 Flow Meter
- 3 Particle Counter
- 1 Analog/Digital Converter
- and 1 USB/RS485 Converter.
The Flow Meter is connected to Analog/Digital Converter; Analog/Digital Converter and the 3 Particle Counter is connected to USB/RS485 Converter. I've using serialPort1 and written a small method to read the SerialPort.
The SerialPort being read!
But unfortunately, I need to separate the string the get Particles Counters. The devices send the string in this format: ?01,00000,00000,00000,n/a,n/a I try to capture the string to separate in the commas, however so capture the end of the string or "n/a".
How to capture the entire string to variable and treat this variable in another method?
My method:
private void serialPort1_DataReceived(object sender,System.IO.Ports.SerialDataReceivedEventArgs e)
{
if(serialPort1.DataBits==8)
{
RxString=serialPort1.ReadExisting();
this.Invoke(new EventHandler(DisplayText));
}
}
private void DisplayText(object sender,EventArgs e)
{
textBox1.AppendText(RxString);
}