コード例 #1
0
ファイル: G13Engine.cs プロジェクト: flyingoverclouds/G13.Net
        /// <summary>
        /// Connect to the first G13 device available and start listening HID event.
        /// If connexion succeeded, the property DevicePath is valued
        /// </summary>
        /// <returns>true if connection succeeded, false in case of failure</returns>
        public bool Connect()
        {
            usbInterface = new USBHIDDRIVER.USBInterface(G13UsbVendorID, G13UsbProductID);
            if (usbInterface == null)
            {
                Console.WriteLine($"ERROR: Unable to instantiate USb interface for {G13UsbVendorID} {G13UsbProductID} ");
                return(false);
            }

            if (!usbInterface.Connect())
            {
                Console.WriteLine("ERROR: Unable to connect to G13 Device!!");
                usbInterface = null;
                return(false);
            }

            usbInterface.EnableUsbBufferEvent(UsbHidEventHandler); // Register event handler to receive HID event
            usbInterface.StartRead();
            return(true);
        }
コード例 #2
0
        private void btnRocheGetData_Click(object sender, EventArgs e)
        {
            usb = new USBHIDDRIVER.USBInterface("vid_173a", "pid_2106");

            string [] devices = usb.getDeviceList();
            usb.enableUsbBufferEvent(new EventHandler(Accuchek_ReceivedData));
            System.Threading.Thread.Sleep(100);
            Console.WriteLine("Connect: " + usb.Connect().ToString());

            //string temp = Convert.ToString(Convert.ToChar(01));
            //temp += Convert.ToString(Convert.ToChar(44));
            //temp += Convert.ToString(Convert.ToChar(01));

            //commandindex = 1;
            //commands.Clear();

            //commands.Add(temp);
            //commands.Add("\n");
            //commands.Add("C4\n");
            //commands.Add("C 3\n");
            //commands.Add("S 1\n");
            //commands.Add("S 2\n");
            //commands.Add("`\n");
            //commands.Add("S 3\n");

            //Send_AccuChek_Command(commandindex++);

            commands.Add(new byte[] { 0x01, 0x13 });
            commands.Add(new byte[] { 0x01, 0x44, 0x01 });
            commands.Add(new byte[] { 0x01, 0x44, 0x01 });
            commands.Add(new byte[] { 0x01, 0x43, 0x01, 0x02 });
            commands.Add(new byte[] { 0x01, 0x45 });
            commands.Add(new byte[] { 0x01, 0x43, 0x04, 0x01 });
            commands.Add(new byte[] { 0x01, 0x44 });
            Send_AccuChek_Command(commands[commandindex++]);

            usb.startRead();
        }
コード例 #3
0
ファイル: G13Engine.cs プロジェクト: flyingoverclouds/G13.Net
 /// <summary>
 /// Stop Usb HIV event handling, and close usb channel the device.
 /// </summary>
 public void Disconnect()
 {
     usbInterface.StopRead();
     usbInterface.Disconnect();
     usbInterface = null;
 }
コード例 #4
0
ファイル: G13Engine.cs プロジェクト: flyingoverclouds/G13.Net
        public static string[] GetDevices()
        {
            var usb = new USBHIDDRIVER.USBInterface(G13UsbVendorID, G13UsbProductID);

            return(usb.getDeviceList());
        }
コード例 #5
0
        private void btnRocheGetData_Click(object sender, EventArgs e)
        {
            usb = new USBHIDDRIVER.USBInterface("vid_173a", "pid_2106");
            
            string [] devices = usb.getDeviceList();
            usb.enableUsbBufferEvent(new EventHandler(Accuchek_ReceivedData));
            System.Threading.Thread.Sleep(100);
            Console.WriteLine("Connect: " + usb.Connect().ToString());

            //string temp = Convert.ToString(Convert.ToChar(01));
            //temp += Convert.ToString(Convert.ToChar(44));
            //temp += Convert.ToString(Convert.ToChar(01));

            //commandindex = 1;
            //commands.Clear();

            //commands.Add(temp);
            //commands.Add("\n");
            //commands.Add("C4\n");
            //commands.Add("C 3\n");
            //commands.Add("S 1\n");
            //commands.Add("S 2\n");
            //commands.Add("`\n");
            //commands.Add("S 3\n");
            
            //Send_AccuChek_Command(commandindex++);

            commands.Add(new byte[] { 0x01, 0x13 });
            commands.Add(new byte[] { 0x01 ,0x44, 0x01});
            commands.Add(new byte[] { 0x01, 0x44, 0x01 });
            commands.Add(new byte[] { 0x01, 0x43, 0x01, 0x02 });
            commands.Add(new byte[] { 0x01, 0x45 });
            commands.Add(new byte[] { 0x01, 0x43, 0x04, 0x01 });
            commands.Add(new byte[] { 0x01, 0x44 });
            Send_AccuChek_Command(commands[commandindex++]);

            usb.startRead();
        }