Hi!
I have a strange problem with Serial and Serial2 on a Teensy3.1.
Serial is used to output some debug messages via PC. Serial2 is connected to a bluetooth 2.0 device.
Sending data over bluetooth is working fine. But sending data to the mobile results in a strange problem.
I only want to transmit S:2#, where the number should go up. This is also not working.
I show you the excerpts from the file, so you can get an idea. I attach the complete file.
This is my setup
Here is the log from the mobile captured over Chrome.
The counting is ok. Eight times "S:2#" is correct. So Serial2.write() is fired correct, but the incremented wCurrentStation isn't set.
I don't get it, why he is sending stuff from Serial?!
Also I'm creating a new variable for sending, but somehow there is stuff from the Serial inside somewho.
Also it's not counting up.
I have a strange problem with Serial and Serial2 on a Teensy3.1.
Serial is used to output some debug messages via PC. Serial2 is connected to a bluetooth 2.0 device.
Sending data over bluetooth is working fine. But sending data to the mobile results in a strange problem.
I only want to transmit S:2#, where the number should go up. This is also not working.
I show you the excerpts from the file, so you can get an idea. I attach the complete file.
This is my setup
Code:
void setup() {
pinMode(ledPIN, OUTPUT);
pinMode(buzzer1PIN, OUTPUT);
Serial.begin(9600); //USB
Serial2.begin(9600); //Bluetooth
startLed();
}
void loop() {
digitalWrite(ledPIN, HIGH);
if (Serial2.available()) {
Serial.println("Serial data available");
char mode = Serial2.read();
Serial.print("Mode Identifier: ");Serial.println(mode);
if(mode == 'W') {
Serial.println("Parsing WORKOUT data...");
wStation = Serial2.parseInt();
wRound = Serial2.parseInt();
wWorkMin = wWorkMin_tmp = Serial2.parseInt();
wWorkSec = wWorkSec_tmp = Serial2.parseInt();
wPauseMin = wPauseMin_tmp = Serial2.parseInt();
wPauseSec = wPauseSec_tmp = Serial2.parseInt();
wPrepMin = wPrepMin_tmp = Serial2.parseInt();
...
wCurrentStation++;
//Sending current station to mobile
char buffer[5];
sprintf (buffer, "S:%d#",wCurrentStation);
Serial2.write(buffer);
Here is the log from the mobile captured over Chrome.
The counting is ok. Eight times "S:2#" is correct. So Serial2.write() is fired correct, but the incremented wCurrentStation isn't set.
Code:
Connected!
Sending Workout: W02,08,00,03,00,02,00,01
S:2#
S:2#
Serial data available
S:2#
erial data available
S:2#
rial data available
S:2#
ial data available
S:2#
al data available
S:2#
l data available
S:2#
Also I'm creating a new variable for sending, but somehow there is stuff from the Serial inside somewho.
Also it's not counting up.
Attachments
Last edited: