Go Down

Topic: Problem when Due receives datas from serial port (Read 1 time) previous topic - next topic

Due88

Hi everyone. I have conected a microcontroller that sends by serial port a data. The Arduino Due sends a request data and later receives this datas and print it by serial port monitor.
The problem is that I get to receive ONLY four times this data. Later, the Arduino don't print this data by serial port monitor. The problem seems that Arduino doesn't take more datas.

I am using the code example for receive the datas. What is the problem?

thanks!!

Code: [Select]
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
  // initialize serial:
  Serial.begin(9600);
  Serial1.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
  // print the string when a newline arrives:
Serial1.print("REQUESTDATA\r");
delay(1000);
  if (stringComplete) {
    Serial.print(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

Palliser


Code: [Select]
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
 // initialize serial:
 Serial.begin(9600);
 Serial1.begin(9600);
 // reserve 200 bytes for the inputString:
 inputString.reserve(200);
}

void loop() {
 // print the string when a newline arrives:
Serial1.print("REQUESTDATA\r");
delay(1000);
 if (stringComplete) {
   Serial.print(inputString);
   // clear the string:
   inputString = "";
   stringComplete = false;
 }
}



Is that snippet code? The example sketch from File->Examples->04.Communication->serialEvent comes with the serialEvent function in it. I don't see it in yours.

p


Go Up