bool CmdMessenger::send(const Cmd &command, bool ack, int ack_id, int simple_timeout)
{
    std::stringstream ss; //stream to hold the command to be sent.

    if(!command.getNumArgs())
        ss << command.getId() << cmd_separator_; // if there are no arguments to be sent, the stream receives only the command id and the command separator.
    else
    {
        //otherwise, if there are some arguments, we will have to iterate over the std::vector args_
        ss << command.getId() << field_separator_;

        for(unsigned long i=0; i<command.args_.size() - 1; i++) { //Note that we go from i = 0, to i = args_.size() - 1, because after the last argument a cmd_separator must be added.
            ss << command.args_[i] << field_separator_; //adds an argument and the field separator to the stream.
        }

        ss << command.args_.back() << cmd_separator_; //finishes the command. Now it is ready to be sent.

    } // else

    std::cout << "Comando: " << ss.str() << std::endl;

    serial_port_.write(ss.str()); //sends the command!

    if(ack) { // if ack is required
        return CmdMessenger::waitCmd(ack_id, simple_timeout); //Verifies if the command arrived or not and returns true if received (false otherwise).
    }

    return true; //if ack is not required, the function returns true anyway.
}