mirror of https://gerrit.osmocom.org/simtrace2
sniff: ensure the checksum error flag is also printed
the firmware now also use a generic value_string array (as does the host application) Change-Id: I861bd8b52e8f2f2a4786bbe1cc834917119dc394
This commit is contained in:
parent
8e84f8125c
commit
697199676e
|
@ -302,6 +302,38 @@ static void change_state(enum iso7816_3_sniff_state iso_state_new)
|
|||
//TRACE_INFO("Changed to ISO 7816-3 state %u\n\r", iso_state); /* don't print since this is function is also called by ISRs */
|
||||
}
|
||||
|
||||
const struct value_string data_flags[] = {
|
||||
{
|
||||
.value = SNIFF_DATA_FLAG_ERROR_INCOMPLETE,
|
||||
.str = "incomplete",
|
||||
},
|
||||
{
|
||||
.value = SNIFF_DATA_FLAG_ERROR_MALFORMED,
|
||||
.str = "malformed",
|
||||
},
|
||||
{
|
||||
.value = SNIFF_DATA_FLAG_ERROR_CHECKSUM,
|
||||
.str = "checksum error",
|
||||
},
|
||||
{
|
||||
.value = 0,
|
||||
.str = NULL,
|
||||
},
|
||||
};
|
||||
|
||||
static void print_flags(const struct value_string* flag_meanings, uint32_t nb_flags, uint32_t flags) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < nb_flags; i++) {
|
||||
if (flags & flag_meanings[i].value) {
|
||||
printf(flag_meanings[i].str);
|
||||
flags &= ~flag_meanings[i].value;
|
||||
if (flags) {
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_send_data(enum simtrace_msg_type_sniff type, const uint8_t* data, uint16_t length, uint32_t flags)
|
||||
{
|
||||
/* Sanity check */
|
||||
|
@ -329,20 +361,7 @@ static void usb_send_data(enum simtrace_msg_type_sniff type, const uint8_t* data
|
|||
}
|
||||
if (flags) {
|
||||
printf(" (");
|
||||
if (flags & SNIFF_DATA_FLAG_ERROR_INCOMPLETE) {
|
||||
printf("incomplete");
|
||||
flags &= ~SNIFF_DATA_FLAG_ERROR_INCOMPLETE;
|
||||
if (flags) {
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
if (flags & SNIFF_DATA_FLAG_ERROR_MALFORMED) {
|
||||
printf("malformed");
|
||||
flags &= ~SNIFF_DATA_FLAG_ERROR_MALFORMED;
|
||||
if (flags) {
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
print_flags(data_flags, ARRAY_SIZE(data_flags), flags);
|
||||
putchar(')');
|
||||
}
|
||||
printf(": ");
|
||||
|
|
|
@ -131,14 +131,14 @@ const struct value_string data_flags[] = {
|
|||
.value = SNIFF_DATA_FLAG_ERROR_MALFORMED,
|
||||
.str = "malformed",
|
||||
},
|
||||
{
|
||||
.value = 0,
|
||||
.str = NULL,
|
||||
},
|
||||
{
|
||||
.value = SNIFF_DATA_FLAG_ERROR_CHECKSUM,
|
||||
.str = "checksum error",
|
||||
},
|
||||
{
|
||||
.value = 0,
|
||||
.str = NULL,
|
||||
},
|
||||
};
|
||||
|
||||
static void print_flags(const struct value_string* flag_meanings, uint32_t nb_flags, uint32_t flags) {
|
||||
|
|
Loading…
Reference in New Issue