Open
Conversation
bquan0
requested changes
Oct 12, 2024
Contributor
bquan0
left a comment
There was a problem hiding this comment.
Good start! I think we can make the code a little less repetitive though...
The main difference between the first readHandler() and sendSignal() and the second pair of functions is just the values you send and the CAN IDs of the messages. Thus, we could just define 2 sets of macros at the top, then use those macros in the functions:
#if IS_FIRST_CAN
#define CAN_MSG_ID_BASE 0x000
#define FLOAT_VAL 3.2
#define UINT8_VAL 98
...
#else
#define CAN_MSG_ID_BASE 0x100
#define FLOAT_VAL 12.3
#define UINT8_VAL 45
...
#endif
void CANDecoder::readHandler(CAN_data msg) {
switch (msg.id) {
case (CAN_MSG_ID_BASE + 0):
...
int CANDecoder::sendSignal() {
uint8_t test8int = UINT8_VAL;
Some other tips:
- In general, I recommend compiling the code and trying to fix the errors before pushing any commits.
- Don't forget to resolve the comments after you've fixed them. It helps with the reviewing process!
Contributor
|
Also, can you switch to the FW-221/canmanager branch in the |
…ion and comments from PR 'Check new CANDecoder Implementation'#1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request is to notify you that I finished the first (untested) versions of the 'candecoder.h' and 'candecoder.cpp' files so far.
Please let me know if the code seems to be as per your guidelines or if there are any issues and thus changes that I need to make.