Fix when multiple shutdowns are sent

Thread queues are empty on every start to avoid ancient messages from previous sessions.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-11-24 20:21:06 +01:00
parent 3def9bff4f
commit c4178fda4b
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 9 additions and 13 deletions

View file

@ -126,23 +126,18 @@ uint16_t set_res_sw(uint8_t sw1, uint8_t sw2) {
}
void apdu_thread() {
card_init_core1();
while (1) {
uint32_t m;
uint32_t m = 0;
queue_remove_blocking(&usb_to_card_q, &m);
if (m == EV_VERIFY_CMD_AVAILABLE || m == EV_MODIFY_CMD_AVAILABLE)
{
if (m == EV_VERIFY_CMD_AVAILABLE || m == EV_MODIFY_CMD_AVAILABLE){
set_res_sw (0x6f, 0x00);
goto done;
}
else if (m == EV_EXIT) {
if (current_app && current_app->unload) {
current_app->unload();
}
break;
}
break;
}
process_apdu();
@ -154,8 +149,9 @@ void apdu_thread() {
queue_add_blocking(&card_to_usb_q, &flag);
}
//printf("EXIT !!!!!!\r\n");
if (current_app && current_app->unload)
if (current_app && current_app->unload) {
current_app->unload();
}
}
void apdu_finish() {

View file

@ -154,8 +154,7 @@ int driver_process_usb_nopacket() {
}
int driver_process_usb_packet(uint16_t rx_read) {
if (rx_read >= 10)
{
if (rx_read >= 10) {
//printf("%d %d %x\r\n",tccid->dwLength,rx_read-10,tccid->bMessageType);
if (ccid_header->dwLength <= rx_read-10) {
size_t apdu_sent = 0;
@ -185,6 +184,8 @@ int driver_process_usb_packet(uint16_t rx_read) {
ccid_write(size_atr);
}
else if (ccid_header->bMessageType == 0x63) {
if (ccid_status == 0)
card_exit(0);
ccid_status = 1;
ccid_response->bMessageType = CCID_SLOT_STATUS_RET;
ccid_response->dwLength = 0;
@ -192,7 +193,6 @@ int driver_process_usb_packet(uint16_t rx_read) {
ccid_response->bSeq = ccid_header->bSeq;
ccid_response->abRFU0 = ccid_status;
ccid_response->abRFU1 = 0;
card_exit();
ccid_write(0);
}
else if (ccid_header->bMessageType == 0x6F) {