Echo answer of Serial3 into Serial

Hi,

This may be trivial, but whats the easiest way to send the reply received on Serial3 of a 2560, out to Serial (0) so it can be seen on the serial monitor.

I am trying to talk to a Sena ESD110V2 Bluetooth module, and I am just trying to get it to scan what is in range, and I want to see it so I can hard code the info that comes in (just testing).

Is something like this code snippet along the right lines?

 Serial3.print("AT+BTINFO?");
  char echoArray[50];
  byte myByte;
  while(Serial3.available() <= 0)
  {
    myByte = Serial3.read();
    echoArray[i] = myByte;
    i++;
  }
  Serial.print(echoArray);

Thanks

Oops

Serial3.print("AT+BTINFO?\r");
  char echoArray[10];
  byte myByte;
  while(Serial3.available() > 0)
  {
    myByte = Serial3.read();
    echoArray[i] = myByte;
    i++;
    if(i == 9)
    {
      Serial.println(echoArray);
      i = 0;
    }
  }

Crashed the IDE a few times with what I first wrote...

This seemed to get the response I needed. Awesome.

  while(Serial3.available() <= 0)
  {
    myByte = Serial3.read();
    echoArray[i] = myByte;
    i++;
  }

Serial.available() returns the number of bytes in the serial buffer, waiting to be read. The value can never be less than 0. Your while loop will fire whenever there is nothing to be read, and will read it, storing it in a buffer, with no error checking. You will, of course, in very short order stomp all over memory beyond the bounds of your array (within nanoseconds of applying power to the Arduino, as a matter of fact).

Yep spotted the mistake and that sounds like just what happened

Thanks