Ejemplo n.º 1
0
        private void btnOpenUSBInterface_Click(object sender, EventArgs e)
        {
            if (bWithHardware)
            {
                if (USBInterface.Open(cboSelectUSBInterface.Text))
                {
                    lblStatus.Text      = "USB-Interface opened";
                    lblStatus.BackColor = Color.Green;

                    // Abtasttimer starten
                    tmrSampling.Start();
                }
                else
                {
                    lblStatus.Text      = "USB-Interface open failed";
                    lblStatus.BackColor = Color.Red;
                }
            }
            else // without hardware
            {
                lblStatus.Text      = "USB-Interface simulated";
                lblStatus.BackColor = Color.Orange;

                // Abtasttimer starten
                tmrSampling.Start();
            }
        }
Ejemplo n.º 2
0
        private void btnOpenUSBInterface_Click(object sender, EventArgs e)
        {
            if (bWithHardware)
            {
                if (USBInterface.Open(cboSelectUSBInterface.Text))
                {
                    lblStatus.Text      = "USB-Interface opened! Success!";
                    lblStatus.BackColor = Color.Green;

                    lblVoltage.BackColor              = Color.Green;
                    lblDistance.BackColor             = Color.Green;
                    USBInterface.DigitalOutLine[2, 0] = true;
                    //Start Samplingtimer
                    tmrSampling.Start();
                }
                else
                {
                    lblStatus.Text      = "USB-Interface open failed! Lockekopf Raus, Tanktop rein! Error!";
                    lblStatus.BackColor = Color.Red;
                }
            }
            else // No hardware -> simulation
            {
                lblStatus.Text      = "USB-Interface simulated";
                lblStatus.BackColor = Color.Orange;

                lblVoltage.BackColor  = Color.Orange;
                lblDistance.BackColor = Color.Orange;

                //Start Samplingtimer for simulation
                tmrSampling.Start();
            }
        }
Ejemplo n.º 3
0
        static void Run()
        {
            USBHIDDRIVER.USBInterface usb = new USBInterface("vid_11fa", "pid_0202");

            usb.Connect();

            usb.enableUsbBufferEvent(new System.EventHandler(MyEventCacher));

            usb.startRead();

            Console.Write("Press CTRL+C To Quit" + Environment.NewLine);
            Console.CancelKeyPress += (sender, eArgs) =>
            {
                _quitEvent.Set();
                eArgs.Cancel = true;
            };

            _quitEvent.WaitOne();

            usb.stopRead();

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
            }
        }
Ejemplo n.º 4
0
        public InputSourceBaanto()
        {
            USBInterface usb = new USBInterface("vid_2453", "pid_0100");

            usb.Connect();
            usb.enableUsbBufferEvent(incomingData);
            usb.startRead();
        }
Ejemplo n.º 5
0
        private static void WriteData(USBInterface usb, byte secondByteValue)
        {
            var command = new byte[] { 0, 2 };

            command[1] = secondByteValue;
            usb.UsbDevice.writeDataSimple(command);
            Thread.Sleep(50);
        }
Ejemplo n.º 6
0
 public void DeinitDevice()
 {
     if (ctsNumLock != null && !ctsNumLock.IsCancellationRequested)
     {
         ctsNumLock.Cancel();
     }
     StopMonitoring();
     iface = null;
 }
Ejemplo n.º 7
0
 public static String[] getALLUsbDevices()
 {
     USBHIDDRIVER.USBInterface usbTemp = new USBInterface("0");
     if (usbTemp.getDeviceList().Length > 1)
     {
         Console.WriteLine("dfsdfsdF");
     }
     return(usbTemp.getDeviceList());
 }
Ejemplo n.º 8
0
        private static void Main(string[] args)
        {
            var usb = new USBInterface(@"vid_0a81", @"pid_ff01");

            usb.Connect();
            WriteData(usb, 64);
            WriteData(usb, 16);
            WriteData(usb, 64);
            WriteData(usb, 64);
            WriteData(usb, 32);
            Console.ReadLine();
        }
Ejemplo n.º 9
0
        public void Start()
        {
            device = new USBInterface("vid_1244", "pid_d237");

            if (!device.Connect())
            {
                throw new Exception("Victor 70C Multimeter cannot be found");
            }

            device.enableUsbBufferEvent(new System.EventHandler(myEventCacher));

            Thread.Sleep(5);
            device.startRead();
        }
Ejemplo n.º 10
0
        public LightController()
        {
            const string vendorId  = "vid_1294";
            const string productId = "pid_1320";

            _device = new USBInterface(vendorId, productId);

            if (_connected)
            {
                return;
            }
            _device.enableUsbBufferEvent(UsbDeviceEventCacher);
            _connected = true;
        }
Ejemplo n.º 11
0
        private static void Main(string[] args)
        {
            _device = new USBInterface("vid_1294", "pid_1320");
            _device.Connect();
            var line = Console.ReadLine();

            while (line != null && line != "E")
            {
                var b = Convert.ToByte(line);
                WriteDataEx(b);
                line = Console.ReadLine();
            }
            Console.ReadLine();
        }
Ejemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DeviceSN">The serial number of the controller to be connected</param>
        /// <param name="MaxDistance"></param>
        /// <param name="PosAfterHome"></param>
        /// <param name="SCCWLS">Soft CCW limitation sensor</param>
        /// <param name="SCWLS">Soft CW limitation sensor</param>
        public IrixiMotionController(string DeviceSN = "")
        {
            // Generate the instance of the state report object
            this.Report         = new DeviceStateReport();
            this.FirmwareInfo   = new FimwareInfo();
            this.PCA9534Info    = new PCA9534Info();
            this.TotalAxes      = -1;
            this.SerialNumber   = DeviceSN;
            this.AxisCollection = new ObservableCollection <Axis>();
            BindingOperations.EnableCollectionSynchronization(this.AxisCollection, _lock);

            _hid_device = new USBInterface(VID, PID, DeviceSN);
            _hid_device.EnableUsbBufferEvent(OnReportReceived);
            _hid_device.EnableUsbDisconnectEvent(OnDisconnected);
        }
        /// <summary>Se connecte au Lidar. La connexion est essayée tant qu'il y a un échec.</summary>
        public override void Start()
        {
            _stopAsked        = false;
            _connectionThread = new Thread(() =>
            {
                while (!IsConnected && !_stopAsked)
                {
                    // Class GUID : CC79D431 - E1F7 - 48c0 - B8F6 - EA3BF62A62BF
                    // Device GUID : 40F8D7C6 - 6856 - 483d - AC31 - DC646CA2D89B - TIM3xx
                    var devices = USBDevice.GetDevices("40F8D7C6-6856-483d-AC31-DC646CA2D89B");

                    foreach (var deviceInfo in devices)
                    {
                        // Recherche d'un TIM SickLidar précis utilisant son numéro de série
                        if (_serialNumber != 0 && deviceInfo.DevicePath.Contains(_serialNumber.ToString()))
                        {
                            try
                            {
                                USBDevice device = new USBDevice(deviceInfo);

                                _device = device;
                                _iface  = device.Interfaces[0];

                                SendMessage("sMN SetAccessMode 03 F4724744");
                                IsConnected = true;

                                _readThread = new Thread(Read)
                                {
                                    Name = $"ReadThread for Lidar {_serialNumber}"
                                };
                                _readThread.Start();
                            }
                            catch (USBException ex)
                            {
                                Trace.WriteLine(ex);
                            }
                        }
                    }

                    Thread.Sleep(1000);
                }
            })
            {
                Name = $"ConnectionThread for Lidar {_serialNumber}"
            };

            _connectionThread.Start();
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    VirtualKeys = false;
                }
                string VID = ConfigurationManager.AppSettings["VID"] ?? "vid_05f3";
                string PID = ConfigurationManager.AppSettings["PID"] ?? "pid_00ff";

                Left   = ConfigurationManager.AppSettings["Left"] ?? "L";
                Middle = ConfigurationManager.AppSettings["Middle"] ?? "M";
                Right  = ConfigurationManager.AppSettings["Right"] ?? "R";

                VKeyLeft   = ConfigurationManager.AppSettings["Left"] ?? "{LEFT}";
                VKeyMiddle = ConfigurationManager.AppSettings["Middle"] ?? " ";
                VKeyRight  = ConfigurationManager.AppSettings["Right"] ?? "{RIGHT}";


                usbI       = new USBInterface(VID, PID);
                savehandle = new EventHandler(HIDhandler);

                bool conn = usbI.Connect();

                if (conn)
                {
                    usbI.enableUsbBufferEvent(savehandle);
                    Thread.Sleep(5);
                    usbI.startRead();
                }

                Console.Read();
                if (conn)
                {
                    usbI.stopRead();
                    try
                    {
                        usbI.Disconnect();
                    }
                    catch { }
                }
            }
            finally
            {
                Environment.Exit(0); //Force close application
            }
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var usb = new USBInterface(@"vid_0a81", @"pid_ff01");

            usb.Connect();
            // sample to file a missile
            WriteData(usb, 8);
            Thread.Sleep(2000);
            WriteData(usb, 0);
            Thread.Sleep(2500);
            WriteData(usb, 8);
            Thread.Sleep(2500);
            WriteData(usb, 0);
            Thread.Sleep(2500);
            Console.ReadLine();
        }
Ejemplo n.º 16
0
        public void CreateUSBDevice(String DeviceINterfaceGuid)
        {
            AsyncCallback callBack = new AsyncCallback(ProcessWINUSBData);

            mWinUSBDevice = USBDevice.GetSingleDevice(DeviceINterfaceGuid);
            if (mWinUSBDevice != null)
            {
                mWinUSBInterface = mWinUSBDevice.Interfaces.Find(USBBaseClass.VendorSpecific);
            }
            if (mWinUSBInterface != null)
            {
                if (mWinUSBInterface != null)
                {
                    readResult = mWinUSBInterface.InPipe.BeginRead(readBuffer, 0, 512, callBack, this);
                }
            }
        }
Ejemplo n.º 17
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Press key (1 ... 8) to change color in Light Notifier");
            Console.WriteLine("Press key (E) to exit app");
            Console.WriteLine("Press other key to crash the app");

            _device = new USBInterface("vid_1294", "pid_1320");
            _device.Connect();
            var line = Console.ReadLine();

            while (line != null && line.ToUpper() != "E")
            {
                var b = Convert.ToByte(line);
                WriteDataEx(b);
                line = Console.ReadLine();
            }
            Console.ReadLine();
        }
Ejemplo n.º 18
0
 public TinyFan(string name, ISettings settings, USBInterface.HIDInterface.interfaceDetails deviceInfo)
     : base("TinyFan", new Identifier("TinyFan", deviceInfo.serialNumber), settings)
 {
     this.deviceInfo = deviceInfo;
     int fanCount = 4;
     fans = new Sensor[fanCount];
     controls = new Sensor[fanCount];
     byte[] tach = this.getTach();
     for (int i = 0; i < fanCount; i++)
     {
         int device = 33 + i;
         string n = "Fan" + (i + 1);
         fans[i] = new Sensor(n, device, SensorType.Fan, this, settings);
         //fans[i].Value = tach[i] * 60 / 2;
         ActivateSensor(fans[i]);
         controls[i] = new Sensor(n, device, SensorType.TinyFanControl, this, settings);
         Control c = new Control(controls[i], settings, 0, 100);
         c.ControlModeChanged += (cc) => //copy from SuperIOHardware.cs
         {
             Console.WriteLine("fan mode changed.");
         };
         c.SoftwareControlValueChanged += (cc) =>
         {
             this.setTach();
         };
         c.FanModeChanged += (cc) =>
         {
             this.setFanPinMode();
         };
         c.FanFollowChanged += (cc) =>
         {
             this.setTach(); //when close "fan follow", I have to invoke this since Update() will not invoke setTach at this case.
         };
         controls[i].Control = c;
         ActivateSensor(controls[i]);
         controls[i].Value = controls[i].Control.SoftwareValue;
     }
     //init device, since now device is passive and didn't save setting itself
     this.setFanPinMode();
     this.setTach();
 }
Ejemplo n.º 19
0
        public MainWindow()
        {
            InitializeComponent();
            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();

            mySender = aTypedMessagesFactory.CreateDuplexTypedMessageSender <MyResponse, MyRequest>();
            mySender.ResponseReceived += OnResponseReceived;

            // Create messaging based on TCP.
            IMessagingSystemFactory aMessagingSystemFactory = new TcpMessagingSystemFactory();
            IDuplexOutputChannel    anOutputChannel         = aMessagingSystemFactory.CreateDuplexOutputChannel("tcp://192.168.2.9:8060/");

            // Attach output channel and be able to send messages and receive response messages.
            mySender.AttachDuplexOutputChannel(anOutputChannel);
            MyRequest test = new MyRequest {
                side = "L", strength = 10
            };

            mySender.SendRequestMessage(test);
            MyRequest reset = new MyRequest {
                side = "L", strength = 0
            };

            mySender.SendRequestMessage(reset);
            try
            {
                USBInterface usb = new USBInterface("vid_044f", "pid_b108");
                usb.Connect();
                usb.enableUsbBufferEvent(new System.EventHandler(myEventCacher));
                usb.startRead();

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 20
0
        public void InitDevice(ushort vid, ushort pid)
        {
            this.vid = vid;
            this.pid = pid;

            USBDeviceInfo[] details = USBDevice.GetDevices(guid);
            if (details == null)
            {
                return;
            }

            try {
                deviceInfo = details.First(info => info.VID == vid && info.PID == pid);
                if (deviceInfo != null)
                {
                    device = new USBDevice(deviceInfo);
                    iface  = device.Interfaces.Find(USBBaseClass.HID);
                    enableNumLock();
                    StartMonitoring();
                }
            } catch (System.InvalidOperationException) {
                iface = null;
            }
        }
Ejemplo n.º 21
0
        /*状態*/



        /*機能*/


        /* -------------------- */


        protected override bool _Reset()
        {
            if (Status == StatusEnum.Close)
            {
                USBIF = USBinterfaceExtensions200C.CreateUSB();

                if (!USBIF.Open())
                {
                    throw new IOException("can't open device");                             //オープン・初期化動作
                }
                if (!USBIF.isUSB3())
                {
                    System.Windows.MessageBox.Show("connected USB 2.0");                    //USB3.0の確認
                }
                if (!USBIF.Reset())
                {
                    throw new IOException("can't reset device"); //USBのリセット動作
                }
                rw.data = USBIF.CISReg;                          //<-!!!意味がないというかただの配列サイズ初期化
                ResetGain();                                     //ここでいい?

                ResetIris();

                /****/

                //サイズの初期化

                USBIFSTATUS sTATUS;
                uint        ysize = 0u;
                uint        xsize = 0u;

                sTATUS = USBIF.ReadReg(10u, ref xsize, 0u);
                Width  = (int)(sTATUS != USBIFSTATUS.E_OK ? 2256u : xsize * 2u);
                sTATUS = USBIF.ReadReg(3u, ref ysize, 0u);
                Height = (int)(sTATUS != USBIFSTATUS.E_OK ? 1178u : ysize * 2u);

                Size        = Width * Height;
                RX_BUF_SIZE = btc_GetImageSize();

                img_io2uint = new uint[RX_BUF_SIZE];
            }
            else if (Status == StatusEnum.Run)
            {
                Stop();
                if (!USBIF.Open())
                {
                    return(false);
                }
            }
            else
            {
                //初期化動作
                if (!USBIF.Open())
                {
                    return(false);
                }
            }


            return(true);
        }
Ejemplo n.º 22
0
 public void deviceList()
 {
     USBHIDDRIVER.USBInterface usbI = new USBInterface("0");
     String[] list = usbI.getDeviceList();
     Assert.IsNotNull(list);
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Read the controllers' serial number and output as a string list
        /// </summary>
        /// <returns></returns>
        public static string[] GetDeviceList()
        {
            USBInterface hid = new USBInterface(PID, VID);

            return(hid.GetDeviceList());
        }
Ejemplo n.º 24
0
 public Rocket(string vendorID, string productID, MoveMode moveMode = MoveMode.Continuous)
 {
     _vendorId = vendorID;
     _moveMode = moveMode;
     _device   = new USBInterface(_vendorId, productID);
 }
Ejemplo n.º 25
0
        public BBDMercury16Input(USBDeviceInfo selectedDevice = null) : base(4000, 8)
        {
            string expectedDeviceID = $"USB\\VID_{DEVICE_VID}&PID_{DEVICE_PID}";

            // libusbK implementation
            //int deviceCount = 0;
            //KLST_DEVINFO_HANDLE deviceInfo;
            //LstK lst = new LstK(KLST_FLAG.NONE);

            //lst.Count(ref deviceCount);
            //while (lst.MoveNext(out deviceInfo))
            //{
            //    Console.WriteLine("libusbk: " + deviceInfo.DeviceInterfaceGUID.ToLower());
            //}

            //lst.Free();


            // DotNetLibUsb
            //var deviceList = LibUsbDotNet.LibUsb.LibUsbDevice.AllDevices.ToArray();
            //foreach (var deviceInfoLUDN in deviceList)
            //{
            //    Console.WriteLine("libusb: " + deviceInfoLUDN.DeviceInterfaceGuids[0].ToString().ToLower() + " - " + deviceInfoLUDN.Device.Info.ProductString);
            //}

            //if (this.deviceInfo == null)
            //{
            //    throw new System.IO.IOException("There is no BBD Mercury-16 connected on any of the USB ports.");
            //}

            //if (deviceInfo.Device.Open())
            //{
            //    reader = deviceInfo.Device.OpenEndpointReader(LibUsbDotNet.Main.ReadEndpointID.Ep01);
            //    writer = deviceInfo.Device.OpenEndpointWriter(LibUsbDotNet.Main.WriteEndpointID.Ep01);
            //}

            // WinUSB.NET
            if (selectedDevice == null)
            {
                // GUID is an example, specify your own unique GUID in the .inf file
                USBDeviceInfo[] connectedDevices = USBDevice.GetDevices(DEVICE_INTERFACE_GUID);

                if (connectedDevices.Length == 0)
                {
                    throw new System.IO.IOException("There is no BBD Mercury-16 connected on any of the USB ports.");
                }

                selectedDevice = connectedDevices[0];

                //USBNotifier notifier = new USBNotifier(null, DEVICE_INTERFACE_GUID);
            }

            // Find your device in the array
            usbDevice    = new USBDevice(selectedDevice);
            usbInterface = usbDevice.Interfaces.Find(USBBaseClass.PersonalHealthcare);

            var phdPacket = ReadIEEE11073Pakcet(usbInterface.InPipe);

            // stop streaming data
            usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x01, 0x00, 0x00 });

            CellSettings cellSettings = new CellSettings();

            while (cellSettings.SystemClock == 0)
            {
                // get the cell settings
                usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x03, 0x00, 0x00 });
                cellSettings = ReadPacket <CellSettings>(usbInterface.InPipe, 0xF004, 10);
            }

            // set the modified cell settings
            //cellSettings.SampleRate /= 4;
            //WritePacket<CellSettings>(usbInterface.OutPipe, 0xF009, cellSettings);

            // start streaming data
            usbInterface.OutPipe.Write(new byte[] { 0xF0, 0x02, 0x00, 0x00 });

            if ((cellSettings.ChannelCount != 8) && (cellSettings.ChannelCount != 16) && (cellSettings.ChannelCount != 24))
            {
                throw new Exception($"The number of channels reported by Mercury-16 ({cellSettings.ChannelCount}) is invalid!");
            }


            //this.SamplesPerSecond = cellSettings.SampleRate;
            for (int i = 0; i < cellSettings.ChannelCount; i++)
            {
                this.SetChannel(i, new SinglePrecisionDataChannel(this.SamplesPerSecond, this.SamplesPerSecond * 5));
            }

            this.BufferSize          = Math.Max(this.BufferSize, this.SamplesPerSecond * this.ChannelCount * 2 / targetFPS);
            this.GoertzelOutputs     = new List <float> [this.ChannelCount];
            this.GoertzelFrequency01 = cellSettings.GoertzelFrequency01;
            this.GoertzelFrequency02 = cellSettings.GoertzelFrequency02;
            this.GoertzelFrequency03 = cellSettings.GoertzelFrequency03;

            Task usbPollTask = Task.Run(() =>
            {
                while (PollUSBData(this))
                {
                }
            });
        }
Ejemplo n.º 26
0
 public void deviceList()
 {
     USBHIDDRIVER.USBInterface usbI = new USBInterface("0");
     String[] list = usbI.getDeviceList();
     Assert.IsNotNull(list);
 }
 public static void Find()
 {
     USBInterface = new USBInterface("vid_067b", "pid_2303");
     USBInterface.Connect();
 }