private void FileAdded(object sender, FileSystemEventArgs e) { byte busNumber; byte deviceAddress; if (IsDeviceEnterface(e.Name, out busNumber, out deviceAddress)) { byte[] descriptorBytes; if (ReadFileDescriptor(e.FullPath, out descriptorBytes)) { LinuxDevItem addedItem = new LinuxDevItem(e.Name, busNumber, deviceAddress, descriptorBytes); if (mLinuxDevItemList.FindByName(e.Name) != null) { throw new Exception("FileAdded:Invalid LinuxDevItem"); } mLinuxDevItemList.Add(addedItem); //Console.WriteLine("Added Vid:{0:X4} Pid:{1:X4}", addedItem.DeviceDescriptor.VendorID, addedItem.DeviceDescriptor.ProductID); ////////////////////// // TODO:DEVICE ARRIVAL ////////////////////// EventHandler <DeviceNotifyEventArgs> deviceNotify = OnDeviceNotify; if (!ReferenceEquals(deviceNotify, null)) { deviceNotify(this, new LinuxDeviceNotifyEventArgs(addedItem, DeviceType.DeviceInterface, EventType.DeviceArrival)); } } } }
public bool Equals(LinuxDevItem other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.DeviceFileName, DeviceFileName) && other.BusNumber == BusNumber && other.DeviceAddress == DeviceAddress && Equals(other.DeviceDescriptor, DeviceDescriptor); }
public bool Equals(LinuxDevItem other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.DeviceFileName, DeviceFileName) && other.BusNumber == BusNumber && other.DeviceAddress == DeviceAddress && Equals(other.DeviceDescriptor, DeviceDescriptor)); }
internal LinuxDeviceNotifyEventArgs(LinuxDevItem linuxDevItem, DeviceType deviceType, EventType eventType) { mEventType = eventType; mDeviceType = deviceType; switch (mDeviceType) { case DeviceType.Volume: throw new NotImplementedException(mDeviceType.ToString()); case DeviceType.Port: throw new NotImplementedException(mDeviceType.ToString()); case DeviceType.DeviceInterface: mDevice = new LinuxUsbDeviceNotifyInfo(linuxDevItem); mObject = mDevice; break; } }
internal LinuxDeviceNotifyEventArgs(LinuxDevItem linuxDevItem, DeviceType deviceType, EventType eventType) { EventType = eventType; DeviceType = deviceType; switch (DeviceType) { case DeviceType.Volume: throw new NotImplementedException(DeviceType.ToString()); case DeviceType.Port: throw new NotImplementedException(DeviceType.ToString()); case DeviceType.DeviceInterface: Device = new LinuxUsbDeviceNotifyInfo(linuxDevItem); Object = Device; break; } }
private void OnAddRemoveEvent(object sender, AddRemoveEventArgs e) { EventHandler<DeviceNotifyEventArgs> deviceNotify = OnDeviceNotify; if (!ReferenceEquals(deviceNotify, null)) { string deviceFileName = String.Format("usbdev{0}.{1}", e.MonoUSBProfile.BusNumber, e.MonoUSBProfile.DeviceAddress); LinuxDevItem linuxDevItem = new LinuxDevItem(deviceFileName, e.MonoUSBProfile.BusNumber, e.MonoUSBProfile.DeviceAddress, e.MonoUSBProfile.DeviceDescriptor); deviceNotify(this, new LinuxDeviceNotifyEventArgs(linuxDevItem, DeviceType.DeviceInterface, e.EventType == AddRemoveType.Added ? EventType.DeviceArrival : EventType.DeviceRemoveComplete)); } }
private void OnAddRemoveEvent(object sender, AddRemoveEventArgs e) { EventHandler <DeviceNotifyEventArgs> deviceNotify = OnDeviceNotify; if (!ReferenceEquals(deviceNotify, null)) { string deviceFileName = e.MonoUSBProfile.MakeDevicePath(); LinuxDevItem linuxDevItem = new LinuxDevItem(deviceFileName, e.MonoUSBProfile.BusNumber, e.MonoUSBProfile.DeviceAddress, e.MonoUSBProfile.DeviceDescriptor); deviceNotify(this, new LinuxDeviceNotifyEventArgs(linuxDevItem, DeviceType.DeviceInterface, e.EventType == AddRemoveType.Added ? EventType.DeviceArrival : EventType.DeviceRemoveComplete)); } }
private void BuildDevList() { mLinuxDevItemList.Clear(); string[] deviceInterfaceFiles = Directory.GetFiles(mDevDir, "usbdev*", SearchOption.TopDirectoryOnly); foreach (string deviceInterfaceFile in deviceInterfaceFiles) { byte busNumber; byte deviceAddress; string deviceFileName = Path.GetFileName(deviceInterfaceFile); if (IsDeviceEnterface(deviceFileName, out busNumber, out deviceAddress)) { byte[] descriptorBytes; if (ReadFileDescriptor(deviceInterfaceFile, out descriptorBytes)) { LinuxDevItem addedItem = new LinuxDevItem(deviceFileName, busNumber, deviceAddress, descriptorBytes); mLinuxDevItemList.Add(addedItem); } } } //Console.WriteLine("LinuxDeviceNotifier:BuildDevList Count:{0}",mLinuxDevItemList.Count); }
internal LinuxUsbDeviceNotifyInfo(LinuxDevItem linuxDevItem) { mLinuxDevItem = linuxDevItem; }
private void FileAdded(object sender, FileSystemEventArgs e) { byte busNumber; byte deviceAddress; if (IsDeviceEnterface(e.Name, out busNumber, out deviceAddress)) { byte[] descriptorBytes; if (ReadFileDescriptor(e.FullPath, out descriptorBytes)) { LinuxDevItem addedItem = new LinuxDevItem(e.Name, busNumber, deviceAddress, descriptorBytes); if (mLinuxDevItemList.FindByName(e.Name) != null) throw new Exception("FileAdded:Invalid LinuxDevItem"); mLinuxDevItemList.Add(addedItem); //Console.WriteLine("Added Vid:{0:X4} Pid:{1:X4}", addedItem.DeviceDescriptor.VendorID, addedItem.DeviceDescriptor.ProductID); ////////////////////// // TODO:DEVICE ARRIVAL ////////////////////// EventHandler<DeviceNotifyEventArgs> deviceNotify = OnDeviceNotify; if (!ReferenceEquals(deviceNotify, null)) { deviceNotify(this, new LinuxDeviceNotifyEventArgs(addedItem, DeviceType.DeviceInterface, EventType.DeviceArrival)); } } } }