1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-05-20 13:49:37 +02:00
cdf2018-principal/chef/src/diagnostics.c

57 lines
1,009 B
C
Raw Normal View History

2018-05-01 14:51:41 +02:00
#include <unistd.h>
#include "diagnostics.h"
#include "buttons.h"
#include "lcd.h"
#include "CF.h"
bool recu;
void setRecu()
{
recu = true;
}
bool diagFPGA()
{
recu = false;
registerRxHandler(C2FD_PING, setRecu);
sendCF(C2FD_PING, NULL, 0);
for (int i = 0; i <= DIAGNOSTIC_SERIAL_TIMEOUT; i += DIAGNOSTIC_POLL_INTERVAL) {
if (recu) {
break;
}
usleep(DIAGNOSTIC_POLL_INTERVAL * 1000);
}
return recu;
}
bool diagArduino()
{
return false;
}
void execDiagnostic(char *name, bool (*diagnostic)(void))
{
clearLCD();
printToLCD(LCD_LINE_1, name);
printToLCD(LCD_LINE_2, "...");
bool res = diagnostic();
if (res) {
printToLCD(LCD_LINE_2, "Ok!");
usleep(DIAGNOSTIC_INTERVAL * 1000);
} else {
printToLCD(LCD_LINE_2, "Echec!");
pressedButton(BUT_BLOCK);
}
}
void runDiagnostics()
{
execDiagnostic("Lien FPGA", diagFPGA);
/* execDiagnostic("Lien Arduino", diagArduino); */
}