when i install my smart card driver i get this error[The reader cannot communicate with the smart ca

Discussion in 'Windows Vista Drivers' started by abc, Aug 10, 2007.

  1. abc

    abc Guest

    Hi ,

    I have written a smart card reader driver{contactless smart card
    reader}, When i install the driver and open a reader application , i
    get a error as

    The reader cannot communicate with the smart card, due to ATR
    configuration conflicts.

    Can some body tell me why this occurs ,

    my power call back function looks as below,


    NTSTATUS phNfc4Win_ScardPower(PSMARTCARD_EXTENSION SmartcardExtension)
    {
    NTSTATUS status = STATUS_SUCCESS;
    KIRQL irql;
    static BYTE AtrBuffer[PH_MAX_ATR_BUFFER_SIZE];
    BYTE Atrlength =0;
    PDEVICE_CONTEXT pDevContext;
    BYTE i = 0;

    BYTE index =0;
    BYTE crcdata = 0;

    pDevContext =
    GetDeviceContext(WdfWdmDeviceGetWdfDeviceHandle(SmartcardExtension-
    KdPrint(("%sVdPowerReader\n"));

    if ((status = SmartcardAcquireRemoveLock(SmartcardExtension)) !=
    STATUS_SUCCESS)
    {
    SmartcardExtension->IoRequest.Information = 0;
    }
    else
    {
    switch (SmartcardExtension->MinorIoControlCode)
    {
    case SCARD_POWER_DOWN :
    {
    KdPrint(("\t%sSCARD_POWER_DOWN\n"));
    SmartcardExtension->CardCapabilities.ATR.Length = 0;
    *(SmartcardExtension->IoRequest.Information) = 0;
    status = STATUS_SUCCESS;
    break;
    }
    case SCARD_COLD_RESET :
    {
    /* change this data based on were we store the ATR */

    //status = phNfc4Win_GetAtrInformation(&pDevContext-
    buffer[0] = 0x3B;
    buffer[1] = (0x80 + pDevContext-
    buffer[2] = 0x80;
    buffer[3] = 0x01;
    memcpy((buffer +4),pDevContext-
    for (index= 1; index<(4 + pDevContext-
    {
    crcdata = crcdata ^ buffer[index];
    }
    buffer[pDevContext-
    crcdata;

    Atrlength = (5 + pDevContext-
    SmartcardExtension->ReaderCapabilities.CurrentState =
    SCARD_SPECIFIC;

    SmartcardExtension->CardCapabilities.ATR.Length =
    (UCHAR)Atrlength;
    *(SmartcardExtension->IoRequest.Information) =
    (UCHAR)Atrlength;
    for(i = 1; i<= 48; i++ )
    {
    KdPrint(("buffer 0x%x \n",buffer));
    }
    RtlCopyMemory(SmartcardExtension->IoRequest.ReplyBuffer, buffer,
    Atrlength);
    RtlCopyMemory(SmartcardExtension->CardCapabilities.ATR.Buffer,
    buffer, Atrlength);
    //RtlCopyMemory(SmartcardExtension->IoRequest.ReplyBuffer, buffer,
    Atrlength);

    /*KeAcquireSpinLock(&SmartcardExtension->OsData->SpinLock,
    &irql);
    SmartcardExtension->ReaderCapabilities.CurrentState =
    SCARD_SPECIFIC;

    KeReleaseSpinLock(&SmartcardExtension->OsData->SpinLock,
    irql);*/
    status = STATUS_SUCCESS;
    break;
    }
    case SCARD_WARM_RESET :
    /* change this data based on were we store the ATR */
    {
    KdPrint(("\t%sSCARD_COLD_RESET\n"));

    KeAcquireSpinLock(&SmartcardExtension->OsData->SpinLock,&irql);
    //if ( SmartcardExtension->ReaderCapabilities.CurrentState
    //status = phNfc4Win_GetAtrInformation(&pDevContext-
    buffer[0] = 0x3B;
    buffer[1] = (0x80 + pDevContext-
    buffer[2] = 0x80;
    buffer[3] = 0x01;
    memcpy(&(buffer[4]),pDevContext-
    for (index= 1; index<(4 + pDevContext-
    {
    crcdata = crcdata ^ buffer[index];
    }
    buffer[pDevContext-
    crcdata;

    Atrlength = (5 + pDevContext-
    SmartcardExtension->CardCapabilities.ATR.Length =
    (UCHAR)Atrlength;
    *(SmartcardExtension->IoRequest.Information) =
    (UCHAR)Atrlength;
    for(i = 1; i<= 48; i++ )
    {
    KdPrint(("buffer 0x%x \n",buffer));
    }
    SmartcardExtension->ReaderCapabilities.CurrentState =
    SCARD_SPECIFIC;
    RtlCopyMemory(SmartcardExtension->IoRequest.ReplyBuffer, buffer,
    Atrlength);
    RtlCopyMemory(SmartcardExtension->CardCapabilities.ATR.Buffer,
    buffer, Atrlength);
    //RtlCopyMemory(SmartcardExtension->IoRequest.ReplyBuffer,
    buffer, Atrlength);

    status = STATUS_SUCCESS;
    }
    /*else
    {
    KeReleaseSpinLock(&SmartcardExtension->OsData->SpinLock,irql);
    }*/
    status = STATUS_SUCCESS;
    break;
    }
    default :
    status = STATUS_SUCCESS;
    break;
    }
    SmartcardReleaseRemoveLock(SmartcardExtension);
    }
    return (STATUS_SUCCESS);
    }

    thanks ,
    Jagadish
     
    abc, Aug 10, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.