Beispiel #1
0
        public static bool SetTestType(UsbDevice usbTestDevice, UsbTestType usbTestType, bool bCheck, byte interfaceID)
        {
            if (ReferenceEquals(usbTestDevice, null))
            {
                throw new UsbTestDeviceException("UsbTestDevice must be set before invoking this member!");
            }

            if (bCheck)
            {
                UsbTestType bCurrentTestType;
                if (GetTestType(usbTestDevice, out bCurrentTestType, interfaceID))
                {
                    if (bCurrentTestType == usbTestType)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            int lengthTransferred;

            byte[] buf = new byte[1];

            UsbSetupPacket cmd = UsbCmdSetTestType;

            cmd.Value = (short)usbTestType;
            cmd.Index = interfaceID;

            bool bSuccess = usbTestDevice.ControlTransfer(ref cmd, buf, buf.Length, out lengthTransferred);

            return(bSuccess && lengthTransferred == 1);
        }
Beispiel #2
0
        public static bool GetTestType(UsbDevice usbTestDevice, out UsbTestType usbTestType, byte interfaceID)
        {
            if (ReferenceEquals(usbTestDevice, null))
            {
                throw new UsbTestDeviceException("UsbTestDevice must be set before invoking this member!");
            }

            int lengthTransferred;

            byte[] buf = new byte[1];

            UsbSetupPacket cmd = UsbCmdGetTestType;

            cmd.Index = interfaceID;

            bool bSuccess = usbTestDevice.ControlTransfer(ref cmd, buf, buf.Length, out lengthTransferred);

            if (bSuccess && lengthTransferred == 1)
            {
                usbTestType = (UsbTestType)buf[0];
                return(true);
            }
            usbTestType = UsbTestType.Invalid;
            return(false);
        }
Beispiel #3
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");
        }
        public static bool GetTestType(UsbDevice usbTestDevice, out UsbTestType usbTestType, byte interfaceID)
        {
            if (ReferenceEquals(usbTestDevice, null))
                throw new UsbTestDeviceException("UsbTestDevice must be set before invoking this member!");

            int lengthTransferred;
            byte[] buf = new byte[1];

            UsbSetupPacket cmd = UsbCmdGetTestType;
            cmd.Index = interfaceID;

            bool bSuccess = usbTestDevice.ControlTransfer(ref cmd, buf, buf.Length, out lengthTransferred);

            if (bSuccess && lengthTransferred == 1)
            {
                usbTestType = (UsbTestType) buf[0];
                return true;
            }
            usbTestType = UsbTestType.Invalid;
            return false;
        }
        public static bool SetTestType(UsbDevice usbTestDevice, UsbTestType usbTestType, bool bCheck, byte interfaceID)
        {
            if (ReferenceEquals(usbTestDevice, null))
                throw new UsbTestDeviceException("UsbTestDevice must be set before invoking this member!");

            if (bCheck)
            {
                UsbTestType bCurrentTestType;
                if (GetTestType(usbTestDevice, out bCurrentTestType, interfaceID))
                {
                    if (bCurrentTestType == usbTestType) return true;
                }
                else
                    return false;
            }
            int lengthTransferred;
            byte[] buf = new byte[1];

            UsbSetupPacket cmd = UsbCmdSetTestType;
            cmd.Value = (short) usbTestType;
            cmd.Index = interfaceID;

            bool bSuccess = usbTestDevice.ControlTransfer(ref cmd, buf, buf.Length, out lengthTransferred);

            return bSuccess && lengthTransferred == 1;
        }
 public static bool SetTestType(UsbDevice usbDevice, UsbTestType usbTestType, bool check)
 {
     UsbTestDevice = usbDevice;
     return SetTestType(usbTestType, check);
 }
 public static bool SetTestType(UsbTestType usbTestType)
 {
     return SetTestType(usbTestType, true);
 }
 public static bool SetTestType(UsbDevice usbDevice, UsbTestType usbTestType)
 {
     UsbTestDevice = usbDevice;
     return SetTestType(usbTestType);
 }
 public static bool GetTestType(UsbDevice usbDevice, out UsbTestType usbTestType)
 {
     UsbTestDevice = usbDevice;
     return GetTestType(out usbTestType);
 }
Beispiel #10
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;
        }
Beispiel #11
0
 public static bool GetTestType(UsbDevice usbDevice, out UsbTestType usbTestType)
 {
     UsbTestDevice = usbDevice;
     return(GetTestType(out usbTestType));
 }
Beispiel #12
0
 public static bool SetTestType(UsbDevice usbDevice, UsbTestType usbTestType, bool check)
 {
     UsbTestDevice = usbDevice;
     return(SetTestType(usbTestType, check));
 }
Beispiel #13
0
 public static bool SetTestType(UsbTestType usbTestType)
 {
     return(SetTestType(usbTestType, true));
 }
Beispiel #14
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");
        }
Beispiel #15
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;
        }