private static void PrintStatus(DEVICE_INFO device) { if (!cliOnly) { Console.WriteLine($"Current state {GetStatus(device)}"); } }
public bool add_device_to_list_nocheck(DEVICE_INFO add_di) { bool result; if (add_di.product_id == null || add_di.product_id == "") { result = false; } else if (call.m_devList.ContainsKey(add_di.product_id)) { result = false; } else { call.m_devList.Add(add_di.product_id, add_di); this.CallIPCSend(new IPC_SIMPLE_REQUEST { cmd_id = 4346, product_id = add_di.product_id, dev_object = add_di }); result = true; } return(result); }
public bool modi_device_info_nocheck(string product_id, DEVICE_INFO new_di) { bool result; if (product_id == null || product_id == "" || product_id != new_di.product_id) { result = false; } else if (!call.m_devList.ContainsKey(new_di.product_id)) { result = false; } else if (call.m_devList.Remove(product_id)) { call.m_devList.Add(product_id, new_di); this.CallIPCSend(new IPC_SIMPLE_REQUEST { cmd_id = 4347, product_id = product_id, dev_object = new_di }); result = true; } else { result = false; } return(result); }
private void add_xj_dev() { DEVICE_INFO dEVICE_INFO = new DEVICE_INFO(); dEVICE_INFO.product_id = "66666666"; dEVICE_INFO.net_id = "测试用虚拟卡3#"; dEVICE_INFO.state = DEVICE_STATE.ST_ONLINE; dEVICE_INFO.FIXED_IP = "192.168.1.133"; dEVICE_INFO.TCP_out_dst_Port = 58258; dEVICE_INFO.MAC = "112233445566"; dEVICE_INFO.cur_use_net_mode = 1; if (!call.m_devList.ContainsKey(dEVICE_INFO.product_id)) { call.m_devList.Add(dEVICE_INFO.product_id, dEVICE_INFO); } dEVICE_INFO = new DEVICE_INFO(); dEVICE_INFO.product_id = "88888888"; dEVICE_INFO.net_id = "测试用虚拟卡2#"; dEVICE_INFO.state = DEVICE_STATE.ST_ONLINE; dEVICE_INFO.FIXED_IP = "192.168.1.166"; dEVICE_INFO.TCP_out_dst_Port = 58258; dEVICE_INFO.cur_use_net_mode = 1; dEVICE_INFO.MAC = "665544332211"; if (!call.m_devList.ContainsKey(dEVICE_INFO.product_id)) { call.m_devList.Add(dEVICE_INFO.product_id, dEVICE_INFO); } this.SYNC_DEV_LIST(); }
protected virtual void OnReceiveFoundCardMessage(ref Message m) { IntPtr pDevInfo = m.LParam; IntPtr pDeviceData = ParseDeviceData(pDevInfo); DEVICE_INFO dev_info = (DEVICE_INFO)Marshal.PtrToStructure(pDevInfo, typeof(DEVICE_INFO)); switch (dev_info.target_device) { case DEVICE_TYPE_NFC_18092_212K: DispatchNfcFEvent(pDeviceData); break; case DEVICE_TYPE_NFC_18092_424K: DispatchNfcFEvent(pDeviceData); break; case DEVICE_TYPE_NFC_14443A_18092_106K: DispatchNfcAEvent(pDeviceData); break; case DEVICE_TYPE_NFC_14443B_106K: DispatchNfcBEvent(pDeviceData); break; } FeliCaNfcDllWrapperClass.FeliCaLibNfcStopDevAccess(0x00); }
protected virtual void OnReceiveFoundCardMessage(ref Message m) { IntPtr pDevInfo = m.LParam; IntPtr pDeviceData; if (IntPtr.Size == 8) { pDeviceData = (IntPtr)((Int64)pDevInfo + (Int64)Marshal.OffsetOf(typeof(DEVICE_INFO), "dev_info")); } else { pDeviceData = (IntPtr)((Int32)pDevInfo + (Int32)Marshal.OffsetOf(typeof(DEVICE_INFO), "dev_info")); } DEVICE_INFO dev_info = (DEVICE_INFO)Marshal.PtrToStructure(pDevInfo, typeof(DEVICE_INFO)); switch (dev_info.target_device) { case DEVICE_TYPE_NFC_18092_212K: case DEVICE_TYPE_NFC_18092_424K: DEVICE_DATA_NFC_18092_212_424K deviceData_F = (DEVICE_DATA_NFC_18092_212_424K)Marshal.PtrToStructure(pDeviceData, typeof(DEVICE_DATA_NFC_18092_212_424K)); string idm = Util.ToHexString(deviceData_F.NFCID2); MessageBox.Show(this, idm, "discover nfc tag"); break; } FeliCaNfcDllWrapperClass.FeliCaLibNfcStopDevAccess(0x00); }
private void trigger_HeartReturnResult(IPC_SIMPLE_ANSWER isa) { if (global_static_var.is_init_ok) { if (call.OnAutoFoundDevice != null) { AutoFoundDeviceEventArgs arg = new AutoFoundDeviceEventArgs(); if (!isa.is_cmd_failed_flag) { DEVICE_INFO di = isa.return_object as DEVICE_INFO; call.m_thisPtr.Invoke(new MethodInvoker(delegate { if (call.m_devList.ContainsKey(di.product_id)) { call.m_devList.Remove(di.product_id); } call.m_devList.Add(di.product_id, di); })); arg.cmd_id = (int)isa.cmd_id; arg.net_id = di.net_id; arg.product_id = di.product_id; arg.state = di.state; arg.signal_strength = di.signal_strength; arg.program_number = di.program_number; if (isa.cmd_id == 4341) { arg.repair_message = "心跳引发的设备状态更新!"; } else if (isa.cmd_id == 4342) { arg.repair_message = "心跳引发的新设备发现!"; } else if (isa.cmd_id == 4343) { arg.repair_message = "长时间没有心跳,认为此设备已离线。"; } } else if (isa.cmd_id == 4342) { arg.repair_message = isa.er_message; arg.net_id = ""; arg.product_id = ""; arg.state = DEVICE_STATE.ST_NONE; arg.signal_strength = 0; arg.program_number = 0; arg.cmd_id = (int)isa.cmd_id; } call.m_thisPtr.BeginInvoke(new MethodInvoker(delegate { if (call.OnAutoFoundDevice != null) { call.OnAutoFoundDevice(this, arg); } })); } } }
/// <summary> /// メッセージハンドラ本体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void messageHandlerFunc(object sender, MessageReceivedEventArgs e) { mResult = false; if (e.Message.Msg == mCardFindMessage) { IntPtr pDevInfo = e.Message.LParam; IntPtr pDeviceData; mNfcId = null; mRD = null; // OSの32bit/64bit判別 DEVICE_INFO dev_info = (DEVICE_INFO)Marshal.PtrToStructure(pDevInfo, typeof(DEVICE_INFO)); mTargetDevice = dev_info.target_device; if (IntPtr.Size == 8) { pDeviceData = (IntPtr)((Int64)pDevInfo + (Int64)Marshal.OffsetOf(typeof(DEVICE_INFO), "dev_info")); } else { pDeviceData = (IntPtr)((Int32)pDevInfo + (Int32)Marshal.OffsetOf(typeof(DEVICE_INFO), "dev_info")); } //解析 switch (mTargetDevice) { case felica_nfc_dll_wrapper.DEVICE_TYPE_NFC_14443A_18092_106K: detectNfcA(pDeviceData); break; case felica_nfc_dll_wrapper.DEVICE_TYPE_NFC_18092_212K: case felica_nfc_dll_wrapper.DEVICE_TYPE_NFC_18092_424K: detectNfcF(pDeviceData); break; default: break; } } else if (e.Message.Msg == mCardEnableMessage) { mResult = true; mListener.Close(); return; } //mListenerWindow.Close(); return; }
private static DeviceStatus GetStatus(DEVICE_INFO device) { DeviceStatus status = new DeviceStatus(); var devices = hhlib.GetAll(); foreach (var ice in devices) { if (device.name == ice.name) { status = ice.status; } } return(status); }
private static void ResetGPU(DEVICE_INFO device) { DeviceStatus current = GetStatus(device); if (current == DeviceStatus.Enabled) { hhlib.SetDeviceState(device, false); if (!cliOnly) { PrintStatus(device); } } else if (current == DeviceStatus.Disabled) { if (!cliOnly) { Console.WriteLine("Device currently disabled.\nWill attempt to enable..."); } } else if (current == DeviceStatus.Unknown) { if (!cliOnly) { Console.WriteLine("Device currently in unknown state.\nWill attempt to enable..."); } } Thread.Sleep(1000); hhlib.SetDeviceState(device, true); PrintStatus(device); if (!cliOnly && GetStatus(device) == DeviceStatus.Enabled) { Console.WriteLine($"{device.name} Successfully reset."); Thread.Sleep(3000); } else if (!cliOnly && GetStatus(device) == DeviceStatus.Disabled) { Console.WriteLine($"{device.name} not successfully reenabled / reset (look above for more info)."); Thread.Sleep(3000); } else if (!cliOnly && GetStatus(device) == DeviceStatus.Unknown) { Console.WriteLine($"{device.name} is in an unknown state. There seems to be an issue."); Thread.Sleep(3000); } else { Console.WriteLine(1); } }
//Name: button1_Clck //Inputs: object, eventArgs //Outputs: none //Remarks: We are using this button to demonstrate enabling a // hardware device. There are several things worth // noting. First, just to be safe we are disabling // hardware notifcations until we are done. The UI // thread in .NET won't let the WndProc method run // to my knowledge while you are in here but if you // were invoking these methods on different callers it // would be worthwhile to disable the notifications // during. The call to SetDeviceState is designed // to allow you to pass in multiple devices in an // array to disable, even though we are currently just // doing the selected one. Also the search is a // substring search so be careful not to use something // so generic that it will affect more devices than // the one(s) you intended. See the notes for the // SetDeviceState method in the library for some // important info. private void button1_Click(object sender, EventArgs e) { if (listdevices.SelectedIndices.Count == 0) { return; } hwh.CutLooseHardwareNotifications(this.Handle); try { DEVICE_INFO di = (DEVICE_INFO)listdevices.SelectedItems[0].Tag; hwh.SetDeviceState(di, true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } hwh.HookHardwareNotifications(this.Handle, true); }
private static void Main(string[] args) { if (args.Length > 0) { if (args[0] == "cli") { cliOnly = true; } } var devices = hhlib.GetAll(); DEVICE_INFO graphics = new DEVICE_INFO(); var found = false; foreach (var info in devices) { if (info.name.ToLower().Contains("nvidia geforce")) { found = true; graphics = info; } } if (found) { if (!cliOnly) { Console.WriteLine($"Found GPU: {graphics.name}\nResetting device..."); } ResetGPU(graphics); } else { if (!cliOnly) { Console.WriteLine("Could not find graphics."); Thread.Sleep(3000); } else { Console.WriteLine(0); } } }
/// <summary> /// Constructor: /// </summary> /// <param name="host">Plugin owning this data</param> /// <param name="guid">Guid of the node owning this data</param> public ControlPanelData(PluginComponent host, string guid) : base(host, guid) { InitDataAtViewTime = false; HardwareState = HARDWARE_STATE.DETACHED; settings = new Settings(); commLog = new ArrayList(); deviceInfo = new DEVICE_INFO(); // query remote device info. DeviceDatbaseItem item = Host.DeviceDatabase.FindByGuid(Host.DeviceConnection.Guid); RemotePlatform = item.Platform; RemoteDescription = item.Description; RemoteVersion = string.Format("{0}.{1:00}", item.OsMajor, item.OsMinor); RemoteCPU = item.CPU; // restore settings from file. settingsPath = host.SettingsPath; settings.Deserialize(settingsPath); }
private void Form1_Load(object sender, EventArgs e) { var result = -1U; try { result = HWSignApi.HWInit(new IntPtr(0)); Thread.Sleep(200); result = HWSignApi.GetDeviceStatus(); DEVICE_INFO dEVICE_INFO = new DEVICE_INFO(); result = HWSignApi.GetDeviceInfo(ref dEVICE_INFO); HWSignApi.RegisterTouchInfoCallBack(TouchInfoCallBack); graphics = pictureBox1.CreateGraphics(); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; } catch (Exception ex) { } }
public static extern int GetDeviceInfo(int devId, ref DEVICE_INFO devInfo);
public int OpenDevice() { BthRuntime.SetLogFileName("BthEmulManager.txt"); int level = DesktopLogging ? 255 : 0; BthRuntime.SetLogLevel(level); devId = BthRuntime.OpenDevice(); if (BthRuntime.INVALID_DEVICE_ID == devId) { HardwareState = HARDWARE_STATE.UNAVAILABLE; int lastError = Marshal.GetLastWin32Error(); HardwareErrorCode = lastError; HardwareErrorMessage = new System.ComponentModel.Win32Exception(lastError).Message; RenderViews(null); } else { HardwareState = HARDWARE_STATE.ATTACHED; // get device info. DEVICE_INFO deviceInfo = new DEVICE_INFO(); if (1 == BthRuntime.GetDeviceInfo(devId, ref deviceInfo)) { DeviceInfo = deviceInfo; Manufacturer = BthRuntime.GetManufacturerName(deviceInfo.manufacturer); } // start connection monitor timer. connectionMonitorTimer = new System.Timers.Timer(); connectionMonitorTimer.Elapsed += new ElapsedEventHandler(ConnectionMonitorTimerEvent); connectionMonitorTimer.Interval = 3000; connectionMonitorTimer.Start(); } return devId; }
public static extern bool USB_GetDeviceInfo(Int32 DevIndex, ref DEVICE_INFO pDevInfo, StringBuilder pFunctionStr);
public static extern int GetDeviceInfo(int devId, ref DEVICE_INFO devInfo);
public static extern bool DEV_GetDeviceInfo(Int32 DevHandle, ref DEVICE_INFO pDevInfo, StringBuilder pFunctionStr);
private void tb_cl_cmd(ref IPC_SIMPLE_ANSWER aisa) { IPC_SIMPLE_ANSWER isa = aisa; if (isa.cmd_id == 45) { if (!isa.is_cmd_over_flag && !isa.is_cmd_failed_flag) { call.m_thisPtr.Invoke(new MethodInvoker(delegate { DEVICE_INFO dEVICE_INFO = isa.return_object as DEVICE_INFO; if (call.m_devList.ContainsKey(isa.product_id)) { call.m_devList.Remove(isa.product_id); } call.m_devList.Add(dEVICE_INFO.product_id, dEVICE_INFO); })); } } else if (isa.cmd_id == 4338) { if (isa.is_cmd_over_flag && !isa.is_cmd_failed_flag) { call.m_thisPtr.Invoke(new MethodInvoker(delegate { Dictionary <string, DEVICE_INFO> dictionary = isa.return_object as Dictionary <string, DEVICE_INFO>; foreach (DEVICE_INFO current in call.m_devList.Values) { if (current.cur_use_net_mode == 1 || current.cur_use_net_mode == 8) { DEVICE_INFO dEVICE_INFO; if (dictionary.TryGetValue(current.product_id, out dEVICE_INFO)) { current.state = dEVICE_INFO.state; } } } })); } else if (!isa.is_cmd_over_flag && !isa.is_cmd_failed_flag) { call.m_thisPtr.Invoke(new MethodInvoker(delegate { DEVICE_INFO dEVICE_INFO; if (isa.product_id != null && call.m_devList.TryGetValue(isa.product_id, out dEVICE_INFO)) { DEVICE_INFO expr_32 = dEVICE_INFO; expr_32.state |= DEVICE_STATE.ST_ONLINE; } })); } } else if (isa.cmd_id == 4339) { if (isa.is_cmd_over_flag && !isa.is_cmd_failed_flag) { call.m_thisPtr.Invoke(new MethodInvoker(delegate { DEVICE_INFO dEVICE_INFO = isa.return_object as DEVICE_INFO; if (call.m_devList.ContainsKey(isa.product_id)) { call.m_devList.Remove(isa.product_id); } call.m_devList.Add(dEVICE_INFO.product_id, dEVICE_INFO); })); } } aisa = isa; }