#include "soft_terrain.h"
#include "soft_device.h"
#include "soft_obstacle.h"
#include "soft_can.h"
#include "string.h"


uavr_terrain uavr56_info = {.get_radar_sensi = 50};
uavr_terrain mimo_ter_info; 
/**
  * @file    can_recv_mocib_terrain
  * @brief   莫之比防地解析
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void can_recv_mocib_terrain(uint8_t *data)
{
    uavr56_info.height = (data[0] << 8) + data[1];
    uavr56_info.Link.recv_time = HAL_GetTick();
    uavr56_info.Link.connect_status = COMP_NORMAL;
}


/**
  * @file    can_recv_enzhao_terrain
  * @brief   恩曌防地解析
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
mimo_part_radar T_radar[5] = {0};
void can_recv_enzhao_terrain(uint32_t CanID, uint8_t data[], uint8_t len)
{
    switch (CanID)
    {
    case CAN_MIMO_T_ID: //单点雷达
        mimo_ter_info.crc = data[3] + data[4] + data[5] + data[6];
        if (data[7] == mimo_ter_info.crc)
        {
            mimo_ter_info.height = (256 * data[4]) + (data[3]); //cm
            //  printf("%d          %d\n", mimo_ter_info.height, m.muniu_hight);   //输出到串口助手上 需要pringtf重定向
        }

        mimo_ter_info.Link.recv_time = HAL_GetTick();
        mimo_ter_info.Link.connect_status = COMP_NORMAL;
        Dev.Radar.facid_T = FAC_MIMO_RT;
        break;
    case CAN_MIMO_T_ID1:
        memcpy(&T_radar[0], data, 8);
        Dev.Part_Tradar_Link.recv_time = HAL_GetTick();
        Dev.Part_Tradar_Link.connect_status = COMP_NORMAL;
        Dev.Part_radarT.facid = FAC_MIMO_RT;
        break;
    case CAN_MIMO_T_ID2:
        memcpy(&T_radar[1], data, 8);
        break;
    case CAN_MIMO_T_ID3:
        memcpy(&T_radar[2], data, 8);
        break;
    case CAN_MIMO_T_ID4:
        memcpy(&T_radar[3], data, 8);
        break;
    case CAN_MIMO_T_ID5:
        memcpy(&T_radar[4], data, 8);
        break;
    default:
        break;
    }

}