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
Diff: main.cpp
- Revision:
- 1:12ddbe69b6e6
- Parent:
- 0:d9f4fedf5253
- Child:
- 2:373260769485
--- a/main.cpp Wed Nov 22 07:51:02 2017 +0000 +++ b/main.cpp Mon Nov 27 12:34:44 2017 +0000 @@ -1,10 +1,11 @@ /*** Thread: CAN *** - * Test CAN Messages - *WERKT 25/10/2017 + * Test CAN to controller + *TODO + *2 Ints samenvoegen zodat we naar het juiste register kunnen sturen, register is fixed, de waardes voor de controller zijn afhankelijk van een sensor. */ #include "mbed.h" #include "CAN.h" - +#include <string> /* CAN (RD TD) */ CAN can(PA_11, PA_12); @@ -38,23 +39,38 @@ data_packed send_data; //struct for send message data_packed receive_data; //struct for rcv message CANMessage msg; //message object for rcv - int send_id = 15; //send message id + int send_id = 513; //Id motorcontroller 0x201 -> 513 int send_status = 0; - canEN = 0; - /* Config Loopback and Frequency */ + canEN = 0; //Voor de tranceiver + + //send_data.data = 0x0CCD31; //0CCD snelheid motor, 31 register in controller. WERKT send_data.data = 0; - can.frequency(1000000); - //can.mode(CAN::LocalTest); - + can.frequency(1000000); //1m freq + can.mode(CAN::LocalTest); + //can.mode(CAN::Normal); //1vd2 comment /* Loop */ + int x = 0x0CCD; + int y = 0x31; + /*///////////////////////////////////////////////////////////// + int Result; + Result = a[5]; + Result = Result << 8; + Result = Result | b[2]; + *////////////////////////////////////////////////////////////// + + unsigned pow = 10; + while(y >= pow) + pow *= 10; + send_data.data = x * pow + y; + while (true) { - /* Send */ - send_status = can.write(CANMessage(send_id, (char*) &send_data, 8)); + send_status = can.write(CANMessage(send_id, (char*) &send_data, 3)); if (send_status == true) { - send_data.data = send_data.data + 1; + //send_data.data = send_data.data + 1; + } /* Receive */