// 通过UDP发送下载指令到CAT1,附带写延时参数(格式:URL|resume_from_byte|write_delay_ms)
char udp_msg[1024] = {0};
- int msg_len = snprintf(udp_msg, sizeof(udp_msg), "%s|%u|%u", url, 0u, write_delay_ms);
+ int msg_len;
+
+ if(g_py_ver==28)
+ {
+ msg_len = snprintf(udp_msg, sizeof(udp_msg), "%s", url);
+ }
+ else
+ {
+ msg_len = snprintf(udp_msg, sizeof(udp_msg), "%s|%u|%u", url, 0u, write_delay_ms);
+ }
if (msg_len < 0 || msg_len >= (int)sizeof(udp_msg)) {
cat1_print_err("HTTP file download: Failed to format UDP message\n");
g_download_state = HTTP_DOWNLOAD_STATE_IDLE;
ret = uapi_spi_slave_read(SPI_BUS_1, &spi_data, 50);
- uint32_t expected_packet_size = 4 + SPI_PACKET_DATA_SIZE; // 1020字节
+ // uint32_t expected_packet_size = 4 + SPI_PACKET_DATA_SIZE; // 1020字节
- if(ret == 0 && spi_data.rx_bytes == expected_packet_size)
+ if(ret == 0 && spi_data.rx_bytes == SPI_PACKET_TOTAL_SIZE)
{
// 解析包头:前4字节为数据长度(小端序)
uint32_t data_len = unpack_uint32_le(g_rx_buffer);
const uint8_t *data_ptr = g_rx_buffer + 4; // 数据部分从第4字节开始
// 验证数据长度合理性(应该在0到SPI_PACKET_DATA_SIZE之间)
- if (data_len > SPI_PACKET_DATA_SIZE) {
+ if (data_len > SPI_PACKET_DATA_SIZE+4) {
printf("SPI packet error (v28): invalid data length %u (max: %u)\n",
- data_len, SPI_PACKET_DATA_SIZE);
+ data_len, SPI_PACKET_DATA_SIZE+4);
total_byte_error_cnt++;
// 版本28:只触发错误回调,不触发中断
trigger_error_callback(CUSTOM_SPI_ERROR_INVALID_DATA_LEN,
else
{
printf("SPI read error (v28): ret=0x%x, rx_bytes=%u (expected: %u)\n",
- ret, spi_data.rx_bytes, expected_packet_size);
+ ret, spi_data.rx_bytes, SPI_PACKET_TOTAL_SIZE);
total_byte_error_cnt++;
// 版本28:只触发错误回调,不触发中断
trigger_error_callback(CUSTOM_SPI_ERROR_READ_FAILED,