Correction de problèmes dans la gestion du tampon tournant
This commit is contained in:
parent
a069a4e8d0
commit
83fa26be6d
@ -19,7 +19,7 @@ add_executable(Modele_RPiPico
|
|||||||
target_link_libraries(Modele_RPiPico
|
target_link_libraries(Modele_RPiPico
|
||||||
hardware_uart
|
hardware_uart
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
pico_multicore
|
pico_multicore
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_enable_stdio_usb(Modele_RPiPico 1)
|
pico_enable_stdio_usb(Modele_RPiPico 1)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "pico/error.h"
|
#include "pico/error.h"
|
||||||
#include "pico/stdio.h"
|
#include <stdio.h>
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
#include "messagerie.h"
|
#include "messagerie.h"
|
||||||
|
|
||||||
@ -63,7 +63,12 @@ void communication_reception_message(){
|
|||||||
// Parce que c'est plus simple à traiter
|
// Parce que c'est plus simple à traiter
|
||||||
index_chaine_recue = 0;
|
index_chaine_recue = 0;
|
||||||
index_tampon = com_reception_buffer.index_tampon_lecture;
|
index_tampon = com_reception_buffer.index_tampon_lecture;
|
||||||
while(index_tampon != com_reception_buffer.index_tampon_ecriture){
|
if(index_tampon != com_reception_buffer.index_tampon_ecriture){
|
||||||
|
while(index_tampon != com_reception_buffer.index_tampon_ecriture){
|
||||||
|
chaîne_octets_reçus[index_chaine_recue] = com_reception_buffer.tampon[index_tampon];
|
||||||
|
index_chaine_recue++;
|
||||||
|
increment_index(&index_tampon);
|
||||||
|
}
|
||||||
chaîne_octets_reçus[index_chaine_recue] = com_reception_buffer.tampon[index_tampon];
|
chaîne_octets_reçus[index_chaine_recue] = com_reception_buffer.tampon[index_tampon];
|
||||||
index_chaine_recue++;
|
index_chaine_recue++;
|
||||||
increment_index(&index_tampon);
|
increment_index(&index_tampon);
|
||||||
@ -80,10 +85,7 @@ void communication_reception_message(){
|
|||||||
if(i+3 < index_chaine_recue){
|
if(i+3 < index_chaine_recue){
|
||||||
message.taille_donnees = chaîne_octets_reçus[i+3];
|
message.taille_donnees = chaîne_octets_reçus[i+3];
|
||||||
}
|
}
|
||||||
for(int z=0; z<=4 + message.taille_donnees; z++ ){
|
|
||||||
printf("%d ", chaîne_octets_reçus[i+z]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
index_fin_message = i+4 + message.taille_donnees;
|
index_fin_message = i+4 + message.taille_donnees;
|
||||||
if(index_fin_message < index_chaine_recue){
|
if(index_fin_message < index_chaine_recue){
|
||||||
if(chaîne_octets_reçus[index_fin_message] == 0){
|
if(chaîne_octets_reçus[index_fin_message] == 0){
|
||||||
|
|||||||
19
main.c
19
main.c
@ -6,9 +6,12 @@
|
|||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <pico/stdio.h>
|
||||||
|
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
#include "messagerie.h"
|
#include "messagerie.h"
|
||||||
|
|
||||||
|
|
||||||
void stdio_usb_out_chars(const char *buf, int length);
|
void stdio_usb_out_chars(const char *buf, int length);
|
||||||
|
|
||||||
#define NB_MORCEAUX 100
|
#define NB_MORCEAUX 100
|
||||||
@ -78,6 +81,7 @@ void main(void)
|
|||||||
int nb_ech = 10;
|
int nb_ech = 10;
|
||||||
int taille_morceau = 60;
|
int taille_morceau = 60;
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
sleep_ms(5000);
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||||
@ -85,6 +89,7 @@ void main(void)
|
|||||||
temps_message_detection = get_absolute_time();
|
temps_message_detection = get_absolute_time();
|
||||||
|
|
||||||
communication_init();
|
communication_init();
|
||||||
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
@ -92,22 +97,20 @@ void main(void)
|
|||||||
envoie_structure(&message_requete_detection, sizeof(message_requete_detection) );
|
envoie_structure(&message_requete_detection, sizeof(message_requete_detection) );
|
||||||
temps_message_detection = get_absolute_time();
|
temps_message_detection = get_absolute_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
start_time_us = get_absolute_time();
|
|
||||||
//envoie_donnees(message_binaire, 10);
|
|
||||||
current_time_us = get_absolute_time();
|
|
||||||
//printf(">temps:%lld\n", current_time_us - start_time_us);
|
|
||||||
|
|
||||||
start_time_us = get_absolute_time();
|
start_time_us = get_absolute_time();
|
||||||
communication_reception_message();
|
communication_reception_message();
|
||||||
while(messagerie_message_disponible()){
|
while(messagerie_message_disponible()){
|
||||||
|
printf("Message disponible\n");
|
||||||
message = messagerie_get_message();
|
message = messagerie_get_message();
|
||||||
if(message.type == 'r'){
|
if(message.type == 'r'){
|
||||||
if(message.id_carte == 'D'){
|
if(message.id_carte == 'D'){
|
||||||
temps_message_detection = get_absolute_time();
|
temps_message_detection = get_absolute_time();
|
||||||
if(message.donnees[1] > 0 && message.donnees[1] < 30){
|
if(message.donnees[0] > 0 && message.donnees[0] < 30){
|
||||||
|
printf(">LED ON\n");
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||||
}else{
|
}else{
|
||||||
|
printf(">LED OFF\n");
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,9 +118,8 @@ void main(void)
|
|||||||
}
|
}
|
||||||
current_time_us = get_absolute_time();
|
current_time_us = get_absolute_time();
|
||||||
|
|
||||||
putchar('\n');
|
|
||||||
printf(">temps:%lld\n", current_time_us - start_time_us);
|
printf(">temps:%lld\n", current_time_us - start_time_us);
|
||||||
sleep_ms(50);
|
//sleep_ms(50);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,3 +142,4 @@ absolute_time_t envoie_nb_char(int nb_char) {
|
|||||||
chaine_envoie[nb_char] = 'a';
|
chaine_envoie[nb_char] = 'a';
|
||||||
return current_time_us - start_time_us;
|
return current_time_us - start_time_us;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user