Problems barsing INT´s ower Bluetooth connection.

I am trying to make a Bluetooth link between two ardunos using HC 05 Bluetooth modules.
Setting up the modules was tricky because the modules came with different firmware and setting and no documentation.
Now I have two arduinos (on two different computers and the modules pairs automatically when powered up. With blank sketches on both ardunos, I can text from one serial terminal and see the text on the other. Feels like magic, and getting it to work was tricky.

I wrote the following little program:
// Test program that sends 3 integer variables separated by comma
// via serial @ 9600,n,8,1
int a, b, c;

void setup() {
Serial.begin(9600);
Serial.println("");
Serial.println("
some text ");
Serial.println("
");
}
void loop() {
Serial.print(a++); //just counting up
Serial.print(","); //comma seperator
Serial.print(1000 - b++); //counting down from 1000
Serial.print(","); //comma seperator
Serial.println(random(1, 1000)); //Just a random number
delay(1000);
}

In the serial monitor on the receiving computer im receiving the data just fine. (With a blank sketch uploaded to the Arduino) It Looks like
1,1000,25
2,999,765

But I cannot read the data into my Arduino
I have tried the following, but without any luck.

int a, b, c;

void setup() {
Serial.begin(9600);
}

void loop() {
while (Serial.available() > 0) {
a = Serial.parseInt();
b = Serial.parseInt();
c = Serial.parseInt(); // and then do something with these values

if (Serial.read() == '\n') {
//Newline has occurred. Do your thing with a,b and c…
}
}
}

Any suggestions or clues on how to parse the ints?

Regards

Peter

Any suggestions or clues on how to parse the ints?

Print a, b, and c after the calls to parseInt(). They may be what you are expecting.

The println() command on the sender is sending a carriage return and line feed, but in what order? Is the \n sent first, or the \r?

You could make it not matter:

char next = Serial.read();
if(next == '\r' || next == '\n')
{
   // do whatever with a, b, and c.

Hi Paul/Forum
I tried your suggestions, but without much luck.
The funny thing is that if I reset the board it sometimes reads "Something".
Not the integers I am sending, but it sure reads something coming from the sending arduino.

It could be parsing variables of other types than I am expecting? Like sending 3 integreres, but parsing them into word variables.

Any suggestions to get this working would be much appreciated. I am kind of stuck here now, and a bit frustrated.

Regards

Peter

I tried your suggestions, but without much luck.

Or posting the modified code. Or the serial output.

Any suggestions to get this working would be much appreciated.

I think that there's a hint floating around here somewhere...