コード例 #1
0
ファイル: PololuMiniUsb.cs プロジェクト: KiwiJaune/GoBot
        static PololuMiniUsb()
        {
            List<DeviceListItem> device_list = Usc.getConnectedDevices();
            if (device_list.Count > 0)
            {
                serialNumber = device_list[0].serialNumber;
                usc = new Usc(device_list[0]);
                settings = usc.getUscSettings();

                Console.WriteLine("Pololu connectée");

                List<int> servos = new List<int>();
                servos.Add(1);
                servos.Add(0);
                servos.Add(3);
                servos.Add(2);
                servos.Add(5);
                servos.Add(8);
                servos.Add(6);
                servos.Add(7);

                connected = true;
                for (int i = 0; i < servos.Count; i++)
                {
                    setMin(servos[i], 256);
                    setMax(servos[i], 16320);
                }
            }
            else
            {
                Console.WriteLine("Pololu non connectée");
            }
        }
コード例 #2
0
ファイル: Analog.cs プロジェクト: siegelpeter/UAV-NET
        /// <summary>
        /// Connects to a Maestro using native USB and returns the Usc object
        /// representing that connection.  When you are done with the
        /// connection, you should close it using the Dispose() method so that
        /// other processes or functions can connect to the device later.  The
        /// "using" statement can do this automatically for you.
        /// </summary>
        Usc connectToDevice()
        {
            // Get a list of all connected devices of this type.
            List<DeviceListItem> connectedDevices = Usc.getConnectedDevices();

            foreach (DeviceListItem dli in connectedDevices)
            {
                if ((device == null) || (this.device == dli.serialNumber))
                {
                    // If you have multiple devices connected and want to select a particular
                    // device by serial number, you could simply add a line like this:
                    //   if (dli.serialNumber != "00012345"){ continue; }

                    Usc uscdevice = new Usc(dli); // Connect to the device.
                    uscdevice.getUscSettings().channelSettings[channel].mode = ChannelMode.Output;
                    return uscdevice;             // Return the device.
                }
            }
            throw new Exception("Could not find device.  Make sure it is plugged in to USB " +
                "and check your Device Manager (Windows) or run lsusb (Linux).");
        }