erste Gehversuche mit dem Can

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Jkestler
Date:
Thu Sep 14 16:24:16 2017 +0000
Parent:
0:bdd47badb8d2
Commit message:
Regler ansteuern;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 04 17:09:39 2017 +0000
+++ b/main.cpp	Thu Sep 14 16:24:16 2017 +0000
@@ -1,22 +1,38 @@
-#include "mbed.h"
- 
-Ticker ticker;
-DigitalOut led1(LED1);
+/*#include "mbed.h"
+
 DigitalOut led2(LED2);
-CAN can1(p9, p10);
 CAN can2(p30, p29,500000);
-char counter = 0;
 
- 
 int main() {
     printf("main()\n\r");
     CANMessage msg;
     while(1) {
-        printf("loop()\n\r");
         if(can2.read(msg)) {
-            printf("Message received: %d\n\r", msg.data[3]);
+            //printf("Message received: %x\t%x\t%x\t%x\t%x\t%x\t%x\t%x\t\n\r", msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]);    
+            printf("Drehzahl: %x%x%x%x\n\r",msg.data[0],msg.data[1],msg.data[2],msg.data[3]);            
             led2 = !led2;
         } 
         wait(0.2);
     }
-}
+}*/
+
+#include "mbed.h"
+
+DigitalOut led2(LED2);
+CAN can2(p30, p29,500000);
+
+int main() {
+    printf("main()\n\r");
+    CANMessage msg;
+    msg.format=CANExtended;
+    msg.id=0x0301;
+    msg.len=0x04;
+    msg.data[0]=0x00;
+    msg.data[1]=0x00;
+    msg.data[2]=0x07;
+    msg.data[3]=0xD0;
+    while(1) {
+        can2.write(msg);
+        wait_ms(20);
+    }
+}
\ No newline at end of file