/// <summary> /// Записываем Feature Report в девайс. /// </summary> /// <param name="ReportID">Report ID</param> /// <param name="Data">Report Data to Write</param> /// <param name="RespondData">Respond Report Data</param> /// <returns>Возвращает True, если успешно отправленны и полученны данные,иначе False</returns> public bool WriteFeatureReport(byte ReportID, byte[] Data, ref byte[] RespondData) { bool success = false; byte[] Report = new byte[SpecifiedDevice.FeatureReportLength]; if (SpecifiedDevice.FeatureReportLength - 1 > Data.Length) { Report[0] = ReportID; Array.Copy(Data, 0, Report, 1, Data.Length); } else { return(success); } try { RespondData = new byte[SpecifiedDevice.FeatureReportLength]; RespondData = SpecifiedDevice.SendFeature(Report, ref success); success = true; } catch (Exception ex) { success = false; } return(success); }
/// <summary> /// Записываем Output Report в девайс. /// </summary> /// <param name="ReportID">Report ID</param> /// <param name="Data">Report Data</param> /// <returns>Возвращает True, если успешно отправленны данные,иначе False</returns> public bool WriteOutputReport(byte ReportID, byte[] Data) { bool success = false; byte[] Report = new byte[SpecifiedDevice.OutputReportLength]; if (SpecifiedDevice.OutputReportLength - 1 > Data.Length) { Report[0] = ReportID; Array.Copy(Data, 0, Report, 1, Data.Length); } else { return(success); } try { SpecifiedDevice.SendData(Report); success = true; } catch (Exception ex) { success = false; } return(success); }
/// <summary> /// Закрываем текущее подключение к устройству, если есть таковое. /// </summary> public void Close() { if (SpecifiedDevice != null) { SpecifiedDevice.Dispose(); SpecifiedDevice = null; if (OnSpecifiedDeviceRemoved != null) { this.OnSpecifiedDeviceRemoved(this, new EventArgs()); } } }
public bool WriteOutputReport(byte[] Data) { bool success = false; try { SpecifiedDevice.SendData(Data); success = true; } catch (Exception ex) { success = false; } return(success); }
public bool WriteFeatureReport(byte[] Data, ref byte[] RespondData) { bool success = false; try { RespondData = new byte[SpecifiedDevice.FeatureReportLength]; RespondData = SpecifiedDevice.SendFeature(Data, ref success); success = true; } catch (Exception ex) { success = false; } return(success); }
void CheckDevicePresent() { try { bool history = false; if (SpecifiedDevice != null) { history = true; } SpecifiedDevice = SpecifiedDevice.FindSpecifiedDevice(VendorId, ProductId); if (SpecifiedDevice != null) { OnSpecifiedDeviceArrived?.Invoke(this, new EventArgs()); if (OnDataRecieved != null) { SpecifiedDevice.DataRecieved += new DataRecievedEventHandler(OnDataRecieved); } if (OnDataSend != null) { SpecifiedDevice.DataSend += new DataSendEventHandler(OnDataSend); } } else { if (OnSpecifiedDeviceRemoved != null && history) { this.OnSpecifiedDeviceRemoved(this, new EventArgs()); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public bool Open(HIDDeviceAvalible Device) { bool success = true; SpecifiedDevice = SpecifiedDevice.OpenSpecifiedDevice(Device.Path); if (SpecifiedDevice == null) { success = false; } else { OnSpecifiedDeviceArrived?.Invoke(this, new EventArgs()); if (OnDataRecieved != null) { SpecifiedDevice.DataRecieved += new DataRecievedEventHandler(OnDataRecieved); } if (OnDataSend != null) { SpecifiedDevice.DataSend += new DataSendEventHandler(OnDataSend); } } return(success); }
public static List <HIDDeviceAvalible> GetDevicesList() { return(SpecifiedDevice.GetDevicesList()); }
public static List <HIDDeviceAvalible> GetDevicesList(UInt16 VendorId) { return(SpecifiedDevice.GetDevicesListByVID(VendorId)); }