1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-21 15:46:06 +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; bool codeInconnu = false;
switch (lettre) { switch (lettre) {
case 'L': // Ouverture loquet case 'L': // Ouverture loquet
servoLoquet.write(100); servoLoquet.write(100);
delay(500); delay(500);
break; break;
case 'F': // Fermeture loquet case 'F': // Fermeture loquet
servoLoquet.write(0); servoLoquet.write(0);
delay(500); delay(500);
break; break;
case 'A': // Position attente balle case 'A': // Position attente balle
servoPositionBalle.write(70); servoPositionBalle.write(70);
delay(500); delay(500);
break; break;
case 'V': // Position évacuation balle case 'V': // Position évacuation balle
servoPositionBalle.write(0); servoPositionBalle.write(0);
delay(500); delay(500);
break; break;
case 'O': // Pousser balle case 'J': // Position ejection balle
// Position basse servoPositionBalle.write(180);
servoPoussoir.write(0); delay(500);
//delay(500); break;
// Position haute case 'O': // Pousser balle
servoPoussoir.write(120); // Position basse
delay(1000); servoPoussoir.write(0);
break; delay(500);
case 'B': // Tourner barillet d'un cran // Position haute
barilletUnCran(); servoPoussoir.write(120);
delay(500); delay(1000);
break; break;
case 'H': // Tourner de deux crans case 'B': // Tourner barillet d'un cran
barilletDeuxCrans(); barilletUnCran();
delay(500); delay(500);
break; break;
case 'R': // Reset barillet case 'H': // Tourner de deux crans
// ax12a.setEndless(ID, OFF); barilletDeuxCrans();
ax12a.setEndless(ID, ON); delay(500);
ax12a.turn(ID, LEFT, 0); break;
ax12a.setEndless(ID, OFF); case 'R': // Reset barillet
ax12a.move(ID, pos_initial); // ax12a.setEndless(ID, OFF);
delay(500); ax12a.setEndless(ID, ON);
break; ax12a.turn(ID, LEFT, 0);
case 'T': // Propulsion on ax12a.setEndless(ID, OFF);
digitalWrite(relai_IN1, HIGH); ax12a.move(ID, pos_initial);
digitalWrite(relai_IN2, LOW); delay(500);
//delay(4000); break;
break; case 'T': // Propulsion on
case 'U': // Propulsion off digitalWrite(relai_IN1, HIGH);
digitalWrite(relai_IN1, LOW); digitalWrite(relai_IN2, LOW);
digitalWrite(relai_IN2, HIGH); //delay(4000);
//delay(4000); break;
break; case 'U': // Propulsion off
case 'P': // Ping digitalWrite(relai_IN1, LOW);
break; digitalWrite(relai_IN2, HIGH);
default: //delay(4000);
codeInconnu = true; break;
case 'P': // Ping
break;
default:
codeInconnu = true;
} }
if (codeInconnu) { if (codeInconnu) {

View file

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

View file

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