Skip to content

Commit

Permalink
agx_parser: fixed return value isse when not decoding successfully, t…
Browse files Browse the repository at this point in the history
…o address pull request westonrobot#33
  • Loading branch information
rdu-weston committed May 31, 2023
1 parent 1125391 commit db7a0f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/protocol_v1/agilex_msg_parser_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "string.h"

bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessage *msg) {
bool ret = true;
// if checksum not correct
if (!CalcCanFrameChecksumV1(rx_frame->can_id, (uint8_t *)rx_frame->data,
rx_frame->can_dlc)) {
Expand Down Expand Up @@ -87,10 +88,11 @@ bool DecodeCanFrameV1(const struct can_frame *rx_frame, AgxMessage *msg) {
break;
}
default:
ret = false;
break;
}

return true;
return ret;
}

bool EncodeCanFrameV1(const AgxMessage *msg, struct can_frame *tx_frame) {
Expand Down
4 changes: 3 additions & 1 deletion src/protocol_v2/agilex_msg_parser_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "math.h"

bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg) {
bool ret = true;
msg->type = AgxMsgUnkonwn;

switch (rx_frame->can_id) {
Expand Down Expand Up @@ -372,10 +373,11 @@ bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg) {
break;
}
default:
ret = false;
break;
}

return true;
return ret;
}

bool EncodeCanFrameV2(const AgxMessage *msg, struct can_frame *tx_frame) {
Expand Down

0 comments on commit db7a0f2

Please sign in to comment.