I'm using the below code to receive the messages using serial port event handler. But it dosent receives any.I am not getting errors. The code breaks in "string msg = comport.Readline()
" Am i doing something wrong ?
public partial class SerialPortScanner : Form
{
private SerialPort comPort = new SerialPort();
public SerialPortScanner()
{
InitializeComponent();
comPort.Open();
comPort.DataReceived += new SerialDataReceivedEventHandler(comPort_DataReceived);
}
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (comPort.IsOpen == true)
{
string msg = comPort.ReadLine();
MessageBox.Show(msg);
}
}
}