private void DeviceRemovedConroller(Dictionary <string, string> properties) { if (properties.ContainsKey("Dependent")) { var device_id = properties["Dependent"]; string VidPid = "", UniqueId = ""; if (USBUtil.dependent_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId)) { OnDeletedDevice(VidPid, UniqueId); } } }
private PDManager() { var existing_devices = DeviceFinder.FindObjects("Win32_USBHub"); foreach (var device in existing_devices) { if (device.ContainsKey("PNPDeviceID")) { var device_id = device["PNPDeviceID"]; string VidPid = "", UniqueId = ""; if (USBUtil.pnp_device_id_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId)) { lock (this) vidpid_to_unique_id_.Add(VidPid, UniqueId); } } } var existing_controller_devices = DeviceFinder.FindObjects("Win32_USBControllerDevice"); foreach (var device in existing_controller_devices) { if (device.ContainsKey("Dependent")) { var device_id = device["Dependent"]; string VidPid = "", UniqueId = ""; if (USBUtil.dependent_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId)) { lock (this) if (!vidpid_to_unique_id_.ContainsKey(VidPid)) { vidpid_to_unique_id_.Add(VidPid, UniqueId); } } } } Refresh(); monitor_usbhub_devices_.DeviceAddedEvent += DeviceAdded; monitor_usbhub_devices_.DeviceDeletedEvent += DeviceRemoved; monitor_usbhub_devices_.Monitor("Win32_USBHub"); monitor_controller_devices_.DeviceAddedEvent += DeviceAddedConroller; monitor_controller_devices_.DeviceDeletedEvent += DeviceRemovedConroller; monitor_controller_devices_.Monitor("Win32_USBControllerDevice"); new Thread(Win32Util.check_for_dialogs_thread) { IsBackground = true }.Start(); }
private void DeviceRemoved(Dictionary <string, string> properties) { if (properties.ContainsKey("PNPDeviceID")) { var device_id = properties["PNPDeviceID"]; string VidPid = "", UniqueId = ""; if (USBUtil.pnp_device_id_to_vidpid_and_unique_id(device_id, ref VidPid, ref UniqueId)) { OnDeletedDevice(VidPid, UniqueId); } } else { // deleted usb device with no PNPDeviceID Debug.Assert(false); } }
public SampleAppForm() { InitializeComponent(); //Add event listener to response received event grbl.ResponseReceived += Grbl_ResponseReceived; //Add event listener to gcode status update event grbl.GCodeStatusUpdate += Grbl_GCodeStatusUpdate; USBUtil.USBPortChangeEvent += USBUtil_USBPortChangeEvent; USBUtil.init(); StopGrbl(); LoadMachines(); //If ports found and only one availeble, open at the beginning StartGrbl(); }
public PortableDrive(FolderItem fi) { root_ = fi; friendly_name_ = root_.Name; root_path_ = root_.Path; if (USBUtil.portable_path_to_vidpid(root_path_, ref vid_pid_)) { unique_id_ = vid_pid_; } // 1.2.3+ - sometimes, we can't match vidpid to unique id (for instance, iphones). in this case, do our best and just // use the unique id from the path itself var unique_id_from_path = USBUtil.unique_id_from_root_path(root_path_); if (unique_id_from_path != "") { unique_id_ = unique_id_from_path; } FindDriveType(); }