1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-21 23:56:04 +01:00

Outils de debug

This commit is contained in:
Geoffrey Frogeye 2018-02-14 18:27:04 +01:00
parent d795e2d906
commit 0a9009d0c3
7 changed files with 73 additions and 15 deletions

View file

@ -1,3 +1,7 @@
/*
* Définition des fonctions utilisées pour échager entre l'Arduino et le chef
*/
#ifndef __SERIAL_H_ #ifndef __SERIAL_H_
#define __SERIAL_H_ #define __SERIAL_H_

View file

@ -7,6 +7,13 @@
#define AC_BAUDRATE 9600UL #define AC_BAUDRATE 9600UL
// Structures used everywhere
struct position {
float x;
float y;
float o;
};
// D: Direct // D: Direct
// Sens naturel : Envoi de donnée // Sens naturel : Envoi de donnée
// Sens inverse : Accusé de réception // Sens inverse : Accusé de réception
@ -33,11 +40,8 @@ struct C2ADD_STOPs {
// Donne une destination // Donne une destination
#define C2AD_GOTO 'G' #define C2AD_GOTO 'G'
struct C2AD_GOTOs { #define C2AD_GOTOs position
float x; // Peut-être o à NaN ou autre valeur spécifique si indifférent
float y;
float o; // Peut-être NaN ou autre valeur spécifique si indifférent
};
// Arduino → Chef // Arduino → Chef
@ -52,9 +56,9 @@ struct A2CI_ERRs {
// Envoie les infos de debug // Envoie les infos de debug
#define A2CI_DBG 'D' #define A2CI_DBG 'D'
struct A2CI_DBGs { struct A2CI_DBGs {
float x; struct position actuel;
float y; struct position destination;
float o; unsigned char movement;
// ... // ...
}; };

View file

@ -29,7 +29,7 @@ FORMAT = ihex
# Target file name (without extension). # Target file name (without extension).
TARGET = principal TARGET = principal
OBJS = AC position movement OBJS = AC position movement debug
# Custom # Custom
NAME = $(TARGET).c NAME = $(TARGET).c

32
arduino/debug.c Normal file
View file

@ -0,0 +1,32 @@
#include <string.h>
#include "debug.h"
#include "AC.h"
#include "position.h"
#include "movement.h"
void TaskDebug(void *pvParameters) {
(void) pvParameters;
for (;;) {
vTaskSuspend(tDebug);
// Copie des valeurs à envoyer en debug
memcpy((void*) &debug.actuel, (const void*) &actuel, (unsigned long) sizeof(actuel));
memcpy((void*) &debug.destination, (const void*) &destination, (unsigned long) sizeof(destination));
debug.movement = movement;
// Envoi des valeurs
sendAC(A2CI_DBG, &debug, sizeof(debug));
}
}
void onA2CI_DBG() {
vTaskResume(tDebug);
}
void configureDebug() {
registerRxHandler(A2CI_DBG, onA2CI_DBG);
xTaskCreate(TaskDebug, "Debug", 128, NULL, 10, &tDebug);;
}

18
arduino/debug.h Normal file
View file

@ -0,0 +1,18 @@
/*
* Outils pour envoyer des informations de debug au chef
*/
#ifndef __DEBUG_H_
#define __DEBUG_H_
#include <FreeRTOS.h>
#include <task.h>
TaskHandle_t tDebug;
struct A2CI_DBGs debug;
void TaskDebug();
void configureDebug();
#endif

View file

@ -8,11 +8,9 @@
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <task.h> #include <task.h>
struct position { #include "ACsignals.h"
float x;
float y; struct position actuel;
float o;
};
TaskHandle_t tPosition; TaskHandle_t tPosition;

View file

@ -6,6 +6,7 @@
#include "AC.h" #include "AC.h"
#include "position.h" #include "position.h"
#include "movement.h" #include "movement.h"
#include "debug.h"
unsigned char speed = 200; unsigned char speed = 200;
@ -24,9 +25,10 @@ void TaskBlink(void *pvParameters) {
} }
int main(void) { int main(void) {
configureAC(); configureAC(); // Doit rester en premier :)
configureMovement(); configureMovement();
configurePosition(); configurePosition();
configureDebug();
xTaskCreate(TaskBlink, "Blink", 128, NULL, 2, NULL); xTaskCreate(TaskBlink, "Blink", 128, NULL, 2, NULL);
sei(); sei();