Browse Source

temp

master
Lizongdi 10 hours ago
parent
commit
9c4f143294
  1. 109
      RBcore/client_setting.c
  2. 66
      project/paint_robot_new/paint_robot_new.c

109
RBcore/client_setting.c

@ -0,0 +1,109 @@
/******************************************************************************
(C), 2018-2099, Radkil
******************************************************************************
: client_setting.c
: 稿
: radkil
: 2026820
:
: PVIV中间层
:
1. : 2026820
: 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);
}
}

66
project/paint_robot_new/paint_robot_new.c

@ -17,11 +17,7 @@
******************************************************************************/ ******************************************************************************/
#include "BHBF.h" #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 "../Protobuf/PSource/msp_MK32.pb.h"
#include <stdint.h>
/*----------------------------------------------* /*----------------------------------------------*
* * * *
@ -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);
}
}

Loading…
Cancel
Save