int status;
byte atrBuf[] = new byte[256];
int timeout=win32Stcp250Dll.GetDLLTimeOutValue();
status = win32Stcp250Dll.MPS_VCCSelectMV(couplerId, vddMillivolts);
if (RET_OK != status) {
throw new MP300Exception("MPS_VCCSelectMV failed, couplerId="+couplerId+", vddMillivolts="+vddMillivolts+", Dll Timeout="+timeout, status);
}
status = win32Stcp250Dll.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);
int fi=out.getSupportedFiDi()>>4;
int di=out.getSupportedFiDi()&0x0F;
//System.out.println("ATR:" + out.toString());
if(out.acceptPps() & (out.getSupportedFiDi()!=0x11)){
byte ppsBuf[] = new byte[10];
for (int i = 0; i < ppsBuf.length; i++) {
ppsBuf[i] = 0;
}
int p=0;
if(GenericTerminal.PROTOCOL_T_1==protocol)
p=1;
if(7==di){
//not supported by STAR265
byte fakeAtr[]=out.getData();
di=0x06;
fakeAtr[2]=(byte) ((out.getSupportedFiDi()&0xF0)|di);
status = win32Stcp250Dll.MPS_ChangeProtocolParameters(couplerId, win32Stcp250Dll.CPP_SIM_ATR ,fakeAtr,fakeAtr.length);
if (RET_OK != status) {
throw new MP300Exception("MPS_ChangeProtocolParameters failed",status);
}
}
status = win32Stcp250Dll.MPS_SendPPSCmm( couplerId, p, fi, di);
if (RET_OK != status) throw new MP300Exception("MPS_SendPPSCmm failed",status);
}
cyclesPerEtu.value= AnswerToReset.fiDi2cyclesPerEtu(fi, di);
return out;
}