Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of testCAN1 by
main.cpp
00001 #include "mbed.h" 00002 // LR 9/02/18 00003 // 00004 // bus CAN 00005 // 00006 // Ce programme genere une trame remote qui "ping" le noeud 20 00007 // id=7XX ou XX adresse du noeud ici 720 , data= X , longueur = 0, can standard (11 bits id) 00008 // 00009 // testé à l'analyseur logique = OK !! 00010 00011 Ticker ticker; 00012 DigitalOut led1(LED1); 00013 DigitalOut led2(LED2); 00014 CAN can1(p9, p10,1000000);// on definit pin et debit 00015 CAN can2(p30, p29, 1000000); 00016 char counter = 0; 00017 char octet_emis[8] = "ABCD"; 00018 int id = 0x539 ; 00019 00020 void send() { 00021 00022 printf("send()\n"); 00023 id = 0x720 ; 00024 octet_emis[0] = 0x01 ; 00025 octet_emis[1] = 0x20 ; 00026 if(can1.write(CANMessage(id, octet_emis, 0, CANRemote, CANStandard ))) { 00027 // ici octet emis n'a pas de sens car trame remote ! 00028 printf("wloop()\n"); 00029 counter++; 00030 printf("Message sent: %d\n", counter); 00031 } 00032 led1 = !led1; 00033 } 00034 00035 int main() { 00036 00037 printf("main()\n"); 00038 ticker.attach(&send, 1); 00039 CANMessage msg; 00040 while(1) { 00041 printf("loop()\n"); 00042 if(can2.read(msg)) { 00043 printf("Message received: %d\n", msg.data[0]); 00044 led2 = !led2; 00045 } 00046 wait(0.2); 00047 } 00048 }
Generated on Fri Jul 15 2022 20:47:07 by
1.7.2
