Package uk.co.nimp.scard

Examples of uk.co.nimp.scard.MP300Exception


        }
       
        if(2==DLL_MODE){
            int status = win32Mp300ComDll.SetDLLMode(DLL_MODE);
            if (RET_OK != status) {
                throw new MP300Exception("SetDLLMode failed", status);
            }
        }
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
View Full Code Here


        int deviceId = 0;
        int resourceId=RES_ID;
        byte[] readerBytes = AStringUtilities.StringToBytesWithFinalNull(host);
        int status = win32Mp300ComDll.OpenCommunication(readerBytes);
        if (RET_OK != status)
            throw new MP300Exception("Fail to establish communication with " + host, status);
        status = win32Mp300ComDll.MPOS_OpenResource(resourceId, couplerId, OVERRIDE);
        if (RET_OK != status)
            throw new MP300Exception("Fail to establish communication with " + host, status);
        status = win32Mp300ComDll.MPS_ResetHard(couplerId);
        if (RET_OK != status) throw new MP300Exception("Fail to establish communication with " + host, status);

       
        SCardSetVdd(deviceId,couplerId,5000);
       
       
        status = win32Mp300ComDll.MPS_CardDetect(couplerId);
        GenericTerminal.State out;
        switch (status) {
            case RET_OK:
                out = GenericTerminal.State.CARD_PRESENT;
                break;
            case CRET_ABSENT:
                out = GenericTerminal.State.CARD_ABSENT;
                break;
            default:
                throw new MP300Exception("MPS_CardDetect failed", status);
        }
        System.out.println(out);
        win32Mp300ComDll.CloseCommunication();
    }
View Full Code Here

            win32Mp300ComDll.SetDLLTimeOutValue(1);
            currentDeviceId=nextDeviceId;
            if(2==DLL_MODE){
                status = win32Mp300ComDll.SelectActiveDevice(currentDeviceId);
                if (RET_OK != status)
                    throw new MP300Exception("SelectActiveDevice failed: ", status);
            }
           
            byte[] readerBytes = AStringUtilities.StringToBytesWithFinalNull(host);
            status = win32Mp300ComDll.OpenCommunication(readerBytes);
            if (RET_OK != status)
                throw new MP300Exception("Fail to establish communication with " + host, status);
            status = win32Mp300ComDll.MPOS_OpenResource(resourceId, couplerId, OVERRIDE);
            if (RET_OK != status)
                throw new MP300Exception("Fail to establish communication with " + host, status);
            status = win32Mp300ComDll.MPS_ResetHard(couplerId);
            if (RET_OK != status) throw new MP300Exception("Fail to establish communication with " + host, status);

            toClean.put(currentDeviceId, couplerId);
            nextDeviceId++;

            switch(resourceId){
View Full Code Here

    }
    static synchronized void setDeviceId(int deviceId) throws MP300Exception{
        if(2==DLL_MODE){
            if(deviceId!=currentDeviceId){
                int status = win32Mp300ComDll.SelectActiveDevice(deviceId);
                if (RET_OK != status) throw new MP300Exception("SelectActiveDevice failed: ", status);
                currentDeviceId=deviceId;
            }
        }
    }
View Full Code Here

    static synchronized void SCardSetVdd(int deviceId, int couplerId, int vddMillivolts) throws ScardException {
        int status;
        setDeviceId(deviceId);
        status = win32Mp300ComDll.MPS_VCCSelectMV(couplerId, vddMillivolts);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_VCCSelectMV failed. deviceId = "+deviceId+", couplerId="+couplerId+", vddMillivolts = "+vddMillivolts, status);
        }
    }
View Full Code Here

    static synchronized void SCardSetClk(int deviceId, int couplerId, int clkHertz) throws ScardException {
        int status;
        setDeviceId(deviceId);
        status = win32Mp300ComDll.MPS_FrequencySelect(couplerId, clkHertz);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_FrequencySelect failed", status);
        }
    }
View Full Code Here

    static synchronized void SCardClkStop(int deviceId, int couplerId,int TgClockCount, int ThClockCount,int PinState) throws ScardException {
        int status;
        setDeviceId(deviceId);
        status = win32Mp300ComDll.MPS_ClockStop(couplerId, TgClockCount, ThClockCount, PinState);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_ClockStop failed", status);
        }
    }
View Full Code Here

        if (RET_OK != status) {
            throw new MP300Exception("MPS_VCCSelectMV failed, couplerId="+couplerId+", vddMillivolts="+vddMillivolts, status);
        }*/
        status = win32Mp300ComDll.MPS_OnCmm(couplerId, clkHertz, atrLenRef, atrBuf);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_OnCmm failed", status);
        }
        short len = atrLenRef.getValue();
        AnswerToReset out=new AnswerToReset(atrBuf,0,len);

        if(autoPps && out.acceptPps() && (out.getSupportedFiDi()!=0x11)){
            byte ppsBuf[] = new byte[10];
            for (int i = 0; i < ppsBuf.length; i++) {
                ppsBuf[i] = 0;
            }
            int pps=0x10000000+(out.getSupportedFiDi()<<16);
            if(GenericTerminal.PROTOCOL_T_1==protocol)
                pps|=0x01000000;
            status = win32Mp300ComDll.MPS_SendPPS2(couplerId, pps, ppsBuf);
            if (RET_OK != status) {
                throw new MP300Exception("MPS_SendPPS2 failed",status);
            }
        }
       
        return out;
    }
View Full Code Here

        if(0==lc)
            lc=NO_LC;
        int status = win32Mp300ComDll.MPS_SendAPDU( couplerId, command, lc,  lcData,
            internalLe, leData, actualLeByRef,internalSw);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_SendAPDU failed",status);
        }
        int actualLe=(int)actualLeByRef.getValue();
        //if(actualLe!=internalLe){
        if(actualLe!=le){
            byte[] actualLeData=new byte[actualLe];
View Full Code Here

    static synchronized void SCardDisconnect(int deviceId, int couplerId) throws MP300Exception {
        setDeviceId(deviceId);
        int status = win32Mp300ComDll.MPS_OffCmm(couplerId);
        if (RET_OK != status) {
            throw new MP300Exception("MPS_OffCmm failed",status);
        }
    }
View Full Code Here

TOP

Related Classes of uk.co.nimp.scard.MP300Exception

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.