none
Sending Data (HID) RRS feed

  • Question

  • Hello everyone,

    I have a specific Generic HID device which developed with Cypress. I try to send 8 byte of datas to the device. When I try to send on Win7 64bit it successed, but on Win10 64bit. I use UsbLibrary.dll. Here is my code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using UsbLibrary;
    
    namespace EGI
    {
        public partial class EGIMain : Form
        {
            public EGIMain()
            {
                InitializeComponent();
            }
    
            private void EGIMain_Load(object sender, EventArgs e)
            {
                this.Pto_USB.ProductId = 0xe177;
                this.Pto_USB.VendorId = 0x04b4;
                this.Pto_USB.CheckDevicePresent();
            }
    
           //*******************************************************************************************************
            //                              HID Functions
            //*******************************************************************************************************
    
            private void usb_OnDeviceArrived(object sender, EventArgs e)
            {
                // this.lb_message.Items.Add("Found a Device");
                Information.Text = "Ekin Generic HID has been connected";
            }
    
            private void usb_OnDeviceRemoved(object sender, EventArgs e)
            {
                if (InvokeRequired)
                {
                    Invoke(new EventHandler(usb_OnDeviceRemoved), new object[] { sender, e });
                }
                else
                {
                    // this.lb_message.Items.Add("Device was removed");
                    Information.Text = "Ekin Generic HID has been removed";
                }
            }
    
            private void usb_OnSpecifiedDeviceArrived(object sender, EventArgs e)
            {
                Information.Text = "Ekin Generic HID has been connected";
            }
    
            private void usb_OnSpecifiedDeviceRemoved(object sender, EventArgs e)
            {
                if (InvokeRequired)
                {
                    Invoke(new EventHandler(usb_OnSpecifiedDeviceRemoved), new object[] { sender, e });
                }
                else
                {
                    Information.Text = "Ekin Generic HID has been removed";
                }
            }
    
            private void usb_OnDataSend(object sender, EventArgs e)
            {
                Information.Text = "Data has been send";
            }
    
            //*******************************************************************************************************
    
            private void sendData_Click(object sender, EventArgs e)   //Sends data to PIC
            {
                try
                {
                    byte[] Out_data = new byte[Pto_USB.SpecifiedDevice.OutputReportLength + 1];
                    Out_data[0] = Convert.ToByte(reportID.Text);
                    Out_data[1] = Convert.ToByte(sData_1.Text);
                    Out_data[2] = Convert.ToByte(sData_2.Text);
                    Out_data[3] = Convert.ToByte(sData_3.Text);
                    Out_data[4] = Convert.ToByte(sData_4.Text);
                    Out_data[5] = Convert.ToByte(sData_5.Text);
                    Out_data[6] = Convert.ToByte(sData_6.Text);
                    Out_data[7] = Convert.ToByte(sData_7.Text);
                    Out_data[8] = Convert.ToByte(sData_8.Text);
    
                    if (this.Pto_USB.SpecifiedDevice != null)
                        this.Pto_USB.SpecifiedDevice.SendData(Out_data);     //send 8 bit of datas
                    else
                        MessageBox.Show("Cannot find a specific devices to send data!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
    
            protected override void OnHandleCreated(EventArgs e)
            {
                base.OnHandleCreated(e);
                Pto_USB.RegisterHandle(Handle);
            }
    
            protected override void WndProc(ref Message m)
            {
                Pto_USB.ParseMessages(ref m);
                base.WndProc(ref m);	// pass message on to base form
            }
        }
    }

    Thanks for your helps.


    • Edited by Ali Dayan Monday, September 18, 2017 11:06 AM
    • Moved by CoolDadTx Monday, September 18, 2017 1:54 PM Third party product
    Monday, September 18, 2017 11:01 AM

All replies

  • These forums are for MS products only. Questions related to the usage and issues around third party libraries need to be posted in their forums.
    Monday, September 18, 2017 1:54 PM