[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-smartcardddk
Subject: Re: VCOMM_OpenComm return IE_OPEN
From: Xavier_Monés <xmm () C3PO ! ES>
Date: 2001-07-18 8:58:17
[Download RAW message or body]
Henry, can you post the source code for your SD266SDelay function?
----- Original Message -----
From: "Henry Lai" <Henry_Lai@HQ.IISI.COM.TW>
To: <SmartCardDDK@DISCUSS.MICROSOFT.COM>
Sent: Wednesday, July 18, 2001 10:31 AM
Subject: Re: VCOMM_OpenComm return IE_OPEN
> This is my code,it is modified from Bulltlp3 in 98DDK
>
> The initialization of COM port is put after
>
> A.getting "COM1"from Registry,
> B.prepare SmartcardExtension,
> C.SmartcardInitialize,
> D.SmartcardCreateLink
>
> Besides ,I retry them about 100 times( through about (0.8*100 )seconds)
> But in 98 SE it is failed.(IE_OPEN)
> Any suggestion?
>
>
>
>
> BOOL
> _cdecl
> SD266SInitCommPort(
> PSMARTCARD_EXTENSION SmartcardExtension
> )
> {
> HPORT lhPort = 0;
> DWORD actionmask = 0;
> DWORD indata = 0;
> DWORD outdata = 0;
> BOOL bRet = FALSE;
> PREADER_EXTENSION readerExtension =
> SmartcardExtension->ReaderExtension;
> _QSB qsb;
>
> SmartcardDebug(
> DEBUG_ALL,
> ("%s!SD266SInitCommPort: Enter\n",
> SD266SSCR_NAME)
> );
>
> //
> // Open the Commport
> //
> lhPort = (HPORT) VCOMM_OpenComm(
> SmartcardExtension->ReaderExtension->pcCommNumber,//it is"COM1"
> (ULONG)-1
> );
>
> if((lhPort == IE_BADID ) || (lhPort == IE_OPEN ))
> {
> SmartcardDebug(
> DEBUG_DRIVER,
> ("%s!SD266SInitCommPort: Error VCOMM_OpenComm %s\n",
> SD266SSCR_NAME,
> SmartcardExtension->ReaderExtension->pcCommNumber)
> );
>
> SD266SDelay(SmartcardExtension,
> 400);
> lhPort = (HPORT) VCOMM_OpenComm(
> SmartcardExtension->ReaderExtension->pcCommNumber,
> (ULONG)-1
> );
> if((lhPort == IE_BADID ) || (lhPort == IE_OPEN ))
> {
> SD266SDelay(SmartcardExtension,
> 400);
> lhPort = (HPORT) VCOMM_OpenComm(
> SmartcardExtension->ReaderExtension->pcCommNumber,
> (ULONG)-1);
> }
> if((lhPort == IE_BADID ) || (lhPort == IE_OPEN ))
> return FALSE;
> }
>
> SmartcardExtension->ReaderExtension->hCommPort = lhPort;
>
> //
> // initialize the COMM timeout structure and set the
> // timeouts
> //
> bRet = VCOMM_GetSetCommTimeouts(
> SmartcardExtension->ReaderExtension->hCommPort,
> &readerExtension->SerialConfigData.CommTimeouts,
> OPENEXCLUSIVE
> );
>
> ASSERT(bRet != FALSE);
>
> if (bRet)
> {
> actionmask =
> fBaudRate |
> fByteSize |
> fParity |
> fStopBits |
> fBitMask |
> fErrorChar;
>
> bRet = VCOMM_SetCommState(
> SmartcardExtension->ReaderExtension->hCommPort,
> &readerExtension->SerialConfigData.theDCB,
> actionmask);
>
> ASSERT(bRet != FALSE);
> }
>
> if (bRet)
> {
> //
> // Set inqueue buffer and outqueue buffer for the Commport
> //
> bRet = VCOMM_SetupComm(
> SmartcardExtension->ReaderExtension->hCommPort,
> readerExtension->SerialConfigData.qreceive,
> sizeof(readerExtension->SerialConfigData.qreceive),
> readerExtension->SerialConfigData.qtransmit,
> sizeof(readerExtension->SerialConfigData.qtransmit),
> &qsb
> );
>
> ASSERT(bRet != FALSE);
> }
>
> if (bRet)
> {
> //
> // set DTR for the reader
> //
> bRet = VCOMM_EscapeCommFunction(
> SmartcardExtension->ReaderExtension->hCommPort,
> SETDTR,
> indata,
> (long)&outdata
> );
>
> ASSERT(bRet != FALSE);
> }
>
> if (bRet)
> {
> //
> // set RTS for the reader
> //
> bRet = VCOMM_EscapeCommFunction(
> SmartcardExtension->ReaderExtension->hCommPort,
> SETRTS,
> indata,
> (long)&outdata
> );
>
> ASSERT(bRet != FALSE);
> }
>
> if(bRet == FALSE)
> {
> bRet = VCOMM_CloseComm(
> SmartcardExtension->ReaderExtension->hCommPort
> );
>
> ASSERT(bRet != FALSE);
> return FALSE;
> }
>
> SmartcardDebug(
> DEBUG_ALL,
> ("%s!SD266SInitCommPort: Exit\n",
> SD266SSCR_NAME)
> );
>
> return TRUE;
> }
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic