2023-07-11 09:51:09 +00:00
|
|
|
#include "Log.h"
|
|
|
|
#include "pico/multicore.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define TEST_TIMEOUT_US 10000000
|
|
|
|
|
|
|
|
void log_core1_routine(){
|
|
|
|
while(1){
|
|
|
|
Log_gestion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief Fonction pour testes les fonctions Log
|
|
|
|
/// @param
|
|
|
|
/// @return 1 si la doit être ré-appelée, 0 si l'utilisateur quitte.
|
|
|
|
int test_log(void){
|
|
|
|
int lettre;
|
|
|
|
char message[50];
|
|
|
|
|
|
|
|
Log_init();
|
|
|
|
|
|
|
|
multicore_launch_core1(log_core1_routine);
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
|
|
|
|
do{
|
|
|
|
printf("A : 1 message\n");
|
|
|
|
printf("B : 9 messages d'affilés\n");
|
|
|
|
printf("C : 100 messages à 100 µs d'intervalle\n");
|
2023-07-11 11:41:24 +00:00
|
|
|
printf("D : Récupération du log stocké\n");
|
2023-07-11 09:51:09 +00:00
|
|
|
printf("Q : Quitter\n");
|
|
|
|
lettre = getchar_timeout_us(TEST_TIMEOUT_US);
|
|
|
|
stdio_flush();
|
|
|
|
}while(lettre == PICO_ERROR_TIMEOUT ||lettre == 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(lettre){
|
|
|
|
case 'A':
|
|
|
|
case 'a':
|
|
|
|
printf("A : 1 message\n");
|
|
|
|
Log_message("Test 1 message", DEBUG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'B':
|
|
|
|
case 'b':
|
|
|
|
printf("B : 9 messages d'affilés\n");
|
|
|
|
for(int i=0; i<9; i++){
|
2023-07-11 11:41:24 +00:00
|
|
|
sprintf(message, "Test message %d/9", i+1);
|
2023-07-11 09:51:09 +00:00
|
|
|
Log_message(message, DEBUG);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
case 'c':
|
|
|
|
printf("C : 100 messages à 100 µs d'intervalle\n");
|
|
|
|
for(int i=0; i<100; i++){
|
2023-07-11 11:41:24 +00:00
|
|
|
sprintf(message, "Test message %d/100", i+1);
|
2023-07-11 09:51:09 +00:00
|
|
|
Log_message(message, DEBUG);
|
|
|
|
sleep_us(100);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2023-07-11 11:41:24 +00:00
|
|
|
case 'D':
|
|
|
|
case 'd':
|
|
|
|
printf("D : Récupération du log stocké\n");
|
|
|
|
Log_get_full_log();
|
|
|
|
break;
|
|
|
|
|
2023-07-11 09:51:09 +00:00
|
|
|
case 'Q':
|
|
|
|
case 'q':
|
|
|
|
printf("Q : Quitter\n");
|
|
|
|
multicore_reset_core1();
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|