1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
// ********************************************************
// Fonction de log des messages envoyés et recu
// ********************************************************
void log(char tab[], int size, int code){
FILE * log = NULL;
int j;
log = fopen("Log.csv", "a");
if(log != NULL){
if(code == 1){
fprintf(log, "%s;", "Send:");
for(j=0; j<size; j++){
if(j == 0 || j == 1) fprintf(log,"%hhX;", (unsigned char)tab[j]);
else{
fprintf(log, "%hhX%hhX;", (unsigned char)tab[j+1], (unsigned char)tab[j]);
j++;
}
}
}
if(code == 2){
fprintf(log, ";->;%s;", "Receive:");
for(j=0; j<size; j++){
if(j == 0 || j == 1) fprintf(log,"%hhX;", (unsigned char)tab[j]);
else{
fprintf(log, "%hhX%hhX;", (unsigned char)tab[j+1], (unsigned char)tab[j]);
j++;
}
}
fprintf(log,"\n");
}
}
fclose (log);
} |
Partager