Exemplo n.º 1
0
        public bool SendData(byte[] data, int index, int length)
        {
            SpecifiedOutputReport specifiedOutputReport = new SpecifiedOutputReport(this);

            specifiedOutputReport.SendData(data, index, length);
            try
            {
                base.Write(specifiedOutputReport);
                if (this.DataSend != null)
                {
                    this.DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (GException0 gException)
            {
                Console.WriteLine(gException.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool SendData(byte[] data)
        {
#if SHOW_USB_DATA
            Console.WriteLine("SendData " + SpecifiedDevice.ByteArrayToString(data));
#endif
            SpecifiedOutputReport specifiedOutputReport = new SpecifiedOutputReport(this);
            specifiedOutputReport.SendData(data);
            try
            {
                base.Write(specifiedOutputReport);
                if (this.DataSend != null)
                {
                    this.DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (GException0 gException)
            {
                Console.WriteLine(gException.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
 public void SendData(byte[] data)
 {
     int count = data.Length;
     int index = 0;
     while (count > 0)
     {
         byte[] mdata = new byte[2];
         int byteToWrite = Math.Min(count, 2);
         Array.Copy(data, index, mdata, 0, byteToWrite);
         index += byteToWrite;
         count -= byteToWrite;
         SpecifiedOutputReport oRep = new SpecifiedOutputReport(this);	// create output report
         oRep.SendData(mdata);	// set the lights states
         try
         {
             Write(oRep); // write the output report
             if (DataSend != null)
             {
                 DataSend(this, new DataSendEventArgs(data));
             }
         }
         catch (HIDDeviceException ex)
         {
             // Device may have been removed!
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }
Exemplo n.º 4
0
        public void SendData(byte[] data)
        {
            SpecifiedOutputReport oRep = new SpecifiedOutputReport(this); // create output report

            oRep.SendData(data);                                          // set the lights states

            Write(oRep);                                                  // write the output report
            if (DataSend != null)
            {
                DataSend(this, new DataSendEventArgs(data));
            }
        }
Exemplo n.º 5
0
        //int offset = 0;

        public bool SendData(byte[] data, int index, int length)
        {
#if false
            //Console.WriteLine("SendData " + SpecifiedDevice.ByteArrayToString(data));

            if (data[0] == 0x43 && data[1] == 0x57 && data[2] == 0x42)
            {
                offset = data[5] * 65536 + data[6] * 256 + data[7];
                //Console.WriteLine("Offset " + offset);
            }

            else
            {
                switch (data[0])
                {
                case 0x52:
                    //Console.WriteLine((data[1] * 256 + data[2] + offset) + "\t" + data[3]);
                    break;

                case 0x57:
                    //Console.WriteLine(string.Format("0x{0:X8}\t", (data[1] * 256 + data[2] + offset), data[3]));
                    Console.WriteLine((data[1] * 256 + data[2] + offset));                             //+ "\t" + data[3]);
                    break;
                }
            }
#endif
            SpecifiedOutputReport specifiedOutputReport = new SpecifiedOutputReport(this);
            specifiedOutputReport.SendData(data, index, length);
            try
            {
                base.Write(specifiedOutputReport);
                if (this.DataSend != null)
                {
                    this.DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (GException0 gException)
            {
                Console.WriteLine(gException.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        public void SendData(byte[] data)
        {
            SpecifiedOutputReport oRep = new SpecifiedOutputReport(this); // create output report

            oRep.SendData(data);                                          // set the lights states
            try
            {
                Write(oRep); // write the output report
                if (DataSend != null)
                {
                    DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 7
0
 public void SendData(byte[] data)
 {
     SpecifiedOutputReport oRep = new SpecifiedOutputReport(this);	// create output report
     oRep.SendData(data);	// set the lights states
     try
     {
         Write(oRep); // write the output report
         if (DataSend != null)
         {
             DataSend(this, new DataSendEventArgs(data));
         }
     }catch (HIDDeviceException ex)
     {
         // Device may have been removed!
     }catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 8
0
        public void SendData(byte[] data)
        {
            SpecifiedOutputReport oOutRep = new SpecifiedOutputReport(this);

            oOutRep.SendData(data);
            try
            {
                base.Write(oOutRep);
                if (this.DataSend != null)
                {
                    this.DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (HIDDeviceException)
            {
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }
        }
        public bool SendData(byte[] data)
        {
#if false
            switch (data[0])
            {
            case 0x52:
                Console.WriteLine(data[1] * 256 + data[2]);
                break;

            case 0x57:
                Console.WriteLine(data[1] * 256 + data[2]);
                break;
            }

            Console.WriteLine("SendData " + SpecifiedDevice.ByteArrayToString(data));
#endif
            SpecifiedOutputReport specifiedOutputReport = new SpecifiedOutputReport(this);
            specifiedOutputReport.SendData(data);
            try
            {
                base.Write(specifiedOutputReport);
                if (this.DataSend != null)
                {
                    this.DataSend(this, new DataSendEventArgs(data));
                }
            }
            catch (GException0 gException)
            {
                Console.WriteLine(gException.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 10
0
        // Token: 0x06000106 RID: 262 RVA: 0x00014D34 File Offset: 0x00012F34
        public void SendData(byte[] data)
        {
            SpecifiedOutputReport specifiedOutputReport = new SpecifiedOutputReport(this);

            if (specifiedOutputReport.SendData(data))
            {
                try
                {
                    base.Write(specifiedOutputReport);
                    if (this.DataSend != null)
                    {
                        this.DataSend(this, new DataSendEventArgs(data));
                    }
                }
                catch (HIDDeviceException ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                catch (Exception ex2)
                {
                    Console.WriteLine(ex2.ToString());
                }
            }
        }