Mario Vargas
/
CANTX
canok
Revision 1:5750eb0e53b2, committed 2022-10-13
- Comitter:
- mvargas_dtk
- Date:
- Thu Oct 13 00:29:59 2022 +0000
- Parent:
- 0:0e8e4d659972
- Commit message:
- ok
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 12 14:44:25 2022 +0000 +++ b/main.cpp Thu Oct 13 00:29:59 2022 +0000 @@ -36,42 +36,74 @@ led1 = 0; BT_RST = 1; wait_ms(5000); - CANMessage msg; + CANMessage msg1; + CANMessage msg2; + CANMessage msg3; + // msg.format = CANExtended;// or CANExtended; // standard or extended ID (can be skipped for standard) + msg1.id = 1337; + msg1.len = 8;//length in bytes (1 to 8); + //msg1.data[0] = 1; // repeat for each byte. + //msg1.data[1] = 2; + //msg1.data[2] = 3; + //msg1.data[3] = 4; + //msg1.data[4] = 5; + //msg1.data[5] = 6; + //msg1.data[6] = 7; + //msg1.data[7] = 8; - //RS485.printf("main()\n"); - //RS485.printf("send()\n"); + msg2.id = 1338; + msg2.len = 8;//length in bytes (1 to 8); + msg2.data[0] = 100; // repeat for each byte. + msg2.data[1] = 200; + msg2.data[2] = 40; + msg2.data[3] = 30; + msg2.data[4] = 20; + msg2.data[5] = 10; + msg2.data[6] = 5; + msg2.data[7] = 0; + + + msg3.id = 1339; + msg3.len = 8;//length in bytes (1 to 8); + msg3.data[0] = 10; // repeat for each byte. + msg3.data[1] = 20; + msg3.data[2] = 10; + msg3.data[3] = 20; + msg3.data[4] = 10; + msg3.data[5] = 20; + msg3.data[6] = 10; + msg3.data[7] = 20; + + + BT.printf("BT Inicio\n"); - //BT.printf("send()\n"); - //if(can1.write(CANMessage(1337, &counter, 1))) { - //RS485.printf("wloop()\n"); - //counter++; - //RS485.printf("Message sent: %d\n", counter); - // BT.printf("Message sent: %d\n", counter); - //} - //led1 = !led1; - //RS485.printf("main end()\n"); - //BT.printf("Message sent: %d\n", counter); - while(1) { - can1.write(CANMessage(1337, &counter, 8)); + for (int i = 1; i<=5; i++){ + + msg1.data[0] = i; // repeat for each byte. + msg1.data[1] = i+20; + msg1.data[2] = i+40; + msg1.data[3] = i+60; + msg1.data[4] = i+80; + msg1.data[5] = i+100; + msg1.data[6] = i+120; + msg1.data[7] = i+140; + can1.write(msg1); + wait_ms(1000); + } + + + // can1.write(msg2); + + // can1.write(msg3); + BT.printf("BTMessage sent: %d\n", counter); - can1.write(CANMessage(1338, &counter1, 8)); - BT.printf("BTMessage sent: %d\n", counter1); - can1.write(CANMessage(1339, &counter2, 8)); - BT.printf("BTMessage sent: %d\n", counter2); - //if(can1.write(CANMessage(1337, &counter, 1))) { - //BT.printf("BTMessage sent: %d\n", counter); - // } - led1 = !led1; - wait_ms(1000); - // printf("loop()\n"); - // if(can2.read(msg)) { - // printf("Message received: %d\n", msg.data[0]); - // led2 = !led2; - // } - //wait_ms(200); + + led1 = !led1; + wait_ms(1000); + } } \ No newline at end of file