// replaces setupread
        public bool ReadInputBuffer()
        {
            var ret = false;

            Hid.InputReportViaInterruptTransfer myInputReport = new Hid.InputReportViaInterruptTransfer();

            //i don't want this sub function to be able to disconnect the colorimeter
            var myColorimeterDetected = true;


            myInputReport.Read(hidHandle, readHandle, writeHandle, ref myColorimeterDetected, ref inputBuffer, ref ret);

            for (int count = 0; count < inputBuffer.Length; count++)
            {
                //  Copy input data to buffer
                inputBuffer[count] = inputBuffer[count];
            }

            return(ret);
        }
        ///  <summary>
        ///  Initiates exchanging reports.
        ///  The application sends a report and requests to read a report.
        ///  </summary>
        ///
        ///  <returns>True if read successful, false otherwise</returns>
        public Boolean SetupRead()
        {
            Boolean success = false;

            try
            {
                // Check read handle
                if (!readHandle.IsInvalid)
                {
                    if (MyHid.Capabilities.InputReportByteLength > 0)
                    {
                        Hid.InputReportViaInterruptTransfer myInputReport = new Hid.InputReportViaInterruptTransfer();

                        //i don't want this sub function to be able to disconnect the colorimeter
                        var myColorimeterDetected = true;


                        myInputReport.Read(hidHandle, readHandle, writeHandle, ref myColorimeterDetected, ref inputBuffer, ref success);
                        InputReportReceived(ref inputBuffer, success);
                    }
                    else
                    {
                        //response.responseInfo.Add("This HID device doesn't have an Input report.");
                    }
                }
                else
                {
                    //response.responseInfo.Add("Invalid read handle.");
                }

                return(success);
            }
            catch (Exception ex)
            {
                //response.responseInfo.Add($"Colorimeter.SetupRead() {ex}");
                throw;
            }
        }
        //This method is used for the cases where a single response packet will be enough to contain the results, and we will not have to iterate through a large amount of data
        private string GetSinglePacketResponse(OutCmd outCommand)
        {
            try
            {
                ////build command to send buffer
                byte[] outputBuffer = new byte[MyHid.Capabilities.OutputReportByteLength];
                outputBuffer[0] = 0;
                outputBuffer[1] = Convert.ToByte(outCommand);//the value of the query firmware state
                outputBuffer[2] = 0;


                //Write command to buffer
                Hid.OutputReportViaInterruptTransfer outputReport = new Hid.OutputReportViaInterruptTransfer();
                if (!outputReport.Write(outputBuffer, writeHandle))
                {
                    //Failure writing to the report
                    throw new Exception();
                }


                //Read from the input report
                bool deviceConnected = true;
                bool success         = false;

                Hid.InputReportViaInterruptTransfer myInputReport = new Hid.InputReportViaInterruptTransfer();
                myInputReport.Read(hidHandle, readHandle, writeHandle, ref deviceConnected, ref inputBuffer, ref success);

                if (!success)
                {
                    //failure reading from the report
                    throw new Exception();
                }


                InputReportReceived(ref inputBuffer, success);
                newInputData = true;


                if (outCommand.Equals(OutCmd.SendFwVers) || outCommand.Equals(OutCmd.SendTestFileVers))
                {
                    //Both of these types of queries return the same type of packet, an encoded string
                    return(Encoding.GetEncoding("iso-8859-1").GetString(inputBuffer, 3, inputBuffer[2]));
                }

                if (outCommand.Equals(OutCmd.QueryFirmwareState))
                {
                    switch ((InCmd)inputBuffer[1])
                    {
                    case InCmd.BootloaderRunning:
                        return("BootloaderRunning");

                    case InCmd.MainFwRunning:
                        return("MainFwRunning");

                    default:
                        return("Unknown");
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(null);
        }