From 9c92025cf25807daf4366f5fb56e1e8de43ae402 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Fri, 15 Sep 2017 16:34:34 +0200 Subject: [PATCH] Serial port ECHO bug fix - for clear eerpom farm_mode will be set to false. In farm_mode is second serial port the main port and data received from this port is send to serial port 0 (debuging feature). --- Firmware/Dcodes.cpp | 42 +++++++++++++++++++-------------------- Firmware/MarlinSerial.cpp | 2 +- Firmware/Marlin_main.cpp | 33 ++++++++++++++++++------------ Firmware/cmdqueue.cpp | 2 +- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 05977b5f..09d394f5 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -1,7 +1,7 @@ -#include "Dcodes.h" -#include "Marlin.h" -#include "cmdqueue.h" - +#include "Dcodes.h" +#include "Marlin.h" +#include "cmdqueue.h" + inline void serial_print_hex_nibble(uint8_t val) { MYSERIAL.write((val > 9)?(val - 10 + 'a'):(val + '0')); @@ -42,8 +42,8 @@ int parse_hex(char* hex, uint8_t* data, int count) return parsed; } -void dcode_0() -{ +void dcode_0() +{ if (*(strchr_pointer + 1) == 0) return; MYSERIAL.println("D0 - Reset"); if (code_seen('B')) //bootloader @@ -57,19 +57,19 @@ void dcode_0() WDTCSR = (1< -#include "Dcodes.h" +#include "Dcodes.h" #ifdef SWSPI @@ -759,16 +759,16 @@ void setup() setup_killpin(); setup_powerhold(); farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE); - EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no); - //if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode - if (farm_no == 0xFFFF) farm_no = 0; - if (farm_mode) + EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no); + if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode + if (farm_no == 0xFFFF) farm_no = 0; + if (farm_mode) { - prusa_statistics(8); - selectedSerialPort = 1; + prusa_statistics(8); + selectedSerialPort = 1; } else - selectedSerialPort = 0; + selectedSerialPort = 0; MYSERIAL.begin(BAUDRATE); SERIAL_PROTOCOLLNPGM("start"); SERIAL_ECHO_START; @@ -5582,6 +5582,13 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp dcode_3(); break; case 4: // D4 - Read/Write PIN dcode_4(); break; + case 5: + MYSERIAL.println("D5 - Test"); + if (code_seen('P')) + selectedSerialPort = (int)code_value(); + MYSERIAL.print("selectedSerialPort = "); + MYSERIAL.println(selectedSerialPort, DEC); + break; /* case 4: { MYSERIAL.println("D4 - Test"); @@ -5619,14 +5626,14 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp #endif break;*/ // break; - case 5: +/* case 5: { -/* MYSERIAL.print("tmc2130_rd_MSCNT(0)="); + MYSERIAL.print("tmc2130_rd_MSCNT(0)="); int val = tmc2130_rd_MSCNT(tmc2130_cs[0]); - MYSERIAL.println(val);*/ + MYSERIAL.println(val); homeaxis(0); } - break; + break;*/ case 6: { /* MYSERIAL.print("tmc2130_rd_MSCNT(1)="); @@ -6691,7 +6698,7 @@ void serialecho_temperatures() { void uvlo_() { - //SERIAL_ECHOLNPGM("UVLO"); + SERIAL_ECHOLNPGM("UVLO"); save_print_to_eeprom(); float current_position_bckp[2]; int feedrate_bckp = feedrate; diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index c32b65b1..9f134c71 100644 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -356,7 +356,7 @@ void get_command() if (selectedSerialPort == 1) { selectedSerialPort = 0; - MYSERIAL.write(serial_char); + MYSERIAL.write(serial_char); // for debuging serial line 2 in farm_mode selectedSerialPort = 1; } TimeSent = millis();