Browse Source

Merge pull request #1311 from i-make-robots/Development

issue 968 for dev branch
Bo Herrmannsen 10 years ago
parent
commit
00e4bc9f54
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
 
376
 
377
 //Inactivity shutdown variables
377
 //Inactivity shutdown variables
378
 static unsigned long previous_millis_cmd = 0;
378
 static unsigned long previous_millis_cmd = 0;
379
+static unsigned long previous_millis_ok = 0;
379
 static unsigned long max_inactive_time = 0;
380
 static unsigned long max_inactive_time = 0;
380
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
381
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
381
 
382
 
645
           else
646
           else
646
           {
647
           {
647
             SERIAL_PROTOCOLLNPGM(MSG_OK);
648
             SERIAL_PROTOCOLLNPGM(MSG_OK);
649
+						previous_millis_ok = millis();
648
           }
650
           }
649
         }
651
         }
650
         else
652
         else
3155
           }
3157
           }
3156
         }
3158
         }
3157
         else if (servo_index >= 0) {
3159
         else if (servo_index >= 0) {
3158
-          SERIAL_PROTOCOL(MSG_OK);
3160
+					SERIAL_PROTOCOL(MSG_OK);
3159
           SERIAL_PROTOCOL(" Servo ");
3161
           SERIAL_PROTOCOL(" Servo ");
3160
           SERIAL_PROTOCOL(servo_index);
3162
           SERIAL_PROTOCOL(servo_index);
3161
           SERIAL_PROTOCOL(": ");
3163
           SERIAL_PROTOCOL(": ");
3162
           SERIAL_PROTOCOL(servos[servo_index].read());
3164
           SERIAL_PROTOCOL(servos[servo_index].read());
3163
           SERIAL_PROTOCOLLN("");
3165
           SERIAL_PROTOCOLLN("");
3166
+					previous_millis_ok = millis();
3164
         }
3167
         }
3165
       }
3168
       }
3166
       break;
3169
       break;
3235
         SERIAL_PROTOCOL(" d:");
3238
         SERIAL_PROTOCOL(" d:");
3236
         SERIAL_PROTOCOL(unscalePID_d(bedKd));
3239
         SERIAL_PROTOCOL(unscalePID_d(bedKd));
3237
         SERIAL_PROTOCOLLN("");
3240
         SERIAL_PROTOCOLLN("");
3241
+				previous_millis_ok = millis();
3238
       }
3242
       }
3239
       break;
3243
       break;
3240
     #endif //PIDTEMP
3244
     #endif //PIDTEMP
3525
           SERIAL_ECHO_START;
3529
           SERIAL_ECHO_START;
3526
           SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
3530
           SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
3527
           SERIAL_PROTOCOLLN("");
3531
           SERIAL_PROTOCOLLN("");
3532
+					previous_millis_ok = millis();
3528
         }
3533
         }
3529
         else
3534
         else
3530
         {
3535
         {
3911
   ClearToSend();
3916
   ClearToSend();
3912
 }
3917
 }
3913
 
3918
 
3919
+
3914
 void FlushSerialRequestResend()
3920
 void FlushSerialRequestResend()
3915
 {
3921
 {
3916
   //char cmdbuffer[bufindr][100]="Resend:";
3922
   //char cmdbuffer[bufindr][100]="Resend:";
3928
     return;
3934
     return;
3929
   #endif //SDSUPPORT
3935
   #endif //SDSUPPORT
3930
   SERIAL_PROTOCOLLNPGM(MSG_OK);
3936
   SERIAL_PROTOCOLLNPGM(MSG_OK);
3937
+	previous_millis_ok = millis();
3931
 }
3938
 }
3932
 
3939
 
3933
 void get_coordinates()
3940
 void get_coordinates()
4352
   if( (millis() - previous_millis_cmd) >  max_inactive_time )
4359
   if( (millis() - previous_millis_cmd) >  max_inactive_time )
4353
     if(max_inactive_time)
4360
     if(max_inactive_time)
4354
       kill();
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
   if(stepper_inactive_time)  {
4370
   if(stepper_inactive_time)  {
4356
     if( (millis() - previous_millis_cmd) >  stepper_inactive_time )
4371
     if( (millis() - previous_millis_cmd) >  stepper_inactive_time )
4357
     {
4372
     {

Loading…
Cancel
Save