المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Timeout exception when reading from serial port



C# Programming
04-01-2010, 08:15 AM
Dear all,

I got Timeout exception when reading from serial port.
how to overcome?

code:
// ports boudRate =115200, readtimeout=300 and writetimeout=300
private void btnRead_Click(object sender, EventArgs e)
{
OpenPort();
string str;
try
{
Thread.Sleep(1000);
str = _serialPort.ReadLine(); // exception occurs here

}
catch (Exception ex) { str = ex.Message; }
txtReadText.Text +=
string.Format("{0}{1}", "", str);

ClosePort();
}