AresENSEA-CDF2020
/
AresCDFMainCode_us2
Test
debugBT.cpp@4:ad9b7355332e, 2020-07-18 (annotated)
- Committer:
- Nanaud
- Date:
- Sat Jul 18 17:09:08 2020 +0000
- Revision:
- 4:ad9b7355332e
- Child:
- 5:34ed652f8c31
Ajout du debug en Bluetooth (Module HC-05)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nanaud | 4:ad9b7355332e | 1 | // Nom du fichier : debugBT.cpp |
Nanaud | 4:ad9b7355332e | 2 | #include "pins.h" |
Nanaud | 4:ad9b7355332e | 3 | |
Nanaud | 4:ad9b7355332e | 4 | // Variables globales & timers |
Nanaud | 4:ad9b7355332e | 5 | Serial bt(PC_6,PC_7); |
Nanaud | 4:ad9b7355332e | 6 | |
Nanaud | 4:ad9b7355332e | 7 | void bluetoothIT() |
Nanaud | 4:ad9b7355332e | 8 | { |
Nanaud | 4:ad9b7355332e | 9 | static int i=0; |
Nanaud | 4:ad9b7355332e | 10 | static char buffer[10]=""; // Tableau qui contient la chaine de caractère rentrée dans le terminal. |
Nanaud | 4:ad9b7355332e | 11 | static char cmd[Lcmd]=""; // Variable qui retient que les premiers caractères qui représentent la commande. |
Nanaud | 4:ad9b7355332e | 12 | |
Nanaud | 4:ad9b7355332e | 13 | //printf("bt.readable = %d \r\n",bt.readable()); |
Nanaud | 4:ad9b7355332e | 14 | while(bt.readable()) { // if(bt.readable()) |
Nanaud | 4:ad9b7355332e | 15 | //pc.printf("bt.readable = %d \r\n",bt.readable()); |
Nanaud | 4:ad9b7355332e | 16 | buffer[i]=bt.getc(); |
Nanaud | 4:ad9b7355332e | 17 | pc.printf("%c",buffer[i]); |
Nanaud | 4:ad9b7355332e | 18 | bt.printf("%c",buffer[i]); |
Nanaud | 4:ad9b7355332e | 19 | i++; |
Nanaud | 4:ad9b7355332e | 20 | } |
Nanaud | 4:ad9b7355332e | 21 | |
Nanaud | 4:ad9b7355332e | 22 | if(buffer[i-1]=='\r') { |
Nanaud | 4:ad9b7355332e | 23 | pc.printf("\r\n"); |
Nanaud | 4:ad9b7355332e | 24 | bt.printf("\r\n"); |
Nanaud | 4:ad9b7355332e | 25 | i=0; |
Nanaud | 4:ad9b7355332e | 26 | |
Nanaud | 4:ad9b7355332e | 27 | copieTab(buffer,cmd); |
Nanaud | 4:ad9b7355332e | 28 | |
Nanaud | 4:ad9b7355332e | 29 | switch(cmdType) { |
Nanaud | 4:ad9b7355332e | 30 | case 1 : // Commande test angle |
Nanaud | 4:ad9b7355332e | 31 | StringToAngle(cmd); |
Nanaud | 4:ad9b7355332e | 32 | cmdType=0; |
Nanaud | 4:ad9b7355332e | 33 | break; |
Nanaud | 4:ad9b7355332e | 34 | default : // Commande par défaut |
Nanaud | 4:ad9b7355332e | 35 | cmdChoice(cmd); |
Nanaud | 4:ad9b7355332e | 36 | } |
Nanaud | 4:ad9b7355332e | 37 | } |
Nanaud | 4:ad9b7355332e | 38 | } |