ahmed sa

ahmed sa

  • NA
  • 289
  • 128.5k

Recieve Data From Serial Port In One Line And Convert intege

Mar 11 2014 3:09 AM
Hi guys i have problem i make code that take data from serial com port for weighting machine
it is ok working but it recieve data in more lines.I try to make it receive data in one line
In code below i need to take weight fro weight bridge machine automatically by timer in visual studio 2005.it works but receive weight values in more lines.
I need to receive weight in one line and automatically updated then convert  to integer

  • void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
  • {
  • if (!InvokeRequired)
  • {
  • if (e.EventType == SerialData.Chars)
  • {
  • string portData = serialPort1.ReadExisting();
  • textBox2.AppendText(portData);
  • }
  • }
  • else
  • {
  • SerialDataReceivedEventHandler invoker = new SerialDataReceivedEventHandler(serialPort1_DataReceived);
  • BeginInvoke(invoker, new object[] { sender, e });
  • }
  • }

  • Attachment: commsample.zip

    Answers (43)