forked from gary/BCU
2
0
Fork 0

解决了配置下发后程序崩溃的问题

This commit is contained in:
Carl 2025-06-04 17:01:11 +08:00
parent b7c3ddf4e1
commit 1def56eb47
5 changed files with 8777 additions and 7239 deletions

View File

@ -50,7 +50,7 @@
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>BCU5</OutputName>
<OutputName>BCU10</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
@ -83,7 +83,7 @@
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name>D:\CodeCompare\BCU\app\stm32fxxx_app\hex2bin.exe D:\CodeCompare\BCU\app\stm32fxxx_app\prj\Objects\BCU5.hex</UserProg1Name>
<UserProg1Name>D:\CodeHvStack\BCU\app\stm32fxxx_app\hex2bin.exe D:\CodeHvStack\BCU\app\stm32fxxx_app\prj\Objects\BCU10.hex</UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,7 @@
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
Stack_Size EQU 0x00000500
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
@ -50,7 +50,7 @@ __initial_sp
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00002000
Heap_Size EQU 0x00003000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base

View File

@ -34,9 +34,9 @@ void parse_mqtt_message(char* message)
// ʾÀýÏûÏ¢: +QMTRECV: 0,31,"bluesun/bms/control/123",11,"MQ3156+1MQ"
uint16_t first = 0;
uint16_t second = 0;
uint8_t buffer[256]; // 存储Modbus响应的缓冲区
uint16_t length; // 响应数据长度
uint8_t data; // 函数返回值
uint8_t buffer[5];
uint16_t length;
uint8_t data = 0;
char data_str[6] = {0};
char* quotes[4] = {0};
@ -97,15 +97,14 @@ void parse_mqtt_message(char* message)
current_buffer = 1;
if(strstr(message, "control") != NULL)
{
if((first >= 3000) && (first <= 3168))
buffer[0] = (second >> 8) & 0xFF;
buffer[1] = second & 0xFF;
data = bcu_modbus_485_0x06_fun(first, 1, buffer, &length);
if (data == 0)
{
bcu_data_set_0x06_msg(first, second);
drv_mqtt_publish_control_no_respose("ok", 2);
}
else if ((first >= 4000) && (first <= 4999))
{
hmi_write_modbus_cfg(first - 4000, second);
}
drv_mqtt_publish_control_no_respose("ok", 2);
}
else if (strstr(message, "read") != NULL)
{
@ -113,13 +112,10 @@ void parse_mqtt_message(char* message)
if (data == 0 && length >= 2)
{
//解析16位寄存器值
uint16_t value = (buffer[0] << 8) | buffer[1];
uint16_t value = (buffer[0] << 8) | buffer[1];
snprintf(data_str, sizeof(data_str), "%u", value);
drv_mqtt_publish_read_no_respose(data_str, strlen(data_str));
memset(data_str, 0, sizeof(data_str));
snprintf(data_str, sizeof(data_str), "%u", value);
drv_mqtt_publish_read_no_respose(data_str, strlen(data_str));
}
}
current_buffer = 0;