From 9c4f1432940d6b39f5b405d3cdf4d49606181448 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 20 Aug 2026 10:56:20 +0800 Subject: [PATCH] temp --- RBcore/client_setting.c | 109 ++++++++++++++++++++++ project/paint_robot_new/paint_robot_new.c | 66 +------------ 2 files changed, 110 insertions(+), 65 deletions(-) create mode 100644 RBcore/client_setting.c diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c new file mode 100644 index 0000000..123c117 --- /dev/null +++ b/RBcore/client_setting.c @@ -0,0 +1,109 @@ +/****************************************************************************** + + 版权所有 (C), 2018-2099, Radkil + + ****************************************************************************** + 文 件 名 : client_setting.c + 版 本 号 : 初稿 + 作 者 : radkil + 生成日期 : 2026年8月20日 + 最近修改 : + 功能描述 : PVIV中间层 + + 修改历史 : + 1.日 期 : 2026年8月20日 + 作 者 : radkil + 修改内容 : 创建文件 + +******************************************************************************/ +#include "pb.h" +#include "pb_decode.h" +#include "../Protobuf/PSource/bsp_PV.pb.h" + +/*----------------------------------------------* + * 外部变量说明 * + *----------------------------------------------*/ + +/*----------------------------------------------* + * 外部函数原型说明 * + *----------------------------------------------*/ + +/*----------------------------------------------* + * 内部函数原型说明 * + *----------------------------------------------*/ + +/*----------------------------------------------* + * 全局变量 * + *----------------------------------------------*/ + +/*----------------------------------------------* + * 模块级变量 * + *----------------------------------------------*/ +static PV_struct_define decoded_PV_variable = { 0 }; +static PV_struct_define decoded_PV = { 0 }; +/*----------------------------------------------* + * 常量定义 * + *----------------------------------------------*/ + +/*----------------------------------------------* + * 宏定义 * + *----------------------------------------------*/ +int check_PV(char *_pBuffer, uint32_t _iSize) +{ + if (_iSize < 4) return -1; + if (_pBuffer[0] != 0x55) return -1; + if (_pBuffer[1] != 0x55) return -1; + + uint16_t crc_check = ((_pBuffer[_iSize - 1] << 8) | _pBuffer[_iSize - 2]); + uint16_t crc_check1 = Rd_modbusCRC16((uint8_t *)_pBuffer, _iSize - 2); + if (crc_check == crc_check1) + { + return _iSize; + } + else + { + return -1; + } +} + +void decode_PV(const char *_pBuffer, uint32_t _iSize) +{ + if (_pBuffer[2] == 0x01 && _pBuffer[3] == 0x01) //01 01 设置PV + { + pb_istream_t i_pv_stream; + + i_pv_stream = pb_istream_from_buffer((const pb_byte_t *)&_pBuffer[4], _iSize - 6); + pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV_variable); + + if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp) + { + decoded_PV=decoded_PV_variable; + } + } + else if (*(_pBuffer + 2) == 0x02 && *(_pBuffer + 3) == 0x01) //设置PV + { + + } + else if (*(_pBuffer + 2) == 0x03 && *(_pBuffer + 3) == 0x01) //返回IV + { + + } + else + { + + } +// Motor_CmdData_t tMotor_CmdData_t = {0}; +// tMotor_CmdData_t.m_ucMotorIndex = 1; +// tMotor_CmdData_t.m_iValue = 10; +// MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, (void *)&tMotor_CmdData_t, sizeof(Motor_CmdData_t)); +} + +void Send_PV(void *argument) +{ + while(1) + { + + Rd_Delay(1); + } +} + diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index 93c5fa6..2b3d0ac 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -17,11 +17,7 @@ ******************************************************************************/ #include "BHBF.h" -#include "pb.h" -#include "pb_decode.h" -#include "../Protobuf/PSource/bsp_PV.pb.h" #include "../Protobuf/PSource/msp_MK32.pb.h" -#include /*----------------------------------------------* * 外部变量说明 * @@ -34,9 +30,6 @@ /*----------------------------------------------* * 内部函数原型说明 * *----------------------------------------------*/ -static SP_MSP_MK32_Button RB_MK32; -static PV_struct_define decoded_PV_variable = { 0 }; -static PV_struct_define decoded_PV = { 0 }; /*----------------------------------------------* * 全局变量 * @@ -45,6 +38,7 @@ static PV_struct_define decoded_PV = { 0 }; /*----------------------------------------------* * 模块级变量 * *----------------------------------------------*/ +static SP_MSP_MK32_Button RB_MK32; /*----------------------------------------------* * 常量定义 * @@ -145,61 +139,3 @@ void decode_MK32(const char *buf, uint32_t _iSize) } } -int check_PV(char *_pBuffer, uint32_t _iSize) -{ - if (_iSize < 4) return -1; - if (_pBuffer[0] != 0x55) return -1; - if (_pBuffer[1] != 0x55) return -1; - - uint16_t crc_check = ((_pBuffer[_iSize - 1] << 8) | _pBuffer[_iSize - 2]); - uint16_t crc_check1 = Rd_modbusCRC16((uint8_t *)_pBuffer, _iSize - 2); - if (crc_check == crc_check1) - { - return _iSize; - } - else - { - return -1; - } -} - -void decode_PV(const char *_pBuffer, uint32_t _iSize) -{ - if (_pBuffer[2] == 0x01 && _pBuffer[3] == 0x01) //01 01 设置PV - { - pb_istream_t i_pv_stream; - - i_pv_stream = pb_istream_from_buffer((const pb_byte_t *)&_pBuffer[4], _iSize - 6); - pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV_variable); - - if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp) - { - decoded_PV=decoded_PV_variable; - } - } - else if (*(_pBuffer + 2) == 0x02 && *(_pBuffer + 3) == 0x01) //设置PV - { - - } - else if (*(_pBuffer + 2) == 0x03 && *(_pBuffer + 3) == 0x01) //返回IV - { - - } - else - { - - } -// Motor_CmdData_t tMotor_CmdData_t = {0}; -// tMotor_CmdData_t.m_ucMotorIndex = 1; -// tMotor_CmdData_t.m_iValue = 10; -// MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, (void *)&tMotor_CmdData_t, sizeof(Motor_CmdData_t)); -} - -void Send_PV(void *argument) -{ - while(1) - { - - Rd_Delay(1); - } -}