/// <summary>
        /// Sends the specified code to the device as a command
        /// </summary>
        private IguanaCode SendCommand(IguanaCode command, byte[] data)
        {
            uint dataLen = 0;
            var dataPtr = IntPtr.Zero;

            if (data.Length > 0)
            {
                dataLen = (uint)data.Length;
                dataPtr = Marshal.AllocHGlobal((int)dataLen);
                Marshal.Copy(data, 0, dataPtr, (int)dataLen);
            }

            var request = CreateRequest((byte)command, dataLen, dataPtr);

            if (request == IntPtr.Zero)
                throw new ApplicationException("Error creating command request!");

            if (!WriteRequest(request, _handle))
                throw new ApplicationException("Couldn't write request to IguanaIR!");

            // Need to "remove data" from the request before freeing, not quite sure why...
            var nullLength = 0u;
            RemoveData(request, ref nullLength);
            FreePacket(request);

            if (data.Length > 0)
            {
                Marshal.FreeHGlobal(dataPtr);
            }

            return ReceiveResponse(10000);
        }
 /// <summary>
 /// Sends the specified code to the device as a command
 /// </summary>
 private IguanaCode SendCommand(IguanaCode command)
 {
     return SendCommand(command, new byte[0]);
 }