コード例 #1
0
        static void Main(string[] args)
        {
            // Get a list of devices that match vid and pid
            // This list should NEVER have more than one element.
            Console.WriteLine("USB HID Test");
            String[] list = usb.getDeviceList();
            Console.WriteLine("Devices with vid = 0x046d and pid = 0xc245: " + list.Length);

            // usb.Connect() returns false if the device is not physically connected.
            while (!usb.Connect())
            {
                Thread.Sleep(1000);
                Console.WriteLine("Not Connected");
            }


            Console.WriteLine("Connected!");


            // This only attaches "myEventCatcher" to the UsbBufferEvent.
            Console.WriteLine("Enabling Buffer Event...");
            usb.enableUsbBufferEvent(new System.EventHandler(myEventCatcher));


            // After calling usb.startRead(), "myEventCacher" will be called whenever the device sends data to the PC.
            Console.WriteLine("Press a key to begin data dump.");
            Console.ReadKey();
            usb.startRead();


            // Device is configured and reading, you can keep on doing your important shit.
            while (true)
            {
                if (!usb.Connect())
                {
                    Console.WriteLine("Device Disconnected");
                }

                Thread.Sleep(1000);
            }
        }
コード例 #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
        public static string[] GetDevices()
        {
            var usb = new USBHIDDRIVER.USBInterface(G13UsbVendorID, G13UsbProductID);

            return(usb.getDeviceList());
        }
コード例 #4
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();
        }