mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-08-14 02:30:28 +03:00
firmware: Drop CEMU_TX_DATA when sim is in-active
When the emulated sim is in reset or without power, drop CEMU_TX_DATA. Change-Id: I796e548225a742cddfde12bd6a60e4d2e5c04c8f
This commit is contained in:
@@ -72,6 +72,7 @@ void card_emu_uart_wait_tx_idle(uint8_t uart_chan);
|
||||
void card_emu_uart_interrupt(uint8_t uart_chan);
|
||||
|
||||
int card_emu_get_vcc(uint8_t uart_chan);
|
||||
bool card_ready(struct card_handle *ch);
|
||||
|
||||
struct cardemu_usb_msg_config;
|
||||
int card_emu_set_config(struct card_handle *ch, const struct cardemu_usb_msg_config *scfg,
|
||||
|
||||
@@ -215,6 +215,19 @@ struct card_handle {
|
||||
} stats;
|
||||
};
|
||||
|
||||
/* if the card should enque messages */
|
||||
bool card_ready(struct card_handle *ch)
|
||||
{
|
||||
switch (ch->state) {
|
||||
case ISO_S_IN_PTS:
|
||||
case ISO_S_WAIT_TPDU:
|
||||
case ISO_S_IN_TPDU:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset all the 'dynamic' state of the card handle to the initial/default values */
|
||||
static void card_handle_reset(struct card_handle *ch)
|
||||
{
|
||||
|
||||
@@ -736,6 +736,12 @@ static void dispatch_usb_command_cardem(struct msgb *msg, struct cardem_inst *ci
|
||||
hdr = (struct simtrace_msg_hdr *) msg->l1h;
|
||||
switch (hdr->msg_type) {
|
||||
case SIMTRACE_MSGT_DT_CEMU_TX_DATA:
|
||||
/* drop message when sim is in-active */
|
||||
if (!card_ready(ci->ch)) {
|
||||
/* FIXME: enqueue an error message for IN */
|
||||
usb_buf_free(msg);
|
||||
return;
|
||||
}
|
||||
queue = card_emu_get_uart_tx_queue(ci->ch);
|
||||
llist_add_tail(&msg->list, queue);
|
||||
card_emu_have_new_uart_tx(ci->ch);
|
||||
|
||||
Reference in New Issue
Block a user