private static extern bool EleControl(ref ELE_DEVICE_CONTEXT EleDeviceContext, uint ulCtrlCode, byte[] pucInput, uint ulInputLen, byte[] pucOutput, uint ulOutputLen, ref uint pulActualLen);
public int ReadSenseLock() { if (strModal == "") { return(1); } uint ulErrRet = 0; bool bRet = false; ELE_DEVICE_CONTEXT edc = new ELE_DEVICE_CONTEXT(); edc.ulSize = (uint)Marshal.SizeOf(typeof(ELE_DEVICE_CONTEXT)); //open first elite e bRet = EleOpenFirstDevice(null, null, null, ELE_SHARE_MODE, ref edc); if (!bRet) { ulErrRet = EleGetLastError(); return(-1); } //verify pin of the found device byte[] Pin = { (byte)'1', (byte)'3', (byte)'5', (byte)'7', (byte)'9', (byte)'2', (byte)'4', (byte)'6', (byte)'8', (byte)'0', (byte)'8', (byte)'8', (byte)'6', (byte)'6', (byte)'2', (byte)'2' }; bRet = EleVerifyPin(ref edc, Pin); if (!bRet) { ulErrRet = EleGetLastError(); return(-1); } //close device bRet = EleClose(ref edc); if (!bRet) { ulErrRet = EleGetLastError(); return(-1); } byte[] rbuff = new byte[MAXLENGTH]; uint rbLen = 0; uint uLRet = 0; uLRet = EleT2Read(iStart, rbuff, iLength, ref rbLen); if (uLRet != ELE_T2_SUCCESS) { return(1); } System.Text.UTF8Encoding u8Encoding = new UTF8Encoding(); SenseLock = u8Encoding.GetString(rbuff); int i = SenseLock.IndexOf(strModal); if (i == -1) { return(-1); } if (i > SenseLock.Length - 1) { sVersion = ""; return(0); } else { sVersion = SenseLock.Substring(i + strModal.Length, SenseLock.Length - strModal.Length); try { sVersion = Int32.Parse(sVersion).ToString(); } catch { sVersion = ""; } } return(0); }
private static extern bool EleOpenNextDevice(ref ELE_DEVICE_CONTEXT EleDeviceContext);
private static extern bool EleSetDevieInfo(ref ELE_DEVICE_CONTEXT EleDeviceContext, uint ulFlag, ref int pBuffer, uint ulBufferLen);
public static extern bool EleExecute(ref ELE_DEVICE_CONTEXT EleDeviceContext, string ModuleName, byte[] Input, uint InputLen, byte[] Output, uint OutputLen, ref uint ActualOutputLen);
private static extern bool EleClose(ref ELE_DEVICE_CONTEXT EleDeviceContext);
private static extern bool EleVerifyPin(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] Pin);
private static extern bool EleWriteModule(ref ELE_DEVICE_CONTEXT EleDeviceContext, string ModuleName, byte[] ModuleContent, uint ModuleContentLen, ref uint ActualWrittenLen);
private static extern bool EleNextModuleName(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pcModuleNameBuffer, uint ulModuleNameBufferLen, ref uint pulModuleNameLen, ref uint pulIndex);
private static extern bool EleOpenFirstDevice(byte[] DeviceNumber, byte[] Desc, byte[] SerialNumber, uint ShareMode, ref ELE_DEVICE_CONTEXT EleDeviceContext);
private static extern bool EleChangeModuleName(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pcOldModuleName, byte[] pcNewModuleName);
private static extern bool EleReadModule(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pcModuleName, byte[] pucModuleBuffer, uint ulModuleBufferLen, ref uint pulActuralModuleLen);
private static extern bool EleChangePin(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pucOldPin, byte[] pucNewPin);
private static extern bool EleUpdate(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pucPkgContent, uint ulPkgLen);
private static extern bool EleSign(ref ELE_DEVICE_CONTEXT EleDeviceContext, byte[] pucSerial, byte[] pcModuleName, byte[] pucModuleContent, uint ulModuleSize, byte[] pPkgBuffer, uint ulPkgBufferLen, ref uint pulActualPkgLen);