Forum: µC & Digital Electronics reading from micro-controller

von (unknown) (Guest)

Rate this post
0 useful
not useful
I have a Arduino micro-controller . The micro-controller works(i have an 
app that shows me the the micro-controller 'spits' out data. The thing 
is that i have implemented some code ( from 
| https://mindmajix.com/emc-san-storage-training ) :

Here i initialize the SerialPort

_serialPort = new SerialPort("COM17", 19200, Parity.None, 8, 
_serialPort.Handshake = Handshake.None;
_serialPort.DataReceived += new 
_serialPort.ReadTimeout = 1000;
_serialPort.WriteTimeout = 1000;
And here i have the listening handler :

void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
    string data = _serialPort.ReadLine();
    this.BeginInvoke(new SetTextDeleg(si_DataReceived), new object[] { 
data });
But i get this error :The operation has timed out. at string data = 
_serialPort.ReadLine(); in the handler .

The COM port is COM17 and the port opens ( a led on the micro-controller 
shows it ). Any idea why the operation timed out ?

i.e. The program loaded into the micro-controller is set to 'shoot' data 
at 1 second.

: Moved by Moderator
von Hmmm (Guest)

Rate this post
0 useful
not useful
What do the data packets sent by the controller look like?

ReadLine() expects a newline (0x0a) character at the end of the line.

von Hmmm (Guest)

Rate this post
0 useful
not useful
And why are you spamming a totally unrelated URL to your employer's 
website? Is that how marketing works in India?


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.