From 148d53fa8636896db473391d68e90ba183cf9863 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 10 Sep 2025 13:03:19 +0200 Subject: [PATCH] Construction du tampon d'envoi en dehors de la boucle de performance --- .vscode/settings.json | 2 +- main.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c988ddf..7668934 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "files.associations": { - + "stdio_usb.h": "c" } } \ No newline at end of file diff --git a/main.c b/main.c index de277c0..c8a21ae 100644 --- a/main.c +++ b/main.c @@ -6,17 +6,37 @@ #include "pico/stdlib.h" #include +void stdio_usb_out_chars(const char *buf, int length); + #define NB_MORCEAUX 100 absolute_time_t envoie_nb_char(int nb_char); +char message[10000]; + +void envoie_donnees(char * donnees, u_int16_t length){ + for (int i=0; i25){ + j=0; + } + message[i]= j + 'a';*/ + message[i]= i%26 + 'a'; + } int nb_ech = 10; - int taille_morceau = 120; + int taille_morceau = 60; stdio_init_all(); while(1){ temps_moyen = 0; @@ -26,6 +46,7 @@ void main(void) temps_max = 0; start_time_us = get_absolute_time(); temps_m[i] = envoie_nb_char(taille_morceau); + //temps_m[i] = i; current_time_us = get_absolute_time(); sleep_ms(1); } @@ -41,15 +62,7 @@ void main(void) absolute_time_t envoie_nb_char(int nb_char) { absolute_time_t current_time_us, start_time_us; int j=0; - char message[10000]; - for(int i=0; i<10000; i++){ - /*j++; - if(j>25){ - j=0; - } - message[i]= j + 'a';*/ - message[i]= i%26 + 'a'; - } + if (nb_char == 0){ return 0; } @@ -57,6 +70,10 @@ absolute_time_t envoie_nb_char(int nb_char) { message[nb_char] = '\0'; start_time_us = get_absolute_time(); printf("%s", message); + envoie_donnees(message, strlen(message)); + current_time_us = get_absolute_time(); + message[nb_char - 1] = 'a'; + message[nb_char] = 'a'; return current_time_us - start_time_us; }