public bool TrySendCommand <T>(IStageCommand command, out T response)
        {
            lock (this) {
                response = default(T);                 //TODO can other method just use this, defaulting to object?
                if (!serial.IsOpen || isHoming)
                {
                    return(false);                                            //TODO makes checkes likes global axis
                }
                if (!sendCommand(command))
                {
                    return(false);
                }
                if (command.ExpectResponse)
                {
                    string responseData = null;
                    if (readLine(out responseData))
                    {
                        object obj = command.ParseResponse(responseData);
                        if ((obj != null) && (obj is T))
                        {
                            response = (T)obj;
                            return(true);
                        }
                    }
                }
                else
                {
                    return(true);
                }

                return(false);
            }
        }
 /// <summary>Internal method that simply sends a command, no checks.</summary>
 private bool sendCommand(IStageCommand command)           //TODO implement in other methods
 {
     try {
         serial.WriteLine(command.Command);
         return(true);
     } catch (Exception ex) {
         Console.WriteLine("Error sending message: " + ex.Message);
         return(false);
     }
 }
 /// <summary>Attempts to send a command and parse its return data, if any.</summary>
 public bool TrySendCommand(IStageCommand command, out object response)
 {
     return(TrySendCommand <object>(command, out response));
 }
        /// <summary>Attempts to send a command and ignore any returned data.</summary>
        public bool TrySendCommand(IStageCommand command)
        {
            object temp;

            return(TrySendCommand(command, out temp));
        }