Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_PLC01A1 ros_lib_melodic
Diff: can_controller.cpp
- Revision:
- 3:ea5cfd721b53
- Parent:
- 1:ef4b86795d79
--- a/can_controller.cpp Sat Aug 15 09:21:36 2020 +0000
+++ b/can_controller.cpp Sun Aug 30 06:39:43 2020 +0000
@@ -4,7 +4,16 @@
* @brief Initialize CAN controller
* @param None
*/
-CANController::CANController():can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD){}
+CANController::CANController():_can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD){
+// _NoData[0] = 'N';
+// _NoData[1] = 'o';
+// _NoData[2] = ',';
+// _NoData[3] = 'D';
+// _NoData[4] = 'a';
+// _NoData[5] = 'T';
+// _NoData[6] = 'a';
+// _NoData[7] = '.';
+}
/**
* @brief Send CAN message
@@ -14,10 +23,19 @@
*/
int CANController::sendMessage( uint16_t ID, char *msgData ){
CANMessage msg(ID, msgData, 8, CANData, CANStandard);
- int successFlag = can1.write(msg);
+ int successFlag = _can1.write(msg);
if(successFlag){
return 0;
}else{
return -1;
}
}
+
+unsigned char *CANController::recieveMessage( uint16_t ID ){
+ while(_can1.read(_rmsg)){
+ if(_rmsg.id == ID){
+ return _rmsg.data;
+ }
+ }
+ return _NoData;
+}
\ No newline at end of file