erste Gehversuche mit dem Can
Dependencies: mbed
Diff: main.cpp
- Revision:
- 2:5f36f90dc534
- Parent:
- 1:7dc06c34b163
- Child:
- 3:ab76c978d2b9
--- a/main.cpp Thu Sep 14 16:24:16 2017 +0000 +++ b/main.cpp Wed Sep 20 14:41:14 2017 +0000 @@ -1,22 +1,24 @@ -/*#include "mbed.h" +#include "mbed.h" DigitalOut led2(LED2); CAN can2(p30, p29,500000); +int16_t n=0; int main() { printf("main()\n\r"); CANMessage msg; while(1) { if(can2.read(msg)) { + n = ((uint16_t)msg.data[2]<<8) + (uint16_t)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]); + printf("Drehzahl: %ld\n\r",n); led2 = !led2; } wait(0.2); } -}*/ +} -#include "mbed.h" +/*#include "mbed.h" DigitalOut led2(LED2); CAN can2(p30, p29,500000); @@ -29,10 +31,11 @@ msg.len=0x04; msg.data[0]=0x00; msg.data[1]=0x00; - msg.data[2]=0x07; + msg.data[2]=0x03; msg.data[3]=0xD0; while(1) { can2.write(msg); wait_ms(20); + } -} \ No newline at end of file +}