![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
can_test for my case
main.cpp
- Committer:
- hirokimineshita
- Date:
- 2016-04-04
- Revision:
- 0:24cfc59b5220
File content as of revision 0:24cfc59b5220:
#include "mbed.h" Ticker ticker; DigitalOut led1(LED1); DigitalOut led2(LED2); //BusOut led(LED1,LED2,LED3,LED4); CAN can2(p9, p10); CAN can1(p30, p29); char counter[8] = {0,0,0,0,0,0,0,0}; int sub=0,j=1,count=0; void send() { //printf("send()\n\r"); //led=counter[0]; if(j>40)j=1; if(can2.write(CANMessage(j, counter, 8))) { //printf("wloop()\n\r"); //printf("Message sent :%3d: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n\r",j, counter[0],counter[1],counter[2],counter[3],counter[4],counter[5],counter[6],counter[7]); sub++; if(count==2){ j++; count=0; } count++; for(int i=0;i<8;i++)counter[i]=(sub>>(i*8))&255; counter[7]=(4*3-j)/(4*3-j); } led1 = !led1; } int main() { //led=0; can2.frequency(1000000); printf("main()\n\r"); //ticker.attach(&send, 0.1); CANMessage msg; while(1) { //printf("loop()\n\r"); if(can2.read(msg)){ printf("%3d:%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n\r",msg.id,msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]); if(msg.id==4)led2 = !led2; } //led=msg.data[0]; //wait(0.2); } }