fix(OTA): 移除BOM标记并优化OTA处理逻辑
移除了OTA.cpp文件中的BOM标记,删除了调试打印代码,修复了 缓冲区溢出检查逻辑,并简化了结束确认帧的发送方式。 - 移除文件开头的BOM标记 - 删除DEBUG_PRINT相关的调试输出代码 - 修正缓冲区大小检查条件,使用expected_size替代硬编码值 - 将结束确认改为使用结构化ACK消息发送
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#include "OTA.h"
|
#include "OTA.h"
|
||||||
#include "Can.h"
|
#include "Can.h"
|
||||||
#include "SpiOta.h"
|
#include "SpiOta.h"
|
||||||
#include "aes128.h"
|
#include "aes128.h"
|
||||||
@@ -297,10 +297,6 @@ void OTAHandler::process() {
|
|||||||
drainFlashBuffer();
|
drainFlashBuffer();
|
||||||
if (pending_finish_ack && flash_buf_cnt == 0U) {
|
if (pending_finish_ack && flash_buf_cnt == 0U) {
|
||||||
pending_finish_ack = false;
|
pending_finish_ack = false;
|
||||||
#if DEBUG_PRINT
|
|
||||||
printf("[OTA] flash drain done, send FINISH ACK\r\n");
|
|
||||||
#endif
|
|
||||||
send_structured_ack(0xFFFFFFFFU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pending_app_jump) {
|
if (pending_app_jump) {
|
||||||
@@ -625,7 +621,7 @@ void OTAHandler::handleLinkMessage(ota_link_msg_type_t type, u8 *data, u8 len) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
u32 offset = receive_packet_num * OTA_PACKET_SIZE;
|
u32 offset = receive_packet_num * OTA_PACKET_SIZE;
|
||||||
if (offset + OTA_PACKET_SIZE > APP_MAX_SIZE) {
|
if (offset >= expected_size) {
|
||||||
ota_error = OTA_ERROR_INVALID_SIZE;
|
ota_error = OTA_ERROR_INVALID_SIZE;
|
||||||
ota_state = OTA_STATE_IDLE;
|
ota_state = OTA_STATE_IDLE;
|
||||||
send_error_frame(receive_packet_num, OTA_ERROR_INVALID_SIZE);
|
send_error_frame(receive_packet_num, OTA_ERROR_INVALID_SIZE);
|
||||||
@@ -652,8 +648,7 @@ void OTAHandler::handleLinkMessage(ota_link_msg_type_t type, u8 *data, u8 len) {
|
|||||||
if (receive_IFEND == 0xFFFFFFFFU) {
|
if (receive_IFEND == 0xFFFFFFFFU) {
|
||||||
ota_state = OTA_STATE_FINISHED;
|
ota_state = OTA_STATE_FINISHED;
|
||||||
pending_finish_ack = true;
|
pending_finish_ack = true;
|
||||||
u8 wait_hint[1] = {0x04};
|
send_structured_ack(0xF0F0F0F0U);
|
||||||
send_wait_frame(1, wait_hint);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user