can のテストプログラム これは動く
Dependencies: mbed
Fork of RS485113D by
main.cpp
- Committer:
- taurin
- Date:
- 2016-01-23
- Revision:
- 2:0302f6a98ff0
- Parent:
- 1:d593f210a376
File content as of revision 2:0302f6a98ff0:
//can test driver #include "mbed.h" #define SENDID 1337 #define NUM 5 Ticker ticker; CAN can(p9, p10); char datas[NUM]; char counter=0; Serial pc(USBTX,USBRX); void send() { // printf("send()\n"); if(can.write(CANMessage(1, datas, NUM))) { //printf("wloop()\n"); for(int i = 0; i < NUM; i++){ datas[i] = i+counter; } counter++; //printf("Message sent: %d\n", counter); } } int main() { printf("mainSS()\n"); ticker.attach(&send, 1); CANMessage retmsg; while(1) { if(can.read(retmsg)){ pc.printf("retdata has come!!:%d\n\r",retmsg.data[0]); } //printf("loop()\n"); wait(0.2); } }