Beispiel #1
0
 public UsbIO()
 {
     KEY_USB = 32767;
     TECLAS  = 32767;
     IsOpen  = false;
     usbapi  = null;
 }
        static public bool StopSensorData(UsbHidPort usb)
        {
            byte[] x = new byte[2];
            x[0] = 0x01;
            x[1] = 0x01;
            usbHIDSend(usb, x, 0x02);  //выключаем передачу данных

            x    = new byte[2];
            x[0] = 0x01;
            x[1] = 0xD1;
            return(usbHIDSend(usb, x, 0x02));
        }
        static public bool StartSensorData(UsbHidPort usb)
        {
            byte[] x = new byte[2];
            x[0] = 0x01;
            x[1] = 0xD2;
            usbHIDSend(usb, x, 0x02);

            x    = new byte[2];
            x[0] = 0x01;
            x[1] = 0x71;
            return(usbHIDSend(usb, x, 0x02));
        }
Beispiel #4
0
        public MissileLauncher()
        {
            this.UP    = new byte[10];
            this.UP[1] = 2; //private bytes counter, to find memory leaks
            this.UP[2] = 2;

            this.DOWN    = new byte[10];
            this.DOWN[1] = 2;
            this.DOWN[2] = 1;

            this.LEFT    = new byte[10];
            this.LEFT[1] = 2;
            this.LEFT[2] = 4;

            this.RIGHT    = new byte[10];
            this.RIGHT[1] = 2;
            this.RIGHT[2] = 8;

            this.FIRE    = new byte[10];
            this.FIRE[1] = 2;
            this.FIRE[2] = 0x10;

            this.STOP    = new byte[10];
            this.STOP[1] = 2;
            this.STOP[2] = 0x20;

            this.LED_ON    = new byte[9];
            this.LED_ON[1] = 3;
            this.LED_ON[2] = 1;

            this.LED_OFF    = new byte[9];
            this.LED_OFF[1] = 3;

            this.USB                           = new UsbHidPort();
            this.USB.ProductId                 = 0;
            this.USB.SpecifiedDevice           = null;
            this.USB.VendorId                  = 0;
            this.USB.OnSpecifiedDeviceRemoved += new EventHandler(this.USB_OnSpecifiedDeviceRemoved);
            this.USB.OnDataRecieved           += new DataRecievedEventHandler(this.USB_OnDataRecieved);
            this.USB.OnSpecifiedDeviceArrived += new EventHandler(this.USB_OnSpecifiedDeviceArrived);


            this.USB.VID_List[0] = 0xa81;
            this.USB.PID_List[0] = 0x701;
            this.USB.VID_List[1] = 0x2123;
            this.USB.PID_List[1] = 0x1010;
            this.USB.ID_List_Cnt = 2;

            IntPtr handle = new IntPtr();

            this.USB.RegisterHandle(handle);
        }
 public UNITRotationSpeedMeasurementNetControl()
 {
     this.LinesGroup[0].Description = "Rotation Speed in RPM";
     this.LinesGroup[0].Stroke      = Brushes.Green;
     this.onReceiveDoubleData       = new OnReceiveDoubleDataDelegate(OnReceiveDoubleData);
     this.port = new UsbHidPort();
     this.port.OnDataRecieved           += Port_OnDataRecieved;
     this.port.OnDataSend               += Port_OnDataSend;
     this.port.OnDeviceArrived          += Port_OnDeviceArrived;
     this.port.OnDeviceRemoved          += Port_OnDeviceRemoved;
     this.port.OnSpecifiedDeviceArrived += Port_OnSpecifiedDeviceArrived;
     this.port.OnSpecifiedDeviceRemoved += Port_OnSpecifiedDeviceRemoved;
 }
Beispiel #6
0
        public GHWTDrumController(FrmMain main, int pid, int vid)
        {
            m_UsbDrum           = new UsbHidPort();
            m_UsbDrum.ProductId = pid;
            m_UsbDrum.VendorId  = vid;
            m_UsbDrum.OnSpecifiedDeviceArrived += UsbOnSpecifiedDeviceArrived;
            m_UsbDrum.OnSpecifiedDeviceRemoved += UsbOnSpecifiedDeviceRemoved;
            m_UsbDrum.OnDataRecieved           += UsbOnDataRecieved;

            m_HitFilter                  = new HitFilter(main, 6, m_GuiTranslater);
            m_CheckForDrumTimer          = new Timer();
            m_CheckForDrumTimer.Interval = 1000;
            m_CheckForDrumTimer.Tick    += CheckForDrumsTick;
            m_CheckForDrumTimer.Start();
        }
