public void Receive_Close(G2ReceivedPacket embeddedPacket) { CommClose close = CommClose.Decode(embeddedPacket); CloseMsg = close.Reason; Log("Received Close (" + close.Reason + ")"); UpdateStatus(SessionStatus.Closed); }
public void Initialize() { log.Debug("begin"); if (!enabled) { return; } string dllPath = Path.Combine(Config.PeripheralAbsolutePath, PeripheralManager.Dir, dll); if (!File.Exists(dllPath)) { dllPath = Path.Combine(Config.PeripheralAbsolutePath, PeripheralManager.Dir, "MoveCardLib", dll); } intPtr = Win32ApiInvoker.LoadLibrary(dllPath); log.InfoFormat("LoadLibrary: dllPath = {0}, ptr = {1}", dllPath, intPtr); IntPtr api = Win32ApiInvoker.GetProcAddress(intPtr, "CommOpen"); commOpen = (CommOpen)Marshal.GetDelegateForFunctionPointer(api, typeof(CommOpen)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CommClose"); commClose = (CommClose)Marshal.GetDelegateForFunctionPointer(api, typeof(CommClose)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CRT310_MovePosition"); cRT310_MovePosition = (CRT310_MovePosition)Marshal.GetDelegateForFunctionPointer(api, typeof(CRT310_MovePosition)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CRT310_GetStatus"); cRT310_GetStatus = (CRT310_GetStatus)Marshal.GetDelegateForFunctionPointer(api, typeof(CRT310_GetStatus)); api = Win32ApiInvoker.GetProcAddress(intPtr, "MC_ReadTrack"); mC_ReadTrack = (MC_ReadTrack)Marshal.GetDelegateForFunctionPointer(api, typeof(MC_ReadTrack)); api = Win32ApiInvoker.GetProcAddress(intPtr, "RF_DetectCard"); rF_DetectCard = (RF_DetectCard)Marshal.GetDelegateForFunctionPointer(api, typeof(RF_DetectCard)); api = Win32ApiInvoker.GetProcAddress(intPtr, "RF_ReadBlock"); rF_ReadBlock = (RF_ReadBlock)Marshal.GetDelegateForFunctionPointer(api, typeof(RF_ReadBlock)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CPU_ColdReset"); cPU_ColdReset = (CPU_ColdReset)Marshal.GetDelegateForFunctionPointer(api, typeof(CPU_ColdReset)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CPU_T0_C_APDU"); cPU_T0_C_APDU = (CPU_T0_C_APDU)Marshal.GetDelegateForFunctionPointer(api, typeof(CPU_T0_C_APDU)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CPU_T1_C_APDU"); cPU_T1_C_APDU = (CPU_T1_C_APDU)Marshal.GetDelegateForFunctionPointer(api, typeof(CPU_T1_C_APDU)); api = Win32ApiInvoker.GetProcAddress(intPtr, "CRT_IC_CardClose"); cRT_IC_CardClose = (CRT_IC_CardClose)Marshal.GetDelegateForFunctionPointer(api, typeof(CRT_IC_CardClose)); Hdle = commOpen("COM5"); }
public void Send_Close(string reason) { if (Status == SessionStatus.Closed) { Debug.Assert(false); return; } CloseMsg = reason; Log("Sending Close (" + reason + ")"); CommClose close = new CommClose(); close.Reason = reason; SendPacket(close); Comm.Close(); UpdateStatus(SessionStatus.Closed); // socket not closed until fin received }