diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7c14665f39..8dfbfc9a81 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -814,7 +814,7 @@ * http://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html */ #if DISABLED(CLASSIC_JERK) - #define JUNCTION_DEVIATION_MM 0.025 // (mm) Distance from real junction edge + #define JUNCTION_DEVIATION_MM 0.12 // (mm) Distance from real junction edge #endif /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6ee84989c8..f9e8846ded 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1716,7 +1716,7 @@ // The number of linear motions that can be in the plan at any give time. // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2 (e.g. 8, 16, 32) because shifts and ors are used to do the ring-buffering. #if ENABLED(SDSUPPORT) - #define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller + #define BLOCK_BUFFER_SIZE 32 // SD,LCD,Buttons take more memory, block buffer needs to be smaller #else #define BLOCK_BUFFER_SIZE 16 // maximize block buffer #endif @@ -1725,7 +1725,7 @@ // The ASCII buffer for serial input #define MAX_CMD_SIZE 96 -#define BUFSIZE 4 +#define BUFSIZE 32 // Transmission to Host Buffer Size // To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0. @@ -1734,7 +1734,7 @@ // For debug-echo: 128 bytes for the optimal speed. // Other output doesn't need to be that speedy. // :[0, 2, 4, 8, 16, 32, 64, 128, 256] -#define TX_BUFFER_SIZE 32 +#define TX_BUFFER_SIZE 256 // Host Receive Buffer Size // Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough. @@ -1745,7 +1745,7 @@ #if RX_BUFFER_SIZE >= 1024 // Enable to have the controller send XON/XOFF control characters to // the host to signal the RX buffer is becoming full. - //#define SERIAL_XON_XOFF + #define SERIAL_XON_XOFF #endif // Add M575 G-code to change the baud rate diff --git a/Marlin/src/libs/Segger/log.h b/Marlin/src/libs/Segger/log.h index 9516cae9bc..c251cab328 100644 --- a/Marlin/src/libs/Segger/log.h +++ b/Marlin/src/libs/Segger/log.h @@ -1,6 +1,7 @@ #ifndef LOG_H #define LOG_H #include "SEGGER_RTT.h" +#include "../../module/mks_wifi/debug_to_uart.h" #define DEBUG_MSG #define INFO_MSG @@ -9,6 +10,9 @@ //#define COLOR_LOG_RTT +//#define DEBUG_TO_UART +#define DEBUG_TO_SEGGER_RTT + #ifdef COLOR_LOG_RTT #ifdef DEBUG_MSG @@ -32,26 +36,56 @@ #define ERROR(fmt, args...) #endif #else + #ifdef DEBUG_TO_UART + + #ifdef DEBUG_MSG + #define DEBUG(fmt, args...) debug_to_uart("[D] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) + #else + #define DEBUG(fmt, args...) + #endif + #ifdef INFO_MSG + #define INFO(fmt, args...) debug_to_uart("[I] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) + #else + #define INFO(fmt, args...) + #endif + #ifdef WARNING_MSG + #define WARNING(fmt, args...) debug_to_uart("[W] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) + #else + #define WARNING(fmt, args...) + #endif + #ifdef ERROR_MSG + #define ERROR(fmt, args...) debug_to_uart("[E] %-20s:%-4d :" fmt "\n", __func__, __LINE__,## args) + #else + #define ERROR(fmt, args...) + #endif + + #endif + + #ifdef DEBUG_TO_SEGGER_RTT + #ifdef DEBUG_MSG #define DEBUG(fmt, args...) SEGGER_RTT_printf(0,"[D] %-20s:%-4d :" fmt "\r\n", __func__, __LINE__, ## args) #else #define DEBUG(fmt, args...) #endif #ifdef INFO_MSG - #define INFO(fmt, args...) SEGGER_RTT_printf(0,"[I] %-20s:%-4d :" fmt "\r\n", __func__, __LINE__, ## args) + #define INFO(fmt, args...) SEGGER_RTT_printf(0,"[I] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) #else #define INFO(fmt, args...) #endif #ifdef WARNING_MSG - #define WARNING(fmt, args...) SEGGER_RTT_printf(0,"[W] %-20s:%-4d :" fmt "\r\n", __func__, __LINE__, ## args) + #define WARNING(fmt, args...) SEGGER_RTT_printf(0,"[W] %-20s:%-4d :" fmt "\n", __func__, __LINE__, ## args) #else #define WARNING(fmt, args...) #endif #ifdef ERROR_MSG - #define ERROR(fmt, args...) SEGGER_RTT_printf(0,"[E] %-20s:%-4d :" fmt "\r\n", __func__, __LINE__,## args) + #define ERROR(fmt, args...) SEGGER_RTT_printf(0,"[E] %-20s:%-4d :" fmt "\n", __func__, __LINE__,## args) #else #define ERROR(fmt, args...) #endif + + #endif + #endif #endif diff --git a/Marlin/src/module/mks_wifi/debug_to_uart.cpp b/Marlin/src/module/mks_wifi/debug_to_uart.cpp new file mode 100644 index 0000000000..397218ce22 --- /dev/null +++ b/Marlin/src/module/mks_wifi/debug_to_uart.cpp @@ -0,0 +1,28 @@ +#include "debug_to_uart.h" + + +void debug_to_uart(char *fmt,...){ + + char buffer[200]; + va_list ParamList; + char *ptr = (char *)buffer; + + buffer[0] = ';'; + buffer[1] = ' '; + + va_start(ParamList, fmt); + vsnprintf (buffer+2, 199, fmt, ParamList); + va_end(ParamList); + + //SERIAL_ECHOLN((char *)&buffer); + + while(*ptr){ + while(MYSERIAL0.availableForWrite()==0){ + safe_delay(10); + } + MYSERIAL0.write(*ptr++); + } + + + +} diff --git a/Marlin/src/module/mks_wifi/debug_to_uart.h b/Marlin/src/module/mks_wifi/debug_to_uart.h new file mode 100644 index 0000000000..5e24bfdc88 --- /dev/null +++ b/Marlin/src/module/mks_wifi/debug_to_uart.h @@ -0,0 +1,9 @@ +#ifndef DEBUG_UART_H +#define DEBUG_UART_H + +#include "../../MarlinCore.h" +#include "../../inc/MarlinConfig.h" + +void debug_to_uart(char *fmt,...); + +#endif \ No newline at end of file diff --git a/Marlin/src/module/mks_wifi/mks_wifi_sd.cpp b/Marlin/src/module/mks_wifi/mks_wifi_sd.cpp index 23c079e00c..ef8a5fc684 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi_sd.cpp +++ b/Marlin/src/module/mks_wifi/mks_wifi_sd.cpp @@ -24,7 +24,7 @@ void mks_wifi_sd_init(void){ CardReader::release(); result = f_mount((FATFS *)&FATFS_Obj, "0", 1); - DEBUG("SD init %d",result); + DEBUG("SD init result:%d",result); } @@ -72,7 +72,12 @@ void mks_wifi_start_file_upload(ESP_PROTOC_FRAME *packet){ mks_wifi_sd_init(); //открыть файл для записи - f_open((FIL *)&upload_file,str,FA_CREATE_ALWAYS | FA_WRITE); + res=f_open((FIL *)&upload_file,str,FA_CREATE_ALWAYS | FA_WRITE); + if(res){ + DEBUG("File open error %d",res); + mks_wifi_sd_deinit(); + return; + } ui.set_status((const char *)"Upload file...",true); ui.update(); @@ -185,23 +190,26 @@ void mks_wifi_start_file_upload(ESP_PROTOC_FRAME *packet){ if(file_data_size != 0){ //В буфере что-то есть file_inc_size += file_data_size; + DEBUG("Save %d bytes from buffer (%d of %d) ",file_data_size,file_inc_size,file_size); res=f_write((FIL *)&upload_file,(uint8_t*)file_buff,file_data_size,&bytes_writen); if(res){ ERROR("Write err %d",res); break; } file_size_writen+=bytes_writen; - - file_inc_size += data_size; - res=f_write((FIL *)&upload_file,(uint8_t*)(buff+8),data_size,&bytes_writen); - if(res){ - ERROR("Write err %d",res); - break; - } - file_size_writen+=bytes_writen; - - f_sync((FIL *)&upload_file); + } + + file_inc_size += data_size; + DEBUG("Save %d bytes from dma (%d of %d) ",data_size,file_inc_size,file_size); + res=f_write((FIL *)&upload_file,(uint8_t*)(buff+8),data_size,&bytes_writen); + if(res){ + ERROR("Write err %d",res); + break; } + file_size_writen+=bytes_writen; + + f_sync((FIL *)&upload_file); + break; } @@ -227,6 +235,17 @@ void mks_wifi_start_file_upload(ESP_PROTOC_FRAME *packet){ }else{ ui.set_status((const char *)"Upload failed",true); DEBUG("Upload failed! File size: %d; Recieve %d; SD write %d",file_size,file_inc_size,file_size_writen); + //Установить имя файла. + str[0]='0'; + str[1]=':'; + str[2]='/'; + + memcpy((uint8_t *)str+3,(uint8_t *)&packet->data[5],(packet->dataLen - 5)); + str[packet->dataLen - 5 + 3] = 0; + + DEBUG("Rename file %s",str); + f_rename(str,"file_failed.gcode"); + BUZZ(436,392); BUZZ(109,0); BUZZ(436,392); diff --git a/firmware/2208/Robin_nano35.bin b/firmware/2208/Robin_nano35.bin index f6078c431e..f18f6ad617 100644 Binary files a/firmware/2208/Robin_nano35.bin and b/firmware/2208/Robin_nano35.bin differ diff --git a/firmware/std/Robin_nano35.bin b/firmware/std/Robin_nano35.bin index 978ffc30a0..959c5fd80d 100644 Binary files a/firmware/std/Robin_nano35.bin and b/firmware/std/Robin_nano35.bin differ