协议添加探头距离与声速

This commit is contained in:
95384 2024-11-23 18:00:43 +08:00
parent e96230cbd3
commit 701ff34162
2 changed files with 32 additions and 32 deletions

View File

@ -48,19 +48,20 @@ typedef enum
FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */ FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */ FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */
FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */ FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */
FRT_REGISTER_WAVE_DATA = 34, /* 波形数据 */ FRT_REGISTER_DISTANCE = 34, /* 换能器表面距离 */
FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */ FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */
FRT_REGISTER_LINEAR_POINT_X_1 = 36, /* 线性插值原始点1 */ FRT_REGISTER_WIND_C = 36, /* 计算得到的风速 */
FRT_REGISTER_LINEAR_POINT_X_2 = 37, /* 线性插值原始点2 */ FRT_REGISTER_LINEAR_POINT_X_1 = 37, /* 线性插值原始点1 */
FRT_REGISTER_LINEAR_POINT_X_3 = 38, /* 线性插值原始点3 */ FRT_REGISTER_LINEAR_POINT_X_2 = 38, /* 线性插值原始点2 */
FRT_REGISTER_LINEAR_POINT_X_4 = 39, /* 线性插值原始点4 */ FRT_REGISTER_LINEAR_POINT_X_3 = 39, /* 线性插值原始点3 */
FRT_REGISTER_LINEAR_POINT_X_5 = 40, /* 线性插值原始点5 */ FRT_REGISTER_LINEAR_POINT_X_4 = 40, /* 线性插值原始点4 */
FRT_REGISTER_LINEAR_POINT_Y_1 = 41, /* 线性插值校准点1 */ FRT_REGISTER_LINEAR_POINT_X_5 = 41, /* 线性插值原始点5 */
FRT_REGISTER_LINEAR_POINT_Y_2 = 42, /* 线性插值校准点2 */ FRT_REGISTER_LINEAR_POINT_Y_1 = 42, /* 线性插值校准点1 */
FRT_REGISTER_LINEAR_POINT_Y_3 = 43, /* 线性插值校准点3 */ FRT_REGISTER_LINEAR_POINT_Y_2 = 43, /* 线性插值校准点2 */
FRT_REGISTER_LINEAR_POINT_Y_4 = 44, /* 线性插值校准点4 */ FRT_REGISTER_LINEAR_POINT_Y_3 = 44, /* 线性插值校准点3 */
FRT_REGISTER_LINEAR_POINT_Y_5 = 45, /* 线性插值校准点5 */ FRT_REGISTER_LINEAR_POINT_Y_4 = 45, /* 线性插值校准点4 */
FRT_REGISTER_LINEAR_ENABLE = 46, /* 线性插值使能 */ FRT_REGISTER_LINEAR_POINT_Y_5 = 46, /* 线性插值校准点5 */
FRT_REGISTER_LINEAR_ENABLE = 47, /* 线性插值使能 */
}FRT_MsgRegister; }FRT_MsgRegister;
#pragma pack(push,1) #pragma pack(push,1)

View File

@ -44,7 +44,6 @@ static u_int16_t FRT_ReadRegTransducerCFG1R5(void *pMsg);
static u_int16_t FRT_ReadRegTransducerCFG4R5(void *pMsg); static u_int16_t FRT_ReadRegTransducerCFG4R5(void *pMsg);
static u_int16_t FRT_ReadRegTransducerCFG8R0(void *pMsg); static u_int16_t FRT_ReadRegTransducerCFG8R0(void *pMsg);
static u_int16_t FRT_ReadRegRSSIRange(void *pMsg); static u_int16_t FRT_ReadRegRSSIRange(void *pMsg);
static u_int16_t FRT_ReadRegWaveData(void *pMsg);
static u_int16_t FRT_ReadRegErrorData(void *pMsg); static u_int16_t FRT_ReadRegErrorData(void *pMsg);
static u_int16_t FRT_ReadRegPoint_1X(void *pMsg); static u_int16_t FRT_ReadRegPoint_1X(void *pMsg);
static u_int16_t FRT_ReadRegPoint_2X(void *pMsg); static u_int16_t FRT_ReadRegPoint_2X(void *pMsg);
@ -892,11 +891,11 @@ void FRT_MsgProc_ReadRegister(device_handle device, void *pMsg)
uint8_t *data = (uint8_t *)pMsg; uint8_t *data = (uint8_t *)pMsg;
u_int16_t start_reg_addr = (data[2] << 8)| data[3]; u_int16_t start_reg_addr = (data[2] << 8)| data[3];
u_int16_t reg_num= (data[4] << 8)| data[5]; u_int16_t reg_num= (data[4] << 8)| data[5];
if ( \ if ( \
start_reg_addr < 0x00 ||\ start_reg_addr < 0x00 ||\
(start_reg_addr > 0x08 && start_reg_addr < 0x14) ||\ (start_reg_addr > FRT_REGISTER_PRESSURE && start_reg_addr < FRT_REGISTER_DEVICE_ADDR) ||\
(start_reg_addr > 0x17 && start_reg_addr < 0x1E) ||\ (start_reg_addr > FRT_REGISTER_TEMPHUM_UPDATE_TIME && start_reg_addr < FRT_REGISTER_TRANSDUCER_CFG_1R5) ||\
start_reg_addr > 0x2E \ start_reg_addr > FRT_REGISTER_LINEAR_ENABLE \
) )
{ {
@ -904,11 +903,11 @@ void FRT_MsgProc_ReadRegister(device_handle device, void *pMsg)
return; return;
} }
if ( \ if ( \
reg_num < 0x01 ||\ reg_num < 0x01 ||\
(((reg_num + start_reg_addr - 1) > 0x08) && ((reg_num + start_reg_addr - 1) < 0x14)) ||\ (((reg_num + start_reg_addr - 1) > FRT_REGISTER_PRESSURE) && ((reg_num + start_reg_addr - 1) < FRT_REGISTER_DEVICE_ADDR)) ||\
(((reg_num + start_reg_addr -1) > 0x17) && ((reg_num + start_reg_addr -1) < 0x1E)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_TEMPHUM_UPDATE_TIME) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_TRANSDUCER_CFG_1R5)) ||\
((reg_num + start_reg_addr -1) > 0x2E) \ ((reg_num + start_reg_addr -1) > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
@ -957,20 +956,20 @@ void FRT_MsgProc_WriteRegister(device_handle device, void *pMsg)
unsigned short return_crc_value; unsigned short return_crc_value;
// 校验 // 校验
if (start_reg_addr < 0x14 ||\ if (start_reg_addr < FRT_REGISTER_DEVICE_ADDR ||\
(start_reg_addr > 0x1C && start_reg_addr < 0x1E)||\ (start_reg_addr > FRT_REGISTER_REST_DEFAULT_SETTING && start_reg_addr < FRT_REGISTER_TRANSDUCER_CFG_1R5) ||\
(start_reg_addr > 0x21 && start_reg_addr < 0x29)||\ (start_reg_addr > FRT_REGISTER_DISTANCE && start_reg_addr < FRT_REGISTER_LINEAR_POINT_Y_1) ||\
(start_reg_addr > 0x2E) (start_reg_addr > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
term_printf("start_reg_addr error:%d", start_reg_addr); term_printf("start_reg_addr error:%d", start_reg_addr);
return; return;
} }
if (reg_num < 0x01 ||\ if (reg_num < 0x01 ||\
((reg_num + start_reg_addr - 1) < 0x14) ||\ ((reg_num + start_reg_addr - 1) < FRT_REGISTER_DEVICE_ADDR) ||\
(((reg_num + start_reg_addr -1) > 0x1C) && ((reg_num + start_reg_addr -1) < 0x1E)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_REST_DEFAULT_SETTING) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_TRANSDUCER_CFG_1R5)) ||\
(((reg_num + start_reg_addr -1) > 0x21) && ((reg_num + start_reg_addr -1) < 0x29)) ||\ (((reg_num + start_reg_addr -1) > FRT_REGISTER_DISTANCE) && ((reg_num + start_reg_addr -1) < FRT_REGISTER_LINEAR_POINT_Y_1)) ||\
((reg_num + start_reg_addr -1) > 0x2E) ((reg_num + start_reg_addr -1) > FRT_REGISTER_LINEAR_ENABLE) \
) )
{ {
term_printf("reg_num error:%d", reg_num); term_printf("reg_num error:%d", reg_num);