引入mqtt 引入cjson

This commit is contained in:
2584532475@qq.com committed 2023-11-30 08:10:01 +08:00
1 parent a69c1a58d6
commit f8591b8b99
86 files changed
+12141 -2157

No files matched your search

+4 -6
View File
@@ -3,9 +3,10 @@
#include<stdint.h>
#include "crc.h"
#include "modbus-s.h"
#include "modbus-m.h"
#if !defined(LOG_TAG)
#define LOG_TAG "main"
#define LOG_TAG "modbus-s"
#endif
#include <elog.h>
@@ -22,19 +23,16 @@ void ModbusSlaveInit(ModBusSlave_t * drv,uint8_t ID,uint8_t * data,uint16_t * r
//-1 地址错误
int ModbusSlaveHandle(ModBusSlave_t * drv,uint8_t * data,uint16_t length )
{
uint16_t rcrc = 0,ccrc = 0 ;
if( (data[0] != drv->ID) && (data[0] != 0x00))
{
// 地址错误
return -1;
}
rcrc = ((uint16_t)data[length- 1] << 8) + (uint16_t)data[length- 2] ;
ccrc = MX_CRC_CALC(data,length-2);
if (rcrc != ccrc )
if(modbus_m_crc_check(data,length) != MOD_OK)
{
log_e("rcrc:%04X,ccrc:%04X\r\n",rcrc,ccrc) ;
return -2;
}
drv->func = data[1] ;
switch (drv->func)