title: Get Weight From Weigh Bridge Machine Using Serial Port in C#
body: <p>i am develop application for getting weight from weigh Bridge machine using C#.Net.i am trying lot of ways but,doesn't read correct data format weight from weigh bridge machine.i am getting ouput like <code>?x???????x?x?x??x???x??x???x???x?</code> continuously get from serial port.i want to get weight from weigh bridge machine my code is listed below:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.IO.Ports;
  using System.IO;
  
  namespace SerialPortTest
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          String a = "";
  
          private void button1_Click(object sender, EventArgs e)
          {
          serialPort1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
           serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
  
          if (serialPort1.IsOpen == false)
          {
              serialPort1.Open();
          }
          timer1.Start();
          button1.Enabled = false;
          button2.Enabled = true;
          }
  
          private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
          {
              a = a + serialPort1.ReadExisting();
          }
  
          private void timer1_Tick(object sender, EventArgs e)
          {
              if (a.Length != 0)
              {
                  textBox1.AppendText(a);
                  a = "";
              }
          }
  
          private void button2_Click(object sender, EventArgs e)
          {
              if (serialPort1.IsOpen == true)
              {
                  serialPort1.Close();
                  button2.Enabled = false;
                  button1.Enabled = true;
              }
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              if (serialPort1.IsOpen == true)
              {
                  button1.Enabled = false;
                  button2.Enabled = true;
              }
              else
              {
                  button1.Enabled = true;
                  button2.Enabled = false;
              }
          }
      }
  }
  </code></pre>
  
  <p>my code is append text from serial port data to textbox but,it's shows only like <code>?xxx?xxxx?xxxx?</code></p>
  
  <p>can any one help me how to get weight from serial port using c#</p>
  
  <p>Thanks For Reading My Post!</p>