chipKIT® Development Platform

Inspired by Arduino™

Serial communication problems.

Created Mon, 03 Dec 2012 17:35:10 +0000 by vantees


vantees

Mon, 03 Dec 2012 17:35:10 +0000

Hi, I am new to Max32 as before I was using Arduino boards. I am trying to rewrite some of my code, but I am having some problems with serial communication.

while (Serial.available()) {
    char thisChar = (char)Serial.read();
    if (!(thisChar == 10 || thisChar == 13)) newLine += thisChar;
    if (thisChar == '\n') lineComplete = true;
  }

Code above reads Serial line, send from eg. PC, but it seems to be not working correctly with Max32. It never returns "\n" new line, any suggestions?!?

I am looking for code returns whole serial line at time. Thanks


majenko

Tue, 04 Dec 2012 00:40:36 +0000

That code will only return whatever is in the serial buffer. If the entire line (including the \n) hasn't been transmitted at the time, it will terminate early.

Without seeing it in context (i.e., the rest of your code please) it's impossible to say if that's going to be a problem or not.


vantees

Tue, 04 Dec 2012 07:47:54 +0000

Ok. looks like max32 do not recognize serialevent(). When I put code inside loop() all worked. But why it does not show any errors when loading code with serialevent()?