rv.PJLinkConnection.sendCommand C# (CSharp) Method

sendCommand() public method

public sendCommand ( Command cmd ) : Command.Response
cmd Command
return Command.Response
        public Command.Response sendCommand(Command cmd)
        {
            if(initConnection())
            {
                try
                {
                    string cmdString = cmd.getCommandString() + "\r";

                    if (_useAuth && _pjKey != "")
                        cmdString = getMD5Hash(_pjKey + _passwd) + cmdString;

                    byte[] sendBytes = Encoding.ASCII.GetBytes(cmdString);
                    _stream.Write(sendBytes, 0, sendBytes.Length);

                    byte[] recvBytes = new byte[_client.ReceiveBufferSize];
                    int bytesRcvd = _stream.Read(recvBytes, 0, (int)_client.ReceiveBufferSize);
                    string returndata = Encoding.ASCII.GetString(recvBytes, 0, bytesRcvd);
                    returndata = returndata.Trim();
                    cmd.processAnswerString(returndata);
                    return cmd.CmdResponse;
                }
                finally
                {
                    closeConnection();
                }
            }

            return Command.Response.COMMUNICATION_ERROR;
        }

Usage Example

        private async void btnInfo_Click(object sender, RoutedEventArgs e)
        {
            //try
            {
                string info           = "";
                rv.PJLinkConnection c = connectBeamer();
                info = await c.getProjectorInfo();

                LampStatusCommand lscmd = new LampStatusCommand();
                if (await c.sendCommand(lscmd) == Command.Response.SUCCESS)
                {
                    info += "\n";
                    info += lscmd.dumpToString();
                }

                var view = ApplicationView.GetForCurrentView();
                view.TryResizeView(new Size(328, 250));
                InfoDialog dialog = new InfoDialog(info);
                await dialog.ShowAsync();

                view.TryResizeView(new Size(328, 100));
            }
            //catch (Exception)
            {
            }
        }
All Usage Examples Of rv.PJLinkConnection::sendCommand