Browse Source

issue 968 for dev branch

try, try again.

If 'OK' is garbled on sending PC won't receive it.  Both machines will
wait on each other forever.  This resends OK if nothing is heard from PC
for a while to avoid this bad case.
Dan Royer 9 years ago
parent
commit
9472bbe51d
1 changed files with 16 additions and 1 deletions
  1. 16
    1
      Marlin/Marlin_main.cpp

+ 16
- 1
Marlin/Marlin_main.cpp View File

@@ -376,6 +376,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
376 376
 
377 377
 //Inactivity shutdown variables
378 378
 static unsigned long previous_millis_cmd = 0;
379
+static unsigned long previous_millis_ok = 0;
379 380
 static unsigned long max_inactive_time = 0;
380 381
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
381 382
 
@@ -645,6 +646,7 @@ void loop()
645 646
           else
646 647
           {
647 648
             SERIAL_PROTOCOLLNPGM(MSG_OK);
649
+						previous_millis_ok = millis();
648 650
           }
649 651
         }
650 652
         else
@@ -3155,12 +3157,13 @@ Sigma_Exit:
3155 3157
           }
3156 3158
         }
3157 3159
         else if (servo_index >= 0) {
3158
-          SERIAL_PROTOCOL(MSG_OK);
3160
+					SERIAL_PROTOCOL(MSG_OK);
3159 3161
           SERIAL_PROTOCOL(" Servo ");
3160 3162
           SERIAL_PROTOCOL(servo_index);
3161 3163
           SERIAL_PROTOCOL(": ");
3162 3164
           SERIAL_PROTOCOL(servos[servo_index].read());
3163 3165
           SERIAL_PROTOCOLLN("");
3166
+					previous_millis_ok = millis();
3164 3167
         }
3165 3168
       }
3166 3169
       break;
@@ -3235,6 +3238,7 @@ Sigma_Exit:
3235 3238
         SERIAL_PROTOCOL(" d:");
3236 3239
         SERIAL_PROTOCOL(unscalePID_d(bedKd));
3237 3240
         SERIAL_PROTOCOLLN("");
3241
+				previous_millis_ok = millis();
3238 3242
       }
3239 3243
       break;
3240 3244
     #endif //PIDTEMP
@@ -3525,6 +3529,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3525 3529
           SERIAL_ECHO_START;
3526 3530
           SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
3527 3531
           SERIAL_PROTOCOLLN("");
3532
+					previous_millis_ok = millis();
3528 3533
         }
3529 3534
         else
3530 3535
         {
@@ -3911,6 +3916,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3911 3916
   ClearToSend();
3912 3917
 }
3913 3918
 
3919
+
3914 3920
 void FlushSerialRequestResend()
3915 3921
 {
3916 3922
   //char cmdbuffer[bufindr][100]="Resend:";
@@ -3928,6 +3934,7 @@ void ClearToSend()
3928 3934
     return;
3929 3935
   #endif //SDSUPPORT
3930 3936
   SERIAL_PROTOCOLLNPGM(MSG_OK);
3937
+	previous_millis_ok = millis();
3931 3938
 }
3932 3939
 
3933 3940
 void get_coordinates()
@@ -4352,6 +4359,14 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
4352 4359
   if( (millis() - previous_millis_cmd) >  max_inactive_time )
4353 4360
     if(max_inactive_time)
4354 4361
       kill();
4362
+
4363
+	// If 'OK' is garbled on sending PC won't receive it.  Both machines will wait on each other forever.
4364
+	// This resends OK if nothing is heard from PC for a while to avoid this bad case.
4365
+  if( (millis() - previous_millis_ok) >  max_inactive_time/4 ) {
4366
+		SERIAL_PROTOCOL(MSG_OK);
4367
+		previous_millis_ok=millis();
4368
+  }
4369
+
4355 4370
   if(stepper_inactive_time)  {
4356 4371
     if( (millis() - previous_millis_cmd) >  stepper_inactive_time )
4357 4372
     {

Loading…
Cancel
Save