mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-25 17:58:32 +03:00
simtrace2-cardem-pcsc: Decode STATUS flags to strings
SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600 (RESET VCC CLK ) is more understandable than SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600 Change-Id: I5bbfa1d99ebee4b297d894a5f444dbe743c7ab70
This commit is contained in:
@@ -64,6 +64,16 @@ static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
|
|||||||
atr[atr_len-1] = csum;
|
atr[atr_len-1] = csum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cemu_flags2str(char *out, unsigned int out_len, uint32_t flags)
|
||||||
|
{
|
||||||
|
snprintf(out, out_len, "%s%s%s%s%s",
|
||||||
|
flags & CEMU_STATUS_F_RESET_ACTIVE ? "RESET " : "",
|
||||||
|
flags & CEMU_STATUS_F_VCC_PRESENT ? "VCC " : "",
|
||||||
|
flags & CEMU_STATUS_F_CLK_ACTIVE ? "CLK " : "",
|
||||||
|
flags & CEMU_STATUS_F_CARD_INSERT ? "CARD_PRES " : "",
|
||||||
|
flags & CEMU_STATUS_F_RCEMU_ACTIVE ? "RCEMU " : "");
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Incoming Messages
|
* Incoming Messages
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
@@ -71,12 +81,13 @@ static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
|
|||||||
/*! \brief Process a STATUS message from the SIMtrace2 */
|
/*! \brief Process a STATUS message from the SIMtrace2 */
|
||||||
static int process_do_status(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int len)
|
static int process_do_status(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
struct cardemu_usb_msg_status *status;
|
struct cardemu_usb_msg_status *status = (struct cardemu_usb_msg_status *) buf;
|
||||||
status = (struct cardemu_usb_msg_status *) buf;
|
char fbuf[80];
|
||||||
|
|
||||||
printf("=> STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u\n",
|
cemu_flags2str(fbuf, sizeof(fbuf), status->flags);
|
||||||
|
printf("=> STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u (%s)\n",
|
||||||
status->flags, status->fi, status->di, status->wi,
|
status->flags, status->fi, status->di, status->wi,
|
||||||
status->waiting_time);
|
status->waiting_time, fbuf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -177,10 +188,12 @@ static int process_usb_msg(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int le
|
|||||||
static int process_irq_status(struct osmo_st2_cardem_inst *ci, const uint8_t *buf, int len)
|
static int process_irq_status(struct osmo_st2_cardem_inst *ci, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
const struct cardemu_usb_msg_status *status = (struct cardemu_usb_msg_status *) buf;
|
const struct cardemu_usb_msg_status *status = (struct cardemu_usb_msg_status *) buf;
|
||||||
|
char fbuf[80];
|
||||||
|
|
||||||
LOGCI(ci, LOGL_INFO, "SIMtrace IRQ STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u\n",
|
cemu_flags2str(fbuf, sizeof(fbuf), status->flags);
|
||||||
|
LOGCI(ci, LOGL_INFO, "SIMtrace IRQ STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u (%s)\n",
|
||||||
status->flags, status->fi, status->di, status->wi,
|
status->flags, status->fi, status->di, status->wi,
|
||||||
status->waiting_time);
|
status->waiting_time, fbuf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user