From 4ad58296a901e55d0da6f414c1e3a4562698bb14 Mon Sep 17 00:00:00 2001 From: Aslan Date: Wed, 7 Nov 2018 19:03:07 +0800 Subject: [PATCH] Update README.md --- CAN files/README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/CAN files/README.md b/CAN files/README.md index 1b8807f..e72c554 100644 --- a/CAN files/README.md +++ b/CAN files/README.md @@ -269,6 +269,62 @@ int main(void) } ``` +# first method of receiving CAN message + +1. Go to "can.c" and locate the function called "CanReceiveMsgProcess". +2. This function is what is used to do something with the received CAN messages. Inside the function, there's a switch statement that goes through each ID of the received message. So, you would have to figure out what the ID your device sends messages with, then add the ID to the switch statement. +For example, if my device send messages with the ID '0x200', then in the function "CanReceiveMsgProcess", I would makes the following changes: +```c +void CanReceiveMsgProcess(CAN_RxHeaderTypeDef *rxHeader,uint8_t* msg) +{ + + can_count++; + switch(rxHeader->StdId) + { + case 0x200: + { + // I made a new statement for 0x200 here + function_to_do_something_here(); + }break; + case CAN_BUS2_MOTOR1_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR2_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR3_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR4_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR5_FEEDBACK_MSG_ID: + { + + }break; + + case CAN_BUS2_MOTOR6_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR7_FEEDBACK_MSG_ID: + { + + }break; + case CAN_BUS2_MOTOR8_FEEDBACK_MSG_ID: + { + + }break; + + } + +} +``` + # Second method of receiving CAN message *Development in progress*