예제 #1
0
 public void startRead()
 {
     sendStartCMD();
     usbI.enableUsbBufferEvent(new System.EventHandler(myEventCacher));
     Thread.Sleep(5);
     usbI.startRead();
     Thread.Sleep(5);
     for (int i = 0; i < 200; i++)
     {
         Assert.IsNotNull(USBHIDDRIVER.USBInterface.usbBuffer);
         Thread.Sleep(2);
     }
     usbI.stopRead();
     sendStopCMD();
 }
예제 #2
0
 public bool StartCommunication()
 {
     if (Connected)
     {
         if (FirstTime)
         {
             FirstTime = false;
             // only hook up one event handler
             usb.enableUsbBufferEvent(
                 new System.EventHandler(OnDataAvailable));
         }
         usb.startRead();
         return(true);
     }
     return(false);
 }
예제 #3
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);
            }
        }
예제 #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();
        }
예제 #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();
        }