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).

This commit is contained in:
Robert Pelnar 2017-09-15 16:34:34 +02:00
parent 6f5f88e7ea
commit 9c92025cf2
4 changed files with 43 additions and 36 deletions

View file

@ -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<<WDE) | (1<<WDP0); //30ms prescaler
while(1); //wait for reset
*/
}
void dcode_1()
{
}
void dcode_1()
{
MYSERIAL.println("D1 - Clear EEPROM");
cli();
for (int i = 0; i < 4096; i++)
eeprom_write_byte((unsigned char*)i, (unsigned char)0);
sei();
}
void dcode_2()
{
}
void dcode_2()
{
MYSERIAL.println("D2 - Read/Write RAM");
uint16_t address = 0x0000; //default 0x0000
uint16_t count = 0x2000; //default 0x2000 (entire ram)
@ -111,9 +111,9 @@ void dcode_2()
}
MYSERIAL.write('\n');
}
}
void dcode_3()
{
}
void dcode_3()
{
MYSERIAL.println("D3 - Read/Write EEPROM");
uint16_t address = 0x0000; //default 0x0000
uint16_t count = 0x2000; //default 0x2000 (entire eeprom)
@ -155,10 +155,10 @@ void dcode_3()
}
MYSERIAL.write('\n');
}
}
void dcode_4()
{
}
void dcode_4()
{
MYSERIAL.println("D4 - Read/Write PIN");
if (code_seen('P')) // Pin (0-255)
{

View file

@ -23,7 +23,7 @@
#include "Marlin.h"
#include "MarlinSerial.h"
int selectedSerialPort;
int selectedSerialPort = 0;
#ifndef AT90USB
// this next line disables the entire HardwareSerial.cpp,

View file

@ -57,7 +57,7 @@
#include <avr/wdt.h>
#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;

View file

@ -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();