diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1b9b1d1f..1b226674 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -263,6 +263,8 @@ int lcd_change_fil_state = 0; int feedmultiplyBckp = 100; unsigned char lang_selected = 0; +bool prusa_sd_card_upload = false; + unsigned long total_filament_used; unsigned int heating_status; @@ -1071,6 +1073,80 @@ void setup() update_current_firmware_version_to_eeprom(); } +void trace(); + +#define CHUNK_SIZE 64 // bytes +#define SAFETY_MARGIN 1 +char chunk[CHUNK_SIZE+SAFETY_MARGIN]; +int chunkHead = 0; + +int serial_read_stream() { + + setTargetHotend(0, 0); + setTargetBed(0); + + lcd_implementation_clear(); + lcd_printPGM(PSTR(" Upload in progress")); + + // first wait for how many bytes we will receive + uint32_t bytesToReceive; + + // receive the four bytes + char bytesToReceiveBuffer[4]; + for (int i=0; i<4; i++) { + int data; + while ((data = MYSERIAL.read()) == -1) {}; + bytesToReceiveBuffer[i] = data; + + } + + // make it a uint32 + memcpy(&bytesToReceive, &bytesToReceiveBuffer, 4); + + // we're ready, notify the sender + MYSERIAL.write('+'); + + // lock in the routine + uint32_t receivedBytes = 0; + while (prusa_sd_card_upload) { + int i; + for (i=0; i