![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
version 2.6.5 mode normal en cours(problème de décalage) voir incrément et coefficient codeur
Dependencies: mbed
Fork of Robot_a_cables_v2_6 by
main.cpp@0:1ab5fdb4fa56, 2018-02-09 (annotated)
- Committer:
- LouisReynier
- Date:
- Fri Feb 09 20:49:17 2018 +0000
- Revision:
- 0:1ab5fdb4fa56
- Child:
- 1:4d70e593345f
Programme qui g?n?re la trame qui est sens?e faire passer le noeud 20 dans une autre dimension !; Test?e ? l'analyseur logique : ca marche !
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LouisReynier | 0:1ab5fdb4fa56 | 1 | #include "mbed.h" |
LouisReynier | 0:1ab5fdb4fa56 | 2 | // LR 9/02/18 |
LouisReynier | 0:1ab5fdb4fa56 | 3 | // |
LouisReynier | 0:1ab5fdb4fa56 | 4 | // bus CAN |
LouisReynier | 0:1ab5fdb4fa56 | 5 | // |
LouisReynier | 0:1ab5fdb4fa56 | 6 | // Ce programme genere une trame |
LouisReynier | 0:1ab5fdb4fa56 | 7 | // id=00, data= 01 20 , longueur = 2, can standard (11 bits id) |
LouisReynier | 0:1ab5fdb4fa56 | 8 | // |
LouisReynier | 0:1ab5fdb4fa56 | 9 | // testé à l'analyseur logique = OK !! |
LouisReynier | 0:1ab5fdb4fa56 | 10 | |
LouisReynier | 0:1ab5fdb4fa56 | 11 | Ticker ticker; |
LouisReynier | 0:1ab5fdb4fa56 | 12 | DigitalOut led1(LED1); |
LouisReynier | 0:1ab5fdb4fa56 | 13 | DigitalOut led2(LED2); |
LouisReynier | 0:1ab5fdb4fa56 | 14 | CAN can1(p9, p10,1000000);// on definit pin et debit |
LouisReynier | 0:1ab5fdb4fa56 | 15 | CAN can2(p30, p29, 1000000); |
LouisReynier | 0:1ab5fdb4fa56 | 16 | char counter = 0; |
LouisReynier | 0:1ab5fdb4fa56 | 17 | char octet_emis[8] = "ABCD"; |
LouisReynier | 0:1ab5fdb4fa56 | 18 | int id = 0x539 ; |
LouisReynier | 0:1ab5fdb4fa56 | 19 | |
LouisReynier | 0:1ab5fdb4fa56 | 20 | void send() { |
LouisReynier | 0:1ab5fdb4fa56 | 21 | |
LouisReynier | 0:1ab5fdb4fa56 | 22 | printf("send()\n"); |
LouisReynier | 0:1ab5fdb4fa56 | 23 | id = 0x00 ; |
LouisReynier | 0:1ab5fdb4fa56 | 24 | octet_emis[0] = 0x01 ; |
LouisReynier | 0:1ab5fdb4fa56 | 25 | octet_emis[1] = 0x20 ; |
LouisReynier | 0:1ab5fdb4fa56 | 26 | if(can1.write(CANMessage(id, octet_emis, 2, CANData, CANStandard ))) { |
LouisReynier | 0:1ab5fdb4fa56 | 27 | printf("wloop()\n"); |
LouisReynier | 0:1ab5fdb4fa56 | 28 | counter++; |
LouisReynier | 0:1ab5fdb4fa56 | 29 | printf("Message sent: %d\n", counter); |
LouisReynier | 0:1ab5fdb4fa56 | 30 | } |
LouisReynier | 0:1ab5fdb4fa56 | 31 | led1 = !led1; |
LouisReynier | 0:1ab5fdb4fa56 | 32 | } |
LouisReynier | 0:1ab5fdb4fa56 | 33 | |
LouisReynier | 0:1ab5fdb4fa56 | 34 | int main() { |
LouisReynier | 0:1ab5fdb4fa56 | 35 | |
LouisReynier | 0:1ab5fdb4fa56 | 36 | printf("main()\n"); |
LouisReynier | 0:1ab5fdb4fa56 | 37 | ticker.attach(&send, 1); |
LouisReynier | 0:1ab5fdb4fa56 | 38 | CANMessage msg; |
LouisReynier | 0:1ab5fdb4fa56 | 39 | while(1) { |
LouisReynier | 0:1ab5fdb4fa56 | 40 | printf("loop()\n"); |
LouisReynier | 0:1ab5fdb4fa56 | 41 | if(can2.read(msg)) { |
LouisReynier | 0:1ab5fdb4fa56 | 42 | printf("Message received: %d\n", msg.data[0]); |
LouisReynier | 0:1ab5fdb4fa56 | 43 | led2 = !led2; |
LouisReynier | 0:1ab5fdb4fa56 | 44 | } |
LouisReynier | 0:1ab5fdb4fa56 | 45 | wait(0.2); |
LouisReynier | 0:1ab5fdb4fa56 | 46 | } |
LouisReynier | 0:1ab5fdb4fa56 | 47 | } |