Пример #1
0
        private bool getTestType(out UsbTestType testType, byte interfaceID)
        {
            if (mUsbDevice.IsOpen)
            {
                if (PIC18TestDevice.GetTestType(mUsbDevice, out testType, interfaceID))
                {
                    return(true);
                }

                testType = 0;
                return(false);
            }

            throw new Exception("Device Not Opened");
        }
Пример #2
0
        private void cboTestType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!mUsbDevice.IsOpen)
            {
                return;
            }

            timerUpdateUI.Enabled = false;

            UsbTestType currentTestType = mUsbTestType;
            UsbTestType newTestType     = (UsbTestType)cboTestType.SelectedItem;

            if (newTestType == currentTestType)
            {
                return;
            }

            cboTestType.Enabled = false;

            stopReadWrite();

            if (PIC18TestDevice.SetTestType(mUsbDevice, newTestType, false, mInterfaceInfo.Descriptor.InterfaceID))
            {
                SetStatus("Test Selected:" + newTestType, false);
            }
            else
            {
                SetStatus("Test Select Failed", true);
            }

            ResetBenchmark();
            mUsbTestType = newTestType;

            if (newTestType == UsbTestType.WriteToDevice)
            {
                mthWriteThreadEP1      = new Thread(WriteThreadEP1_NoRecv);
                bWriteThreadEP1Enabled = true;
                mthWriteThreadEP1.Start();
            }
            else if (newTestType == UsbTestType.Loop)
            {
                mthWriteThreadEP1      = new Thread(WriteThreadEP1);
                bWriteThreadEP1Enabled = true;
                mthWriteThreadEP1.Start();
            }

            if (newTestType == UsbTestType.None)
            {
                ResetBenchmark();
                panTest.Enabled = false;
            }
            else
            {
                timerUpdateUI.Stop();
                timerUpdateUI.Interval = mBenchMarkParameters.RefreshDisplayInterval;
                timerUpdateUI.Enabled  = true;
                timerUpdateUI.Start();

                panTest.Enabled = true;
            }
            if (newTestType != UsbTestType.WriteToDevice)
            {
                mEP1Reader.DataReceivedEnabled = true;
            }

            cboTestType.Enabled = true;
        }