- better (or at least some) signal handling

- always checking the existance of a card, when requested


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@168 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-06-23 12:20:54 +00:00
parent aa539552b7
commit 3987f7acad
2 changed files with 24 additions and 12 deletions

View File

@@ -61,6 +61,7 @@ ccid_desc = {
.dwMechanical = __constant_cpu_to_le32(0),
.dwFeatures = __constant_cpu_to_le32(
0x2| // Automatic parameter configuration based on ATR data
0x4| // Automatic activation of ICC on inserting
0x8| // Automatic ICC voltage selection
0x10| // Automatic ICC clock frequency change
0x20| // Automatic baud rate change
@@ -99,11 +100,7 @@ detect_card_presence(int slot)
if (slot >= sizeof *card_in_slot)
return SC_ERROR_INVALID_ARGUMENTS;
if (card_in_slot[slot] && sc_card_valid(card_in_slot[slot])) {
sc_result = SC_SLOT_CARD_PRESENT;
} else {
sc_result = sc_detect_card_presence(reader, slot);
}
sc_result = sc_detect_card_presence(reader, slot);
if (sc_result == 0
&& card_in_slot[slot]
@@ -249,8 +246,8 @@ static __u8 get_bStatus(int sc_result, __u8 bSlot)
if (flags >= 0) {
if (sc_result < 0) {
if (flags & SC_SLOT_CARD_PRESENT) {
if (flags & SC_SLOT_CARD_CHANGED || (
card_in_slot[bSlot]
if (flags & SC_SLOT_CARD_CHANGED
|| (card_in_slot[bSlot]
&& !sc_card_valid(card_in_slot[bSlot]))) {
/*sc_debug(ctx, "error inactive");*/
result = CCID_BSTATUS_ERROR_INACTIVE;
@@ -270,7 +267,7 @@ static __u8 get_bStatus(int sc_result, __u8 bSlot)
/*sc_debug(ctx, "ok inactive");*/
result = CCID_BSTATUS_OK_INACTIVE;
} else {
sc_debug(ctx, "ok active");
/*sc_debug(ctx, "ok active");*/
result = CCID_BSTATUS_OK_ACTIVE;
}
} else {

View File

@@ -583,8 +583,9 @@ static int autoconfig ()
}
if (!doint) {
source_sink_intf.bNumEndpoints = 2;
// Automatic activation of ICC on inserting not supported
// USB Wake up signaling not supported
ccid_desc.dwFeatures &= ~__constant_cpu_to_le32(0x100000);
ccid_desc.dwFeatures &= ~__constant_cpu_to_le32(0x4|0x100000);
}
return 0;
}
@@ -1533,9 +1534,23 @@ stall:
static void signothing (int sig, siginfo_t *info, void *ptr)
{
/* NOP */
if (verbose > 1)
fprintf (stderr, "%s %d\n", __FUNCTION__, sig);
unsigned int seconds = 10;
switch (sig) {
case SIGINT:
if (verbose > 1)
fprintf (stderr, "\nInitializing shutdown, "
"waiting %d seconds for threads to terminate\n",
seconds);
sleep(5);
case SIGQUIT:
fprintf (stderr, "Doing immediate shutdown.\n");
exit(1);
break;
default:
if (verbose > 1)
fprintf (stderr, "Received unhandled signal %u\n",
sig);
}
}
static const char *speed (enum usb_device_speed s)