Example #1
0
        /// <summary>
        /// Timeout if read via interrupt transfer doesn't return.
        /// </summary>

        private void OnReadTimeout()
        {
            CloseCommunications();
            _transferInProgress = false;
            _sendOrGet          = SendOrGet.Send;
        }
Example #2
0
 /// <summary>
 /// Timeout if write via interrupt transfer doesn't return.
 /// </summary>
 private void OnWriteTimeout()
 {
     CloseCommunications();
     _transferInProgress = false;
     _sendOrGet          = SendOrGet.Get;
 }
Example #3
0
		/// <summary>
		/// Alternate sending and getting a report.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>

		private void cmdPeriodicTransfers_Click(object sender, EventArgs e)
		{
			try
			{
				if (cmdPeriodicTransfers.Text == "Start")
				{
					if (_transferInProgress)
					{
						DisplayTransferInProgressMessage();
					}
					else
					{
						_sendOrGet = SendOrGet.Send;
						PeriodicTransfersStart();
					}
				}
				else
				{
					PeriodicTransfersStop();
				}
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
Example #4
0
		/// <summary>
		/// Request to send an Output report or get an Input report.
		/// </summary>

		private void SendOutputReportOrGetInputReport()
		{
			try
			{
				//  If the device hasn't been detected, was removed, or timed out on a previous attempt
				//  to access it, look for the device.

				if (!_deviceHandleObtained)
				{
					_deviceHandleObtained = FindTheHid();
				}

				if (_deviceHandleObtained)
				{
					if (_sendOrGet == SendOrGet.Send)
					{
						RequestToSendOutputReport();
						_sendOrGet = SendOrGet.Get;
					}
					else
					{
						RequestToGetInputReport();
						_sendOrGet = SendOrGet.Send;
					}
				}
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
Example #5
0
		/// <summary>
		/// Request to send or get a Feature report.
		/// </summary>

		private void SendOrGetFeatureReport()
		{
			try
			{
				//  If the device hasn't been detected, was removed, or timed out on a previous attempt
				//  to access it, look for the device.

				if (!_deviceHandleObtained)
				{
					_deviceHandleObtained = FindTheHid();
				}

				if (_deviceHandleObtained)
				{
					switch (_sendOrGet)
					{
						case SendOrGet.Send:
							RequestToSendFeatureReport();
							_sendOrGet = SendOrGet.Get;
							break;
						case SendOrGet.Get:
							RequestToGetFeatureReport();
							_sendOrGet = SendOrGet.Send;
							break;
					}
				}
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
Example #6
0
		/// <summary>
		/// Timeout if write via interrupt transfer doesn't return.
		/// </summary>

		private void OnWriteTimeout()
		{
			try
			{
				MyMarshalDataToForm(FormActions.AddItemToListBox, "The attempt to write a report timed out.");
				MyMarshalDataToForm(FormActions.ScrollToBottomOfListBox, "");
				CloseCommunications();
				MyMarshalDataToForm(FormActions.EnableSendOutputReportInterrupt, "");
				_transferInProgress = false;
				_sendOrGet = SendOrGet.Get;
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}