PRUSA SN in eeprom
This commit is contained in:
parent
b71f1be37a
commit
dea3f23a69
2 changed files with 33 additions and 9 deletions
|
@ -407,6 +407,7 @@ static void gcode_M105(uint8_t extruder);
|
|||
static void temp_compensation_start();
|
||||
static void temp_compensation_apply();
|
||||
|
||||
static bool get_PRUSA_SN(char* SN);
|
||||
|
||||
uint16_t gcode_in_progress = 0;
|
||||
uint16_t mcode_in_progress = 0;
|
||||
|
@ -1075,6 +1076,21 @@ void setup()
|
|||
if(!(eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED)))
|
||||
eeprom_update_byte((unsigned char *)EEPROM_FAN_CHECK_ENABLED,true);
|
||||
}
|
||||
|
||||
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_PRUSA_SN + 19)) //saved EEPROM SN is not valid. Try to retrieve it.
|
||||
{
|
||||
char SN[20];
|
||||
if (get_PRUSA_SN(SN))
|
||||
{
|
||||
eeprom_update_block(SN, (uint8_t*)EEPROM_PRUSA_SN, 20);
|
||||
puts_P(PSTR("SN updated"));
|
||||
}
|
||||
else
|
||||
puts_P(PSTR("SN update failed"));
|
||||
}
|
||||
|
||||
|
||||
#ifndef W25X20CL
|
||||
SERIAL_PROTOCOLLNPGM("start");
|
||||
#else
|
||||
|
@ -3386,25 +3402,26 @@ void gcode_M701()
|
|||
*
|
||||
* Typical format of S/N is:CZPX0917X003XC13518
|
||||
*
|
||||
* Command operates only in farm mode, if not in farm mode, "Not in farm mode." is written to MYSERIAL.
|
||||
*
|
||||
* Send command ;S to serial port 0 to retrieve serial number stored in 32U2 processor,
|
||||
* reply is transmitted to serial port 1 character by character.
|
||||
* reply is transmitted to the selected serial port.
|
||||
* Operation takes typically 23 ms. If the retransmit is not finished until 100 ms,
|
||||
* it is interrupted, so less, or no characters are retransmitted, only newline character is send
|
||||
* in any case.
|
||||
* The command will fail if the 32U2 processor is unpowered via USB since it is isolated from the rest of the electronics.
|
||||
* In that case the value that is stored in the EEPROM should be used instead.
|
||||
*
|
||||
* @return 1 on success
|
||||
*/
|
||||
static void gcode_PRUSA_SN()
|
||||
static bool get_PRUSA_SN(char* SN)
|
||||
{
|
||||
uint8_t selectedSerialPort_bak = selectedSerialPort;
|
||||
char SN[20];
|
||||
selectedSerialPort = 0;
|
||||
SERIAL_ECHOLNRPGM(PSTR(";S"));
|
||||
uint8_t numbersRead = 0;
|
||||
ShortTimer timeout;
|
||||
timeout.start();
|
||||
|
||||
while (numbersRead < (sizeof(SN) - 1)) {
|
||||
while (numbersRead < 19) {
|
||||
if (MSerial.available() > 0) {
|
||||
SN[numbersRead] = MSerial.read();
|
||||
numbersRead++;
|
||||
|
@ -3413,7 +3430,7 @@ static void gcode_PRUSA_SN()
|
|||
}
|
||||
SN[numbersRead] = 0;
|
||||
selectedSerialPort = selectedSerialPort_bak;
|
||||
SERIAL_ECHOLN(SN);
|
||||
return (numbersRead == 19);
|
||||
}
|
||||
//! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors
|
||||
//! at the TACH_1 pin, which causes bad detection of print fan speed.
|
||||
|
@ -3950,7 +3967,12 @@ void process_commands()
|
|||
card.openFile(strchr_pointer+4,false);
|
||||
|
||||
} else if (code_seen("SN")) { // PRUSA SN
|
||||
gcode_PRUSA_SN();
|
||||
char SN[20];
|
||||
eeprom_read_block(SN, (uint8_t*)EEPROM_PRUSA_SN, 20);
|
||||
if (SN[19])
|
||||
puts_P(PSTR("SN invalid"));
|
||||
else
|
||||
puts(SN);
|
||||
|
||||
} else if(code_seen("Fir")){ // PRUSA Fir
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
|
|||
| 0x0D29 3369 | uint8 | EEPROM_PINDA_TEMP_COMPENSATION | ffh 255 | ffh 255 | PINDA temp compensation unknown state | LCD menu | D3 Ax0d29 C1
|
||||
| ^ | ^ | ^ | 00h 0 | ^ | PINDA has no temp compensation PINDA v1/2 | ^ | ^
|
||||
| ^ | ^ | ^ | 01h 1 | ^ | PINDA has temp compensation aka SuperPINDA | ^ | ^
|
||||
| 0x0D15 3349 | char[20] | EEPROM_PRUSA_SN | SN[19] == 0 | ffffffffffffffff... | PRUSA Serial number string | PRUSA SN | D3 Ax0d15 C20
|
||||
|
||||
|
||||
| Address begin | Bit/Type | Name | Valid values | Default/FactoryReset | Description | Gcode/Function| Debug code
|
||||
|
@ -521,8 +522,9 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
|
|||
#define EEPROM_ALTFAN_OVERRIDE (EEPROM_UVLO_LA_K-1) //uint8
|
||||
#define EEPROM_EXPERIMENTAL_VISIBILITY (EEPROM_ALTFAN_OVERRIDE-1) //uint8
|
||||
#define EEPROM_PINDA_TEMP_COMPENSATION (EEPROM_EXPERIMENTAL_VISIBILITY-1) //uint8
|
||||
#define EEPROM_PRUSA_SN (EEPROM_PINDA_TEMP_COMPENSATION-20) //char[20]
|
||||
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
|
||||
#define EEPROM_LAST_ITEM EEPROM_PINDA_TEMP_COMPENSATION
|
||||
#define EEPROM_LAST_ITEM EEPROM_PRUSA_SN
|
||||
// !!!!!
|
||||
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
|
||||
// !!!!!
|
||||
|
|
Loading…
Reference in a new issue