1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-14 04:16:05 +01:00

Tolérance au loupage de message du FPGA

This commit is contained in:
Geoffrey Frogeye 2018-05-10 10:02:49 +02:00
parent 1337bd62a9
commit 63bf4ee3c3
3 changed files with 81 additions and 64 deletions

View file

@ -66,60 +66,64 @@ void loop()
bool codeInconnu = false;
switch (lettre) {
case 'L': // Ouverture loquet
servoLoquet.write(100);
delay(500);
break;
case 'F': // Fermeture loquet
servoLoquet.write(0);
delay(500);
break;
case 'A': // Position attente balle
servoPositionBalle.write(70);
delay(500);
break;
case 'V': // Position évacuation balle
servoPositionBalle.write(0);
delay(500);
break;
case 'O': // Pousser balle
// Position basse
servoPoussoir.write(0);
//delay(500);
// Position haute
servoPoussoir.write(120);
delay(1000);
break;
case 'B': // Tourner barillet d'un cran
barilletUnCran();
delay(500);
break;
case 'H': // Tourner de deux crans
barilletDeuxCrans();
delay(500);
break;
case 'R': // Reset barillet
// ax12a.setEndless(ID, OFF);
ax12a.setEndless(ID, ON);
ax12a.turn(ID, LEFT, 0);
ax12a.setEndless(ID, OFF);
ax12a.move(ID, pos_initial);
delay(500);
break;
case 'T': // Propulsion on
digitalWrite(relai_IN1, HIGH);
digitalWrite(relai_IN2, LOW);
//delay(4000);
break;
case 'U': // Propulsion off
digitalWrite(relai_IN1, LOW);
digitalWrite(relai_IN2, HIGH);
//delay(4000);
break;
case 'P': // Ping
break;
default:
codeInconnu = true;
case 'L': // Ouverture loquet
servoLoquet.write(100);
delay(500);
break;
case 'F': // Fermeture loquet
servoLoquet.write(0);
delay(500);
break;
case 'A': // Position attente balle
servoPositionBalle.write(70);
delay(500);
break;
case 'V': // Position évacuation balle
servoPositionBalle.write(0);
delay(500);
break;
case 'J': // Position ejection balle
servoPositionBalle.write(180);
delay(500);
break;
case 'O': // Pousser balle
// Position basse
servoPoussoir.write(0);
delay(500);
// Position haute
servoPoussoir.write(120);
delay(1000);
break;
case 'B': // Tourner barillet d'un cran
barilletUnCran();
delay(500);
break;
case 'H': // Tourner de deux crans
barilletDeuxCrans();
delay(500);
break;
case 'R': // Reset barillet
// ax12a.setEndless(ID, OFF);
ax12a.setEndless(ID, ON);
ax12a.turn(ID, LEFT, 0);
ax12a.setEndless(ID, OFF);
ax12a.move(ID, pos_initial);
delay(500);
break;
case 'T': // Propulsion on
digitalWrite(relai_IN1, HIGH);
digitalWrite(relai_IN2, LOW);
//delay(4000);
break;
case 'U': // Propulsion off
digitalWrite(relai_IN1, LOW);
digitalWrite(relai_IN2, HIGH);
//delay(4000);
break;
case 'P': // Ping
break;
default:
codeInconnu = true;
}
if (codeInconnu) {

View file

@ -5,6 +5,7 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "debug.h"
@ -29,14 +30,20 @@ void onF2CI_CODER()
pthread_mutex_unlock(&posPolling);
}
struct timespec maxDelayDelta = { 0, 10000000 };
void updateDelta()
{
// Sending
int ret = -1;
pthread_mutex_lock(&posPolling);
sendCF(F2CI_CODER, NULL, 0);
// Waiting for reception
pthread_mutex_lock(&posPolling);
while (ret != 0) {
// Sending
sendCF(F2CI_CODER, NULL, 0);
// Waiting for reception
ret = pthread_mutex_timedlock(&posPolling, &maxDelayDelta);
}
pthread_mutex_unlock(&posPolling);
}

View file

@ -19,15 +19,22 @@ void onF2CI_CAPT()
pthread_mutex_unlock(&secPolling);
}
struct timespec maxDelaySecu = { 0, 10000000 };
void* TaskSecurite(void* pData)
{
(void)pData;
for (;;) {
int ret = -1;
pthread_mutex_lock(&secPolling);
sendCF(F2CI_CAPT, NULL, 0);
// Waiting for reception
pthread_mutex_lock(&secPolling);
while (ret != 0) {
// Sending
sendCF(F2CI_CAPT, NULL, 0);
// Waiting for reception
ret = pthread_mutex_timedlock(&secPolling, &maxDelaySecu);
}
pthread_mutex_unlock(&secPolling);
pthread_mutex_lock(&secData);
@ -54,8 +61,8 @@ void configureSecurite()
pthread_mutex_init(&secPolling, NULL);
pthread_mutex_init(&secData, NULL);
registerRxHandlerCF(F2CI_CAPT, onF2CI_CAPT);
registerDebugVar("secFront", ld, &secFront);
registerDebugVar("secBack", ld, &secBack);
registerDebugVar("secFront", f, &secFront);
registerDebugVar("secBack", f, &secBack);
pthread_create(&tSecurite, NULL, TaskSecurite, NULL);
}
@ -63,4 +70,3 @@ void deconfigureSecurite()
{
pthread_cancel(tSecurite);
}