1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-21 23:56:04 +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

@ -82,10 +82,14 @@ void loop()
servoPositionBalle.write(0); servoPositionBalle.write(0);
delay(500); delay(500);
break; break;
case 'J': // Position ejection balle
servoPositionBalle.write(180);
delay(500);
break;
case 'O': // Pousser balle case 'O': // Pousser balle
// Position basse // Position basse
servoPoussoir.write(0); servoPoussoir.write(0);
//delay(500); delay(500);
// Position haute // Position haute
servoPoussoir.write(120); servoPoussoir.write(120);
delay(1000); delay(1000);

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);
while (ret != 0) {
// Sending
sendCF(F2CI_CODER, NULL, 0);
// Waiting for reception // Waiting for reception
pthread_mutex_lock(&posPolling); 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);
while (ret != 0) {
// Sending
sendCF(F2CI_CAPT, NULL, 0); sendCF(F2CI_CAPT, NULL, 0);
// Waiting for reception // Waiting for reception
pthread_mutex_lock(&secPolling); 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);
} }