issues with serial on teensy 2.0++

Status
Not open for further replies.

nekidfrog

Active member
I'm having an issue with serial data getting magically wiped after you close the serial monitor window. So if I open the serial monitor window and type in 2912312 the test value gets updated correctly. If I close the serial monitor window and reopen it... it magically gets swapped back to 12345.... why is my variable reverting back to it's original value on serial close? Below is the code for the arduino that is currently causing the issue. I'm unbelievably stumped on this. I assumed since I made my test variable a global that if at any point it gets updated it would keep it's data until the ardiuno is unplugged. However the arduino is NEVER unplugged. I simply just open and close the serial monitor. It's as if the serial monitor is causing the arduino to reset?


Code:
char inData[12];
long inInt;
int index;
long test = 12345;
long New;

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

void loop(){
	if(Serial.available()){
		New = RX();
	}
	if( New > test ){
		test = New;
	}
	Serial.println(test);
	delay(100);
}

long RX(){
  // Verify packet
  while(Serial.available() > 2){
    char aChar = Serial.read();
    inData[index] = aChar;
    index++;
    inData[index] = '\0';
  }
  // Packet verified and now converting packet from ASCII to LONG
  inInt = atol(inData);
  index = 0;
  inData[index] = '\0';
  return inInt;
}
 
Yup, it's a "feature".

The reset only happens with the Arduino Serial Monitor. If you use another terminal emulator like Teraterm or Hyperterminal, Teensy does not reset when it opens the port.
 
LOL, so it must be sending the DTR... why don't they give you an option to disable that part? Would have saved me about 4 hours scratching my head last night on why my crap was getting wiped.
 
Status
Not open for further replies.
Back
Top