Need help reading data from serial port please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use code below to read data form the port. I know it is not
correct but I am not finding what I need in MSDN to help me.

private void serialPort1_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
string getRelayStates;
getRelayStates = serialPort1.ReadLine();
MessageBox.Show(getRelayStates);

Any ideas?
thanks
 
CMartin,

Well, you are trying to read an entire line, but when the DataReceived
event is fired, it isn't guaranteed that an entire line is available. Can
you read one character at a time?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top