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:
@@ -13,6 +13,6 @@
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessageV1 *msg) {}
|
||||
void EncodeCanFrame(const AgxMessageV1 *msg, struct can_frame *tx_frame) {}
|
||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc) {}
|
||||
bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessageV1 *msg) {}
|
||||
void EncodeCanFrameV1(const AgxMessageV1 *msg, struct can_frame *tx_frame) {}
|
||||
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"
|
||||
|
||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessageV1 *msg);
|
||||
void EncodeCanFrame(const AgxMessageV1 *msg, struct can_frame *tx_frame);
|
||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||
bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessageV1 *msg);
|
||||
void EncodeCanFrameV1(const AgxMessageV1 *msg, struct can_frame *tx_frame);
|
||||
uint8_t CalcCanFrameChecksumV1(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "stdio.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;
|
||||
|
||||
switch (rx_frame->can_id) {
|
||||
@@ -309,7 +309,7 @@ bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg) {
|
||||
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) {
|
||||
/***************** command frame *****************/
|
||||
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;
|
||||
checksum = (uint8_t)(id & 0x00ff) + (uint8_t)(id >> 8) + dlc;
|
||||
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"
|
||||
|
||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg);
|
||||
void EncodeCanFrame(const AgxMessage *msg, struct can_frame *tx_frame);
|
||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||
bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg);
|
||||
void EncodeCanFrameV2(const AgxMessage *msg, struct can_frame *tx_frame);
|
||||
uint8_t CalcCanFrameChecksumV2(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
namespace westonrobot {
|
||||
bool ProtocolV2Parser::DecodeMessage(const struct can_frame *rx_frame,
|
||||
AgxMessage *msg) {
|
||||
return DecodeCanFrame(rx_frame, msg);
|
||||
return DecodeCanFrameV2(rx_frame, msg);
|
||||
}
|
||||
|
||||
void ProtocolV2Parser::EncodeMessage(const AgxMessage *msg,
|
||||
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 dlc) {
|
||||
return CalcCanFrameChecksum(id, data, dlc);
|
||||
return CalcCanFrameChecksumV2(id, data, dlc);
|
||||
}
|
||||
} // namespace westonrobot
|
||||
Reference in New Issue
Block a user