mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
fixed function duplicated def issue
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* hunter_protocol_v1_parser.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jul 09, 2021 22:20
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Ruixiang Du (rdu)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HUNTER_PROTOCOL_V1_PARSER_HPP
|
||||||
|
#define HUNTER_PROTOCOL_V1_PARSER_HPP
|
||||||
|
|
||||||
|
#include "ugv_sdk/details/interface/parser_interface.hpp"
|
||||||
|
|
||||||
|
namespace westonrobot {
|
||||||
|
class HunterProtocolV1Parser : public ParserInterface {
|
||||||
|
public:
|
||||||
|
bool DecodeMessage(const struct can_frame *rx_frame,
|
||||||
|
AgxMessage *msg) override;
|
||||||
|
void EncodeMessage(const AgxMessage *msg,
|
||||||
|
struct can_frame *tx_frame) override;
|
||||||
|
uint8_t CalculateChecksum(uint16_t id, uint8_t *data, uint8_t dlc) override;
|
||||||
|
};
|
||||||
|
} // namespace westonrobot
|
||||||
|
|
||||||
|
#endif /* HUNTER_PROTOCOL_V1_PARSER_HPP */
|
||||||
@@ -53,7 +53,7 @@ RangerState RangerBase::GetRangerState() {
|
|||||||
|
|
||||||
void RangerBase::ParseCANFrame(can_frame *rx_frame) {
|
void RangerBase::ParseCANFrame(can_frame *rx_frame) {
|
||||||
AgxMessage status_msg;
|
AgxMessage status_msg;
|
||||||
DecodeCanFrame(rx_frame, &status_msg);
|
DecodeCanFrameV2(rx_frame, &status_msg);
|
||||||
std::lock_guard<std::mutex> guard(state_mutex_);
|
std::lock_guard<std::mutex> guard(state_mutex_);
|
||||||
UpdateRangerState(status_msg, ranger_state_);
|
UpdateRangerState(status_msg, ranger_state_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ TracerState TracerBaseV2::GetTracerState() {
|
|||||||
|
|
||||||
void TracerBaseV2::ParseCANFrame(can_frame *rx_frame) {
|
void TracerBaseV2::ParseCANFrame(can_frame *rx_frame) {
|
||||||
AgxMessage status_msg;
|
AgxMessage status_msg;
|
||||||
DecodeCanFrame(rx_frame, &status_msg);
|
DecodeCanFrameV2(rx_frame, &status_msg);
|
||||||
std::lock_guard<std::mutex> guard(state_mutex_);
|
std::lock_guard<std::mutex> guard(state_mutex_);
|
||||||
UpdateTracerState(status_msg, tracer_state_);
|
UpdateTracerState(status_msg, tracer_state_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,6 @@
|
|||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessageV1 *msg) {}
|
bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessageV1 *msg) {}
|
||||||
void EncodeCanFrame(const AgxMessageV1 *msg, struct can_frame *tx_frame) {}
|
void EncodeCanFrameV1(const AgxMessageV1 *msg, struct can_frame *tx_frame) {}
|
||||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc) {}
|
uint8_t CalcCanFrameChecksumV1(uint16_t id, uint8_t *data, uint8_t dlc) {}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ struct can_frame {
|
|||||||
|
|
||||||
#include "protocol_v1/agilex_message_v1.h"
|
#include "protocol_v1/agilex_message_v1.h"
|
||||||
|
|
||||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessageV1 *msg);
|
bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessageV1 *msg);
|
||||||
void EncodeCanFrame(const AgxMessageV1 *msg, struct can_frame *tx_frame);
|
void EncodeCanFrameV1(const AgxMessageV1 *msg, struct can_frame *tx_frame);
|
||||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc);
|
uint8_t CalcCanFrameChecksumV1(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg) {
|
bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg) {
|
||||||
msg->type = AgxMsgUnkonwn;
|
msg->type = AgxMsgUnkonwn;
|
||||||
|
|
||||||
switch (rx_frame->can_id) {
|
switch (rx_frame->can_id) {
|
||||||
@@ -309,7 +309,7 @@ bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeCanFrame(const AgxMessage *msg, struct can_frame *tx_frame) {
|
void EncodeCanFrameV2(const AgxMessage *msg, struct can_frame *tx_frame) {
|
||||||
switch (msg->type) {
|
switch (msg->type) {
|
||||||
/***************** command frame *****************/
|
/***************** command frame *****************/
|
||||||
case AgxMsgMotionCommand: {
|
case AgxMsgMotionCommand: {
|
||||||
@@ -595,7 +595,7 @@ void EncodeCanFrame(const AgxMessage *msg, struct can_frame *tx_frame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc) {
|
uint8_t CalcCanFrameChecksumV2(uint16_t id, uint8_t *data, uint8_t dlc) {
|
||||||
uint8_t checksum = 0x00;
|
uint8_t checksum = 0x00;
|
||||||
checksum = (uint8_t)(id & 0x00ff) + (uint8_t)(id >> 8) + dlc;
|
checksum = (uint8_t)(id & 0x00ff) + (uint8_t)(id >> 8) + dlc;
|
||||||
for (int i = 0; i < (dlc - 1); ++i) checksum += data[i];
|
for (int i = 0; i < (dlc - 1); ++i) checksum += data[i];
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ struct can_frame {
|
|||||||
|
|
||||||
#include "ugv_sdk/details/interface/agilex_message.h"
|
#include "ugv_sdk/details/interface/agilex_message.h"
|
||||||
|
|
||||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg);
|
bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg);
|
||||||
void EncodeCanFrame(const AgxMessage *msg, struct can_frame *tx_frame);
|
void EncodeCanFrameV2(const AgxMessage *msg, struct can_frame *tx_frame);
|
||||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc);
|
uint8_t CalcCanFrameChecksumV2(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,16 @@
|
|||||||
namespace westonrobot {
|
namespace westonrobot {
|
||||||
bool ProtocolV2Parser::DecodeMessage(const struct can_frame *rx_frame,
|
bool ProtocolV2Parser::DecodeMessage(const struct can_frame *rx_frame,
|
||||||
AgxMessage *msg) {
|
AgxMessage *msg) {
|
||||||
return DecodeCanFrame(rx_frame, msg);
|
return DecodeCanFrameV2(rx_frame, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolV2Parser::EncodeMessage(const AgxMessage *msg,
|
void ProtocolV2Parser::EncodeMessage(const AgxMessage *msg,
|
||||||
struct can_frame *tx_frame) {
|
struct can_frame *tx_frame) {
|
||||||
EncodeCanFrame(msg, tx_frame);
|
EncodeCanFrameV2(msg, tx_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ProtocolV2Parser::CalculateChecksum(uint16_t id, uint8_t *data,
|
uint8_t ProtocolV2Parser::CalculateChecksum(uint16_t id, uint8_t *data,
|
||||||
uint8_t dlc) {
|
uint8_t dlc) {
|
||||||
return CalcCanFrameChecksum(id, data, dlc);
|
return CalcCanFrameChecksumV2(id, data, dlc);
|
||||||
}
|
}
|
||||||
} // namespace westonrobot
|
} // namespace westonrobot
|
||||||
Reference in New Issue
Block a user