diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 29893925c3..c3ccea40d9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -119,6 +119,7 @@ // M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating // Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling // IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F +// M112 - Emergency stop // M114 - Output current position to serial port // M115 - Capabilities string // M117 - display message @@ -673,6 +674,11 @@ void get_command() } } + + //If command was e-stop process now + if(strcmp(cmdbuffer[bufindw], "M112") == 0) + kill(); + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -1177,19 +1183,21 @@ void process_commands() //ClearToSend(); return; } - //break; + break; case 2: // G2 - CW ARC if(Stopped == false) { get_arc_coordinates(); prepare_arc_move(true); return; } + break; case 3: // G3 - CCW ARC if(Stopped == false) { get_arc_coordinates(); prepare_arc_move(false); return; } + break; case 4: // G4 dwell LCD_MESSAGEPGM(MSG_DWELL); codenum = 0; @@ -1799,7 +1807,7 @@ void process_commands() int pin_number = LED_PIN; if (code_seen('P') && pin_status >= 0 && pin_status <= 255) pin_number = code_value(); - for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++) + for(int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins)/sizeof(int)); i++) { if (sensitive_pins[i] == pin_number) { @@ -1830,6 +1838,9 @@ void process_commands() #endif setWatch(); break; + case 112: // M112 -Emergency Stop + kill(); + break; case 140: // M140 set bed temp if (code_seen('S')) setTargetBed(code_value()); break; @@ -2153,8 +2164,9 @@ void process_commands() } break; case 85: // M85 - code_seen('S'); - max_inactive_time = code_value() * 1000; + if(code_seen('S')) { + max_inactive_time = code_value() * 1000; + } break; case 92: // M92 for(int8_t i=0; i < NUM_AXIS; i++) @@ -2275,6 +2287,7 @@ void process_commands() if(tmp_extruder >= EXTRUDERS) { SERIAL_ECHO_START; SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER); + break; } } volumetric_multiplier[tmp_extruder] = 1 / area; @@ -2466,7 +2479,7 @@ void process_commands() if(pin_state >= -1 && pin_state <= 1){ - for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++) + for(int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins)/sizeof(int)); i++) { if (sensitive_pins[i] == pin_number) { @@ -3424,6 +3437,9 @@ void handle_status_leds(void) { void manage_inactivity() { + if(buflen < (BUFSIZE-1)) + get_command(); + if( (millis() - previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(); diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 737d075754..aac6ca66f5 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -179,7 +179,7 @@ void PID_autotune(float temp, int extruder, int ncycles) float Kp, Ki, Kd; float max = 0, min = 10000; - if ((extruder > EXTRUDERS) + if ((extruder >= EXTRUDERS) #if (TEMP_BED_PIN <= -1) ||(extruder < 0) #endif @@ -609,6 +609,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERROR((int)e); SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); + return 0.0; } #ifdef HEATER_0_USES_MAX6675 if (e == 0) @@ -909,7 +910,7 @@ void disable_heater() #endif #endif - #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 @@ -917,7 +918,7 @@ void disable_heater() #endif #endif - #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index fd3374454d..c321125cae 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -305,7 +305,7 @@ static void lcd_implementation_init() B00000 }; //thanks Sonny Mounicou -#if defined(LCDI2C_TYPE_PCF8575) +#if defined(LCD_I2C_TYPE_PCF8575) lcd.begin(LCD_WIDTH, LCD_HEIGHT); #ifdef LCD_I2C_PIN_BL lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); diff --git a/README.md b/README.md index 94552684ea..17e920ec00 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ========================== Marlin 3D Printer Firmware ========================== +[![Coverity Scan Build Status](https://scan.coverity.com/projects/2224/badge.svg)](https://scan.coverity.com/projects/2224) + Marlin has a GPL license because I believe in open development. Please do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent. @@ -193,6 +195,7 @@ M Codes * M107 - Fan off * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating * Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling +* M112 - Emergency stop * M114 - Output current position to serial port * M115 - Capabilities string * M117 - display message