![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CAN a enviar_TLMoto
Fork of CANnucleo_Hello by
Revision 15:b1d0bf2626ed, committed 2016-06-27
- Comitter:
- Crazyaboutmachines
- Date:
- Mon Jun 27 16:09:13 2016 +0000
- Parent:
- 14:ff9c77b97bad
- Commit message:
- CAN nucleo a enviar
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Jun 26 15:11:08 2016 +0000 +++ b/main.cpp Mon Jun 27 16:09:13 2016 +0000 @@ -12,13 +12,13 @@ CANMessage rxMsg; int counter = 0; -Serial pc(SERIAL_TX, SERIAL_RX); +//Serial pc(SERIAL_TX, SERIAL_RX); int main() { - can1.frequency(100000); // set bit rate to 1Mbps - can2.frequency(100000); // set bit rate to 1Mbps + can1.frequency(40000); // set bit rate to 1Mbps + can2.frequency(40000); // set bit rate to 1Mbps led = 1; // turn LED on - pc.printf("pcprintf check"); + //pc.printf("pcprintf check"); while(1) { wait(10); @@ -27,9 +27,14 @@ // ledState = led.read(); // get led state ledState = 1; txMsg.clear(); // clear Tx message storage - txMsg.id = TX_ID; // set ID (9 bits) - txMsg << counter; // append first data item (32? bits?=4bytes) - txMsg << ledState; // append second data item (total data lenght must be <= 8 bytes!) (=4bytes) +// txMsg.id = TX_ID; // set ID (9 bits) + + + + txMsg=CANMessage(TX_ID,"a",1,CANData,CANStandard); + + //txMsg << counter; // append first data item (32? bits?=4bytes) + //txMsg << ledState; // append second data item (total data lenght must be <= 8 bytes!) (=4bytes) can1.write(txMsg); @@ -38,9 +43,9 @@ // else // led = 0; // turn LED off - if(can2.read(rxMsg)) { + if(can2.read(rxMsg,0)) { // pc.printf("Message received: %d\n", rxMsg.data[0]); - pc.printf("Message received: %d\n"); + // pc.printf("Message received: %d\n"); led = !led; }