Exemplo n.º 1
0
 /// <summary>
 /// Callback for above. Care with this as it will be called on the background thread from the async read
 /// </summary>
 /// <param name="iResult">Async result parameter</param>
 protected void ReadCompleted(IAsyncResult iResult)
 {
     byte[] arrBuff = (byte[])iResult.AsyncState;        // retrieve the read buffer
     try
     {
         m_oFile.EndRead(iResult);       // call end read : this throws any exceptions that happened during the read
         try
         {
             InputReport oInRep = CreateInputReport(); // Create the input report for the device
             oInRep.SetData(arrBuff);                  // and set the data portion - this processes the data received into a more easily understood format depending upon the report type
             HandleDataReceived(oInRep);               // pass the new input report on to the higher level handler
         }
         finally
         {
             BeginAsyncRead();   // when all that is done, kick off another read for the next report
         }
     }
     catch (IOException ex)      // if we got an IO exception, the device was removed
     {
         HandleDeviceRemoved();
         if (OnDeviceRemoved != null)
         {
             OnDeviceRemoved(this, new EventArgs());
         }
         Dispose();
         throw (ex);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// virtual handler for any action to be taken when data is received. Override to use.
 /// </summary>
 /// <param name="oInRep">The input report that was received</param>
 protected virtual void HandleDataReceived(InputReport oInRep)
 {   // Fire the event handler if assigned
     if (DataReceived != null)
     {
         DataReceived(this, new DataReceivedEventArgs(oInRep));
     }
 }
Exemplo n.º 3
0
 protected void ReadCompleted(IAsyncResult iResult)
 {
     byte[] asyncState = (byte[])iResult.AsyncState;
     try
     {
         this.m_oFile.EndRead(iResult);
         try
         {
             InputReport oInRep = this.CreateInputReport();
             oInRep.SetData(asyncState);
             this.HandleDataReceived(oInRep);
         }
         finally
         {
             this.BeginAsyncRead();
         }
     }
     catch (IOException)
     {
         this.HandleDeviceRemoved();
         if (this.OnDeviceRemoved != null)
         {
             this.OnDeviceRemoved(this, new EventArgs());
         }
         this.Dispose();
     }
 }
Exemplo n.º 4
0
 protected void ReadCompleted(IAsyncResult iResult)
 {
     byte[] data = (byte[])iResult.AsyncState;
     try
     {
         this.m_oFile.EndRead(iResult);
         try
         {
             InputReport inputReport = this.CreateInputReport();
             inputReport.SetData(data);
             this.HandleDataReceived(inputReport);
         }
         finally
         {
             this.BeginAsyncRead();
         }
     }
     catch (IOException ex)
     {
         Console.WriteLine(ex.Message);
         this.HandleDeviceRemoved();
         if (this.OnDeviceRemoved != null)
         {
             this.OnDeviceRemoved(this, new EventArgs());
         }
         this.Dispose();
     }
 }
Exemplo n.º 5
0
 protected override void HandleDataReceived(InputReport oInRep)
 {
     if (this.DataRecieved != null)
     {
         SpecifiedInputReport report = (SpecifiedInputReport)oInRep;
         this.DataRecieved(this, new DataRecievedEventArgs(report.Data));
     }
 }
Exemplo n.º 6
0
 protected override void HandleDataReceived(InputReport oInRep)
 {
     // Fire the event handler if assigned
     if (DataRecieved != null)
     {
         SpecifiedInputReport report = (SpecifiedInputReport)oInRep;
         DataRecieved(this, new DataRecievedEventArgs(report.Data));
     }
 }
Exemplo n.º 7
0
 protected override void HandleDataReceived(InputReport oInRep)
 {
     // Fire the event handler if assigned
     if (DataRecieved != null)
     {
         SpecifiedInputReport report = (SpecifiedInputReport)oInRep;
         DataRecieved(this, new DataRecievedEventArgs(report.Data));
     }
 }
Exemplo n.º 8
0
 protected override void HandleDataReceived(InputReport oInRep)
 {
     // Fire the event handler if assigned
     if (DataRecieved != null)
     {
         try
         {
             SpecifiedInputReport report = (SpecifiedInputReport)oInRep;
             string datastring           = Utils.ToHexString(report.Data).Substring(2, 80);
             if (CheckonResult(datastring))
             {
                 DataRecieved(this, new DataRecievedEventArgs(Utils.HexToByte(datastring)));
             }
         }
         catch { }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// virtual handler for any action to be taken when data is received. Override to use.
 /// </summary>
 /// <param name="oInRep">The input report that was received</param>
 protected virtual void HandleDataReceived(InputReport oInRep)
 {
 }
Exemplo n.º 10
0
		protected virtual void HandleDataReceived(InputReport oInRep)
		{
		}
Exemplo n.º 11
0
 public DataReceivedEventArgs(InputReport data)
 {
     this.data = data;
 }
Exemplo n.º 12
0
 public DataReceivedEventArgs(InputReport data)
 {
     this.data = data;
 }
Exemplo n.º 13
0
 /// <summary>
 /// virtual handler for any action to be taken when data is received. Override to use.
 /// </summary>
 /// <param name="oInRep">The input report that was received</param>
 protected virtual void HandleDataReceived(InputReport oInRep)
 {
     // Fire the event handler if assigned
     if (DataReceived != null)
     {
         DataReceived(this, new DataReceivedEventArgs(oInRep));
     }
 }