AresENSEA-CDF2020
/
AresCDFMainCode_us2
Test
debugBT.cpp@5:34ed652f8c31, 2020-07-21 (annotated)
- Committer:
- Nanaud
- Date:
- Tue Jul 21 19:33:38 2020 +0000
- Revision:
- 5:34ed652f8c31
- Parent:
- 4:ad9b7355332e
- Child:
- 10:0714feaaaee1
Commande Bluetooth test moteur
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 | 5:34ed652f8c31 | 19 | |
Nanaud | 5:34ed652f8c31 | 20 | if((buffer[i] >= 48 && buffer[i] <=57) || (buffer[i]>=97 && buffer[i]<=122) || buffer[i]==13) i++; |
Nanaud | 4:ad9b7355332e | 21 | } |
Nanaud | 4:ad9b7355332e | 22 | |
Nanaud | 4:ad9b7355332e | 23 | if(buffer[i-1]=='\r') { |
Nanaud | 4:ad9b7355332e | 24 | pc.printf("\r\n"); |
Nanaud | 4:ad9b7355332e | 25 | bt.printf("\r\n"); |
Nanaud | 4:ad9b7355332e | 26 | i=0; |
Nanaud | 4:ad9b7355332e | 27 | |
Nanaud | 4:ad9b7355332e | 28 | copieTab(buffer,cmd); |
Nanaud | 4:ad9b7355332e | 29 | |
Nanaud | 4:ad9b7355332e | 30 | switch(cmdType) { |
Nanaud | 4:ad9b7355332e | 31 | case 1 : // Commande test angle |
Nanaud | 4:ad9b7355332e | 32 | StringToAngle(cmd); |
Nanaud | 4:ad9b7355332e | 33 | cmdType=0; |
Nanaud | 4:ad9b7355332e | 34 | break; |
Nanaud | 5:34ed652f8c31 | 35 | case 2 : // Commande test vitesse |
Nanaud | 5:34ed652f8c31 | 36 | StringToVitesse(cmd); |
Nanaud | 5:34ed652f8c31 | 37 | cmdType=0; |
Nanaud | 5:34ed652f8c31 | 38 | break; |
Nanaud | 4:ad9b7355332e | 39 | default : // Commande par défaut |
Nanaud | 4:ad9b7355332e | 40 | cmdChoice(cmd); |
Nanaud | 4:ad9b7355332e | 41 | } |
Nanaud | 4:ad9b7355332e | 42 | } |
Nanaud | 4:ad9b7355332e | 43 | } |