EmbDev.net

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


Author: (unknown) (Guest)
Posted on:

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 
http://www.c-sharpcorner.com/uploadfile/eclipsed4utoo/serialportcommunication12082008111137am/serialportcommunication.aspx 
| https://mindmajix.com/emc-san-storage-training ) :

Here i initialize the SerialPort

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

void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    Thread.Sleep(1000);
    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
Author: Hmmm (Guest)
Posted on:

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.

Author: Hmmm (Guest)
Posted on:

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?

Reply

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]
  • [avrasm]AVR assembler code[/avrasm]
  • [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.