2
Answers

Read SerialPort

soumya p n

soumya p n

16y
3.1k
1
Hello everyone,
I have a problem with reading SerialPort data.My code goes like this:
SerialPort sp = new SerialPort("COM3",9600,Parity.None,8,StopBits.One);
            sp.Open();
            sp.DtrEnable = true;
            sp.RtsEnable = true;    
            //byte[] data = new byte[sp.BytesToRead];
           //  int i = sp.Read(data, 0, data.Length);
            string val = sp.ReadExisting();
            textBox1.Text = sp.ReadExisting();
            sp.Close();
But it returns me thing.Output is just empty.
What would be the problem??
Thanks in advance,
Soumya
Answers (2)