No data while Reading Data from weight machine in RS-232 Serial Port Communication in xamarin.forms

balachandarreddyibalachandarreddyi Member
edited January 23 in Xamarin.Forms

Hi , i am trying to read data from weigh machine using RS-232 serial port communication in xamarin.forms .While reading data i am getting null data , can any one help me out of this
Here is my code,
// Getting port open here
if (srport != null)
if (srport.IsOpen)
srport.Close();
srport = new SerialPort("COM1", 9600,Parity.None,8,StopBits.One);
var str =srport.Open();
Console.WriteLine(str);
if (srport.IsOpen)
{
srport.ReadTimeout = 5000;
ReadData();
}

// Reading Data here
public string ReadData()
{
byte tmpByte;
string rxString ="";
string lineReadIn="";

            while (srport.BytesToRead > 0)
            {
                lineReadIn += srport.ReadExisting();
               Thread.Sleep(100);
            }
          return lineReadIn;
        }

Thankyou in advance

Sign In or Register to comment.