private void firmwareVersionButton_Click(object sender, RoutedEventArgs e) { ShowPendingStatus(""); Command cmd = new GetFirmwareVersion(); Action <string> update = (string text) => { firmwareTextBox.Text = text; }; Callback callback = (ResponseFrame frame, Exception exc) => { if (CheckForErrorsOrTimeout(frame, exc)) { return; } if (frame.ResponseCode == 0x06) { byte[] data = frame.Data; Dispatcher.BeginInvoke(update, $"{data[0]}.{data[1]}"); } ShowSuccessStatus(); }; tappy.SendCommand(cmd, callback); }
public void Initialize() { tagList = new List <string>(); string dllPath = Path.Combine(Config.PeripheralAbsolutePath, PeripheralManager.Dir, dll); if (!File.Exists(dllPath)) { dllPath = Path.Combine(Config.PeripheralAbsolutePath, PeripheralManager.Dir, "RFIDLib", dll); } intPtr = Win32ApiInvoker.LoadLibrary(dllPath); log.InfoFormat("LoadLibrary: dllPath = {0}, ptr = {1}", dllPath, intPtr); uint idcoed = Win32ApiInvoker.GetLastError(); IntPtr api = Win32ApiInvoker.GetProcAddress(intPtr, "OpenDevice"); openDevice = (OpenDevice)Marshal.GetDelegateForFunctionPointer(api, typeof(OpenDevice)); api = Win32ApiInvoker.GetProcAddress(intPtr, "OneFindTags"); oneFindTags = (OneFindTags)Marshal.GetDelegateForFunctionPointer(api, typeof(OneFindTags)); api = Win32ApiInvoker.GetProcAddress(intPtr, "GetHardwareVersionNumber"); getHardwareVersionNumber = (GetHardwareVersionNumber)Marshal.GetDelegateForFunctionPointer(api, typeof(GetHardwareVersionNumber)); api = Win32ApiInvoker.GetProcAddress(intPtr, "GetFirmwareVersion"); getFirmwareVersion = (GetFirmwareVersion)Marshal.GetDelegateForFunctionPointer(api, typeof(GetFirmwareVersion)); api = Win32ApiInvoker.GetProcAddress(intPtr, "GetUniqueID"); getUniqueID = (GetUniqueID)Marshal.GetDelegateForFunctionPointer(api, typeof(GetUniqueID)); api = Win32ApiInvoker.GetProcAddress(intPtr, "SendHeartbeat"); sendHeartbeat = (SendHeartbeat)Marshal.GetDelegateForFunctionPointer(api, typeof(SendHeartbeat)); api = Win32ApiInvoker.GetProcAddress(intPtr, "ConstantFindTags"); constantFindTags = (ConstantFindTags)Marshal.GetDelegateForFunctionPointer(api, typeof(ConstantFindTags)); api = Win32ApiInvoker.GetProcAddress(intPtr, "StopFindTags"); stopFindTags = (StopFindTags)Marshal.GetDelegateForFunctionPointer(api, typeof(StopFindTags)); api = Win32ApiInvoker.GetProcAddress(intPtr, "OnlyRead"); onlyRead = (OnlyRead)Marshal.GetDelegateForFunctionPointer(api, typeof(OnlyRead)); int ret = openDevice(); if (0 == ret) { list = new List <string>(); } else { } }