Beispiel #1
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);
        }
Beispiel #2
0
        public bool ReceiveData(byte[] data)
        {
            bool retVal = base.BeginAsyncRead(data);

#if SHOW_USB_DATA
            Console.WriteLine("ReceiveData " + SpecifiedDevice.ByteArrayToString(data));
#endif
            return(retVal);
        }
        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);
        }