Browse Source

Исправлена ошибка с сохранение файла

размером кратным буферу (8К).
Настройки в конфигурации для работы UART
с октопринт и т.д.
pull/1/head
Sergey 5 years ago
parent
commit
71cf8a7a2d
  1. 2
      Marlin/Configuration.h
  2. 8
      Marlin/Configuration_adv.h
  3. 40
      Marlin/src/libs/Segger/log.h
  4. 28
      Marlin/src/module/mks_wifi/debug_to_uart.cpp
  5. 9
      Marlin/src/module/mks_wifi/debug_to_uart.h
  6. 25
      Marlin/src/module/mks_wifi/mks_wifi_sd.cpp
  7. BIN
      firmware/2208/Robin_nano35.bin
  8. BIN
      firmware/std/Robin_nano35.bin

2
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
/**

8
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

40
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

28
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++);
}
}

9
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

25
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,14 +190,17 @@ 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;
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);
@ -201,7 +209,7 @@ void mks_wifi_start_file_upload(ESP_PROTOC_FRAME *packet){
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);

BIN
firmware/2208/Robin_nano35.bin

Binary file not shown.

BIN
firmware/std/Robin_nano35.bin

Binary file not shown.
Loading…
Cancel
Save