コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
 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());
         }
     }
 }
コード例 #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));
            }
        }
コード例 #5
0
        //set the request to send the report buffer over the control pipe.
        public void set_report(byte[] data, byte buffersize)
        {
            SpecifiedOutputReport oRep = new SpecifiedOutputReport(this);

            oRep.set_report(data, buffersize);
            try
            {
                sendReport(oRep);
            }
            catch (HIDDeviceException ex)
            {
            }
        }
コード例 #6
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);
        }
コード例 #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 (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #8
0
ファイル: SpecifiedDevice.cs プロジェクト: Ehsan70/beaverbot
 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());
     }
 }
コード例 #9
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());
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: SpecifiedDevice.cs プロジェクト: sjanulonoks/mc3000
        // 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());
                }
            }
        }