public EposDeviceManager(MasterSettings settings, SyncCloudAgent cloudAgent) : base(cloudAgent) { _deviceScanner = new DeviceScanner(settings); RegisterEvents(); }
public static void tryAgain(List <string> hosts) { for (int j = 0; j <= 5; j++) { for (int i = 0; i < hosts.Count; i++) { if (hosts.Count > 0 && hosts[i] != null && hosts[i].Length > 0) { if (DeviceScanner.IsHostAccessible(hosts[i])) { Console.WriteLine($"Rechner: {getHostNameFromIp(hosts[i])} mit IP:{ hosts[i]} ist nun erreichbar\r\n"); hosts.Remove(hosts[i]); break; } } i++; } j++; if (hosts.Count == 0) { break; } Thread.Sleep(5000); } foreach (string notFoundIP in hosts) { Console.WriteLine("Rechner wurde nicht gefunden. Möglicherweise ist der Rechner nicht eingeschaltet \r\noder nicht mit dem Netzwerk verbunden.\r\n"); } }
void Awake() { scanner = new DeviceScanner(USB_VID, USB_PID); scanner.DeviceArrived += enter; scanner.DeviceRemoved += exit; scanner.StartAsyncScan(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create the cast video button View.BackgroundColor = UIColor.White; var btnCastVideo = UIButton.FromType(UIButtonType.RoundedRect); btnCastVideo.Frame = new CGRect(110, 90, 100, 30); btnCastVideo.SetTitle("Cast Video", UIControlState.Normal); btnCastVideo.TouchUpInside += CastVideo; View.AddSubview(btnCastVideo); // Get cast button images castButtonImage = UIImage.FromBundle("icon-cast-identified.png"); // Create the cast button castButton = UIButton.FromType(UIButtonType.RoundedRect); castButton.Frame = new CGRect(0, 0, castButtonImage.Size.Width, castButtonImage.Size.Height); castButton.SetImage(null, UIControlState.Normal); castButton.Hidden = true; castButton.TouchUpInside += ChooseDevice; // Add button to the navigation bar NavigationItem.RightBarButtonItem = new UIBarButtonItem(castButton); // Initialize the device scanner DeviceScanner = new DeviceScanner(); DeviceScanner.AddListener(new DeviceScannerListener(this)); DeviceScanner.StartScan(); }
public List <PCDevice> UpdateDevices() { var scanner = DeviceScanner.GetInstance(); scanner.UpdateDevices(); Devices = scanner.Devices; return(Devices); }
protected override void OnDisappearing() { base.OnDisappearing(); if (DeviceScanner.Status == BluetoothLEScannerState.Started) { DeviceScanner.Stop(); } }
public EposDeviceManager(MasterSettings settings) { VcsWrapper.Device.Init(); _deviceScanner = new DeviceScanner(settings); RegisterEvents(); }
//-------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour (if added to the scene) public void Start() { if (!DeviceScanner.IsScanning()) { SenseGloveCs.DeviceScanner.pingTime = 200; SenseGloveCs.DeviceScanner.scanDelay = 500; DeviceScanner.StartScanning(true); } }
//-------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour (if added to the scene) public void Start() { if (!DeviceScanner.IsScanning) { SenseGloveCs.DeviceScanner.ResponseTime = 200; SenseGloveCs.DeviceScanner.ScanInterval = 500; DeviceScanner.StartScanning(2.0f); } }
//[System.Runtime.InteropServices.DllImport("gdi32.dll")] //public static extern bool DeleteObject(IntPtr hObject); public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; _timer.Tick += Timer_Tick; deviceIO = new DeviceIO(); deviceScanner = new DeviceScanner(); deviceScanner.StartListening(); }
private void ScanButton_Clicked(object sender, EventArgs e) { if (DeviceScanner.Status == BluetoothLEScannerState.Started) { DeviceScanner.Stop(); } else { BluetoothDeviceList.Clear(); BluetoothManager.LEScanner.Start(); ScanButton.Text = "Scanning(Click To Stop)"; } }
new static public Aja BoardGet(uint nIndex) { (new Logger("Aja", null)).WriteDebug2("in"); DeviceScanner cDScanner = new DeviceScanner(); Aja cRetVal = null; uint nDevicesCount = cDScanner.GetNumDevices(); if (nIndex < nDevicesCount) { cRetVal = new Aja(cDScanner.GetDeviceInfo(nIndex), nIndex); } (new Logger("Aja", null)).WriteDebug2("out"); return(cRetVal); }
private void UpdateDeviceList() { if (!this.listView.IsEnabled) { return; } var devices = new List <IIinputDevice>(); devices.Add(VirtualKeyboard.Instance); devices.AddRange(DeviceScanner.GetHidKeyboards()); devices.AddRange(DeviceScanner.GetHidMice()); devices.AddRange(DeviceScanner.GetUsbGamepads()); devices.AddRange(DeviceScanner.GetOtherHidDevices()); var devicesToRemove = new List <IIinputDevice>(); foreach (var device in devices) { if (device.DeviceType != DeviceType.Other) { continue; } ushort vid = Convert.ToUInt16(device.Vendor, 16); ushort pid = Convert.ToUInt16(device.Product, 16); var rawDevices = HidDataReader.GetDevices().Where(d => d.ProductId == pid && d.VendorId == vid); if (rawDevices.Count() == 0) { devicesToRemove.Add(device); } } foreach (var deviceToRemove in devicesToRemove) { devices.Remove(deviceToRemove); } this.listView.ItemsSource = devices; this.listView.SelectedIndex = -1; var view = (CollectionView)CollectionViewSource.GetDefaultView(this.listView.ItemsSource); var groupDescription = new PropertyGroupDescription("DeviceType"); view.GroupDescriptions.Add(groupDescription); this.lastData = new byte[0]; }
/// <summary> /// Kiểm tra xem địa chỉ MAC có online không /// </summary> /// <param name="macWithoutSeparator">MAC không có dấu phân cách</param> /// <returns></returns> public bool IsOnline(string macWithoutSeparator) { string macForARPTable = MACHandler.ConvertToSeparatedMac(macWithoutSeparator, "-"); string ipOfMAC = finder.FindIpAddressByMacAddress(macForARPTable); try { return(DeviceScanner.IsHostAccessible(ipOfMAC)); } catch (ArgumentNullException e) { throw new ArgumentNullException("This MAC is not in ARP Table", e); //có thể dùng được MAC này } catch { throw; } }
public MainController(MainWindow _mainWindow) { if (!Directory.Exists("Images")) { Directory.CreateDirectory("Images"); } mainWindow = _mainWindow; Load(); LoadIcons(); scanner = new DeviceScanner(0xffff, 0x1f40); scanner.DeviceArrived += enter; scanner.DeviceRemoved += exit; scanner.StartAsyncScan(); SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch); }
static void Main(string[] args) { // setup a scanner before hand DeviceScanner scanner = new DeviceScanner(0x4d8, 0x3f); scanner.DeviceArrived += enter; scanner.DeviceRemoved += exit; scanner.StartAsyncScan(); Console.WriteLine("asd"); // this should probably happen in enter() function try { // this can all happen inside a using(...) statement USBDevice dev = new USBDevice(0x4d8, 0x3f, null, false, 31); Console.WriteLine(dev.Description()); // add handle for data read dev.InputReportArrivedEvent += handle; // after adding the handle start reading dev.StartAsyncRead(); // can add more handles at any time dev.InputReportArrivedEvent += handle; // write some data byte[] data = new byte[32]; data[0] = 0x00; data[1] = 0x23; dev.Write(data); dev.Dispose(); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadKey(); }
public static List <string> hostsNotReachable() { if (macAdresses.Count > 0) { foreach (string mac in macAdresses) { foreach (IPAddress ip in hostInfo.AddressList) { try { // For Debug Purpose //Console.WriteLine($"ermittelte IP: {ip.ToString().Substring(0, 9)} eigene IP: {IpFinder.GetOwnIPV4().Substring(0, 9)}"); if (!String.IsNullOrEmpty(ip.ToString()) && ip.ToString().Substring(0, 9).Equals(IpFinder.GetOwnIPV4().Substring(0, 9))) { IpAdresse = ip.ToString(); // For Debug Purpose //Console.WriteLine(IpAdresse); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } remoteHostIP = IpFinder.FindIpAddressByMacAddress(mac, IpAdresse); if (DeviceScanner.IsHostAccessible(remoteHostIP)) { Console.WriteLine($"Rechner {getHostNameFromIp(remoteHostIP)} mit IP:{remoteHostIP} ist nun erreichbar\r\n"); } else { HostsOffline.Add(remoteHostIP); } } } return(HostsOffline); }
static public int BoardsQtyGet() { DeviceScanner cDScanner = new DeviceScanner(); return((int)cDScanner.GetNumDevices()); }
public override void ViewDidLoad() { // Get cast button images castButtonImage = UIImage.FromBundle ("icon-cast-identified.png"); // Create the cast button CastButton = UIButton.FromType (UIButtonType.RoundedRect); CastButton.Frame = new CGRect (0, 0, castButtonImage.Size.Width, castButtonImage.Size.Height); CastButton.SetImage (null, UIControlState.Normal); CastButton.Hidden = true; CastButton.TouchUpInside += ChooseDevice; // Add button to the navigation bar NavigationItem.RightBarButtonItem = new UIBarButtonItem (CastButton); // Initialize the device scanner DeviceScanner = new DeviceScanner (); DeviceScanner.AddListener(new DeviceScannerListener(this) { UpdateDeviceOnlineStatus = UpdateButtonStates ,UpdateDeviceOfflineStatus = UpdateButtonStates }); DeviceScanner.StartScan (); this.SimpleCastBtn.TouchUpInside += SimpleCastBtn_TouchUpInside; base.ViewDidLoad(); }
private void DeviceScanner_EnumerationCompleted(object sender, EventArgs e) { DeviceScanner.Stop(); }
public static bool Get_This_Device(ushort p_VendorID, ushort p_PoductID, ushort p_index, ref IntPtr p_ReadHandle, ref IntPtr p_WriteHandle, ref string p_devicepath, bool p_pass_ptr_to_handle, ref Guid p_HidGuid, ref ushort p_num_devices_attached) { Utilities.InitializeParams(); LIN.initialize_LIN_frames(); IntPtr deviceInfoSet = IntPtr.Zero; IntPtr zero = IntPtr.Zero; USB.HIDP_CAPS hIDP_CAPS = default(USB.HIDP_CAPS); ushort num = 0; IntPtr intPtr = IntPtr.Zero; int num2 = 0; USB.SECURITY_ATTRIBUTES sECURITY_ATTRIBUTES = default(USB.SECURITY_ATTRIBUTES); IntPtr intPtr2 = new IntPtr(-1); sECURITY_ATTRIBUTES.lpSecurityDescriptor = 0; sECURITY_ATTRIBUTES.bInheritHandle = Convert.ToInt32(true); sECURITY_ATTRIBUTES.nLength = Marshal.SizeOf(sECURITY_ATTRIBUTES); Guid empty = Guid.Empty; USB.SP_DEVICE_INTERFACE_DATA sP_DEVICE_INTERFACE_DATA; sP_DEVICE_INTERFACE_DATA.cbSize = 0; sP_DEVICE_INTERFACE_DATA.Flags = 0; sP_DEVICE_INTERFACE_DATA.InterfaceClassGuid = Guid.Empty; sP_DEVICE_INTERFACE_DATA.Reserved = 0; USB.SP_DEVICE_INTERFACE_DETAIL_DATA sP_DEVICE_INTERFACE_DETAIL_DATA; sP_DEVICE_INTERFACE_DETAIL_DATA.cbSize = 0; sP_DEVICE_INTERFACE_DETAIL_DATA.DevicePath = ""; USB.HIDD_ATTRIBUTES hIDD_ATTRIBUTES; hIDD_ATTRIBUTES.ProductID = 0; hIDD_ATTRIBUTES.Size = 0; hIDD_ATTRIBUTES.VendorID = 0; hIDD_ATTRIBUTES.VersionNumber = 0; bool result = false; sECURITY_ATTRIBUTES.lpSecurityDescriptor = 0; sECURITY_ATTRIBUTES.bInheritHandle = Convert.ToInt32(true); sECURITY_ATTRIBUTES.nLength = Marshal.SizeOf(sECURITY_ATTRIBUTES); /* * USB.HidD_GetHidGuid(ref empty); * deviceInfoSet = USB.SetupDiGetClassDevs(ref empty, null, 0, 18); * sP_DEVICE_INTERFACE_DATA.cbSize = Marshal.SizeOf(sP_DEVICE_INTERFACE_DATA); * for (int i = 0; i < 30; i++) * { * int num3 = USB.SetupDiEnumDeviceInterfaces(deviceInfoSet, 0, ref empty, i, ref sP_DEVICE_INTERFACE_DATA); * if (num3 != 0) * { * USB.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref sP_DEVICE_INTERFACE_DATA, IntPtr.Zero, 0, ref num2, IntPtr.Zero); * sP_DEVICE_INTERFACE_DETAIL_DATA.cbSize = Marshal.SizeOf(sP_DEVICE_INTERFACE_DETAIL_DATA); * IntPtr intPtr3 = Marshal.AllocHGlobal(num2); * Marshal.WriteInt32(intPtr3, 4 + Marshal.SystemDefaultCharSize); * USB.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref sP_DEVICE_INTERFACE_DATA, intPtr3, num2, ref num2, IntPtr.Zero); * IntPtr intPtr4 = new IntPtr(intPtr3.ToInt32() + 4); * string text = Marshal.PtrToStringAuto(intPtr4); * intPtr = USB.CreateFile(text, 3221225472u, 3u, ref sECURITY_ATTRIBUTES, 3, 0u, 0); * if (intPtr != intPtr2) * { * hIDD_ATTRIBUTES.Size = Marshal.SizeOf(hIDD_ATTRIBUTES); * num3 = USB.HidD_GetAttributes(intPtr, ref hIDD_ATTRIBUTES); * if (num3 != 0) * { * if (hIDD_ATTRIBUTES.VendorID == p_VendorID && hIDD_ATTRIBUTES.ProductID == p_PoductID) * { * if (num == p_index) * { * result = true; * if (p_pass_ptr_to_handle) * { * p_WriteHandle = intPtr; * } * p_devicepath = text; * p_HidGuid = empty; * //Utilities.m_flags.HID_write_handle = intPtr; * USB.HidD_GetPreparsedData(intPtr, ref zero); * USB.HidP_GetCaps(zero, ref hIDP_CAPS); * Utilities.m_flags.irbl = (ushort)hIDP_CAPS.InputReportByteLength; * //Utilities.m_flags.HID_read_handle = USB.CreateFile(text, 3221225472u, 3u, ref sECURITY_ATTRIBUTES, 3, 0u, 0); * if (p_pass_ptr_to_handle) * { * //p_ReadHandle = Utilities.m_flags.HID_read_handle; * } * USB.HidD_FreePreparsedData(ref zero); * break; * } * num += 1; * } * else * { * result = false; * USB.CloseHandle(intPtr); * } * } * else * { * result = false; * USB.CloseHandle(intPtr); * } * } * } * } * USB.SetupDiDestroyDeviceInfoList(deviceInfoSet); * p_num_devices_attached = num; */ Utilities.m_flags.irbl = 65; if (DeviceScanner.ScanOnce(p_VendorID, p_PoductID)) { Utilities.m_flags.HID_Handle = new USBDevice(p_VendorID, p_PoductID, null, false, 65); Utilities.m_flags.HID_DeviceReady = true; result = true; } else { Utilities.m_flags.HID_DeviceReady = false; result = false; } return(result); }