Beispiel #7
0
        void UpdateAvalibleDevices()
        {
            if (!IsConnected)
            {
                AvalibleDevices = UsbHidPort.GetDevicesList();

                if (AvalibleDevices != null)
                {
                    if (!AvalibleDevices.Contains(SelectedDevice))                     // бесполезно, но оставлю... догадались почему?
                    {
                        SelectedDevice = AvalibleDevices.First();
                    }
                }
            }
        }
Beispiel #8
0
        public ProDrumController(FrmMain main, int pid, int vid)
        {
            m_UsbDrum           = new UsbHidPort();
            m_UsbDrum.ProductId = pid;
            m_UsbDrum.VendorId  = vid;
            m_UsbDrum.OnSpecifiedDeviceArrived += new System.EventHandler(UsbOnSpecifiedDeviceArrived);
            m_UsbDrum.OnSpecifiedDeviceRemoved += new System.EventHandler(UsbOnSpecifiedDeviceRemoved);
            m_UsbDrum.OnDataRecieved           += new UsbLibrary.DataRecievedEventHandler(UsbOnDataRecieved);

            m_HitFilter                  = new HitFilter(main, NUM_PADS, m_GuiTranslater);
            m_CheckForDrumTimer          = new Timer();
            m_CheckForDrumTimer.Interval = 1000;
            m_CheckForDrumTimer.Tick    += CheckForDrumsTick;
            m_CheckForDrumTimer.Start();
        }
        static private bool usbHIDSend(UsbHidPort usb, byte[] send_data, byte report_id)
        {
            bool result = true;

            try
            {
                usb.SpecifiedDevice.set_report(send_data, report_id);
                System.Diagnostics.Debug.Print("{0}: Передача -> {1}", DateTime.Now.ToString(), string.Join(" ", send_data));
            }
            catch (Exception ex)
            {
                result = false;
                System.Diagnostics.Debug.Print("{0}: Ошибка -> {1}", DateTime.Now.ToString(), ex.Message);
            }
            return(result);
        }
        public WeabraryConnect()
        {
            #region Usb port implemenation

            usbPort = new UsbHidPort();
            usbPort.OnSpecifiedDeviceRemoved += new EventHandler(usbPort_OnSpecifiedDeviceRemoved);
            usbPort.OnDataRecieved           += new DataRecievedEventHandler(usbPort_OnDataRecieved);
            usbPort.OnDeviceArrived          += new EventHandler(usbPort_OnDeviceArrived);
            usbPort.OnSpecifiedDeviceArrived += new EventHandler(usbPort_OnSpecifiedDeviceArrived);
            usbPort.OnDeviceRemoved          += new EventHandler(usbPort_OnDeviceRemoved);
            usbPort.OnDataSend += new EventHandler(usbPort_OnDataSend);

            #endregion
            weabrary_DeviceArrived += OnDeviceArrived;
            weabrary_DeviceRemoved += OnDeviceRemoved;
        }
Beispiel #11
0
        public Form1()
        {
            InitializeComponent();

            #region Implémentation du port usb

            //Implémentation du composant usb
            usbPort = new UsbHidPort();

            //Implémentation des procédures événementielles de connexion-déconnexion
            usbPort.OnDeviceArrived          += new EventHandler(usbPort_OnDeviceArrived);
            usbPort.OnSpecifiedDeviceArrived += new EventHandler(usbPort_OnSpecifiedDeviceArrived);
            usbPort.OnDeviceRemoved          += new EventHandler(usbPort_OnDeviceRemoved);
            usbPort.OnSpecifiedDeviceRemoved += new EventHandler(usbPort_OnSpecifiedDeviceRemoved);

            //Implémentation des procédures événementielles de transmission
            usbPort.OnDataRecieved += new DataRecievedEventHandler(usbPort_OnDataRecieved);
            usbPort.OnDataSend     += new EventHandler(usbPort_OnDataSend);

            #endregion
        }
Beispiel #12
0
 public bool Open()
 {
     IsOpen = false;
     try
     {
         usbapi           = new UsbHidPort();
         usbapi.ProductId = 63;
         usbapi.VendorId  = 1240;
         usbapi.OnSpecifiedDeviceArrived += usb_OnSpecifiedDeviceArrived;
         usbapi.OnSpecifiedDeviceRemoved += usb_OnSpecifiedDeviceRemoved;
         usbapi.OnDeviceArrived          += usb_OnDeviceArrived;
         usbapi.OnDeviceRemoved          += usb_OnDeviceRemoved;
         usbapi.OnDataRecieved           += usb_OnDataRecieved;
         usbapi.OnDataSend += usb_OnDataSend;
         usbapi.CheckDevicePresent();
         Refresh();
         Thread.Sleep(500);
     }
     catch
     {
     }
     return(IsOpen);
 }