Iqrar Ali

Iqrar Ali

  • NA
  • 259
  • 2.9k

wrong data coming from LIS analyzer abacus diatron 380

Mar 27 2018 11:24 PM
i have below code when i execute the machine, the machine returns "q?". which is not suitable that i want from machine. what i do please please help....
  1. public void SettingRS232()  
  2. {  
  3.     try  
  4.     {  
  5.         serialPort1.PortName = comportName.Text;  
  6.         serialPort1.BaudRate = Convert.ToInt32(combaudrate.Text);  
  7.         serialPort1.DataBits = Convert.ToInt32(comdatabits.Text);  
  8.         serialPort1.StopBits = (StopBits)Enum.Parse(typeof(StopBits), comstopBits.Text);  
  9.         serialPort1.Parity = (Parity)Enum.Parse(typeof(Parity), comparityBits.Text);  
  10.         serialPort1.Handshake = (Handshake)Enum.Parse(typeof(Handshake), comparityBits.Text);  
  11.         serialPort1.ReadTimeout = 2000;  
  12.         serialPort1.WriteTimeout = 500;  
  13.   
  14.         serialPort1.DtrEnable = true;  
  15.         serialPort1.RtsEnable = true;  
  16.   
  17.         serialPort1.Open();  
  18.   
  19.         serialPort1.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);  
  20.         lblstatus.Text = "Port is now ready...";  
  21.   
  22.     }  
  23.     catch (Exception ex)  
  24.     {  
  25.         lblstatus.Text = ex.Message;  
  26.     }  
  27. }  
  28. public void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)  
  29. {  
  30.     SerialPort sp = (SerialPort)sender;  
  31.     string indata = sp.ReadExisting();  
  32.   
  33.     this.Invoke(new Action(delegate() { richTextBox1.Text = indata; }));  
  34. private void btnStart_Click(object sender, EventArgs e)  
  35. {  
  36.     if (serialPort1.IsOpen)  
  37.     {  
  38.     }  
  39.     else  
  40.     {  
  41.          btnStart.BackColor = Color.Green;  
  42.          SettingRS232();  
  43.          btnStop.BackColor = default(Color);  
  44.     }  
  45. }

Attachment: is.rar