コード例 #1
0
        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));
                    }
                }
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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;
     }
 }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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));
            }
        }
コード例 #8
0
 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);
 }
コード例 #9
0
 internal LinuxUsbDeviceNotifyInfo(LinuxDevItem linuxDevItem)
 {
     mLinuxDevItem = linuxDevItem;
 }
コード例 #10
0
 internal LinuxUsbDeviceNotifyInfo(LinuxDevItem linuxDevItem)
 {
     mLinuxDevItem = linuxDevItem;
 }
コード例 #11
0
        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));
                    }
                }
            }
        }
コード例 #12
0
 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);
 }