Skip to content

Commit

Permalink
Added an ability to disable reading of a command from the response.
Browse files Browse the repository at this point in the history
  • Loading branch information
branoholy committed Mar 22, 2016
1 parent ca64a64 commit 7f13e58
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project("regilo")
# Set project version
set(PROJECT_VERSION_MAJOR "2")
set(PROJECT_VERSION_MINOR "3")
set(PROJECT_VERSION_PATCH "")
set(PROJECT_VERSION_PATCH "1")
set(PROJECT_VERSION_TWEAK "")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

Expand Down
16 changes: 10 additions & 6 deletions include/regilo/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ class StreamController : public virtual IController
public:
typedef StreamT Stream;

std::string REQUEST_END = "\n";
std::string RESPONSE_END = "\n";
std::string REQUEST_END = "\n"; ///< A string that the request ends with.
std::string RESPONSE_END = "\n"; ///< A string that the response ends with.

bool readResponse = true;
bool readResponse = true; ///< If true the sendCommand method reads a response.
bool readCommand = true; ///< If true the input command is read from the response at first.

/**
* @brief Default constructor.
Expand Down Expand Up @@ -243,9 +244,12 @@ std::string StreamController<StreamT>::sendCommand()
{
ba::read_until(stream, istreamBuffer, RESPONSE_END);

std::string cmdInput;
getLine(istream, cmdInput, REQUEST_END);
cmdInput = cmdInput.substr(0, cmdInput.length() - REQUEST_END.length());
if(readCommand)
{
std::string cmdInput;
getLine(istream, cmdInput, REQUEST_END);
cmdInput = cmdInput.substr(0, cmdInput.length() - REQUEST_END.length());
}

getLine(istream, output, RESPONSE_END);
deviceOutput.clear();
Expand Down
2 changes: 1 addition & 1 deletion include/regilo/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Log : public virtual ILog
virtual void writeMetadata(std::ostream& metaStream);

public:
char MESSAGE_END = '$';
char MESSAGE_END = '$'; ///< A char that the log message ends with.

/**
* @brief Log constructor with logging to a file.
Expand Down
22 changes: 10 additions & 12 deletions include/regilo/neatocontroller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,20 @@ class NeatoController : public INeatoController, public ScanController<ProtocolC
bool ldsRotation = false;

protected:
// void init();

virtual inline std::string getScanCommand() const override { return CMD_GET_LDS_SCAN; }
virtual bool parseScanData(std::istream& in, ScanData& data) override;

public:
static std::string ON;
static std::string OFF;
static std::string LDS_SCAN_HEADER;
static std::string LDS_SCAN_FOOTER;

static std::string CMD_TEST_MODE;
static std::string CMD_SET_LDS_ROTATION;
static std::string CMD_SET_MOTOR;
static std::string CMD_GET_TIME;
static std::string CMD_GET_LDS_SCAN;
static std::string ON; ///< A string that represents the ON value.
static std::string OFF; ///< A string that represents the OFF value.
static std::string LDS_SCAN_HEADER; ///< A header of the LDS scan output.
static std::string LDS_SCAN_FOOTER; ///< A footer of the LDS scan output.

static std::string CMD_TEST_MODE; ///< A template for the `testmode` command.
static std::string CMD_SET_LDS_ROTATION; ///< A template for the `setldsrotation` command.
static std::string CMD_SET_MOTOR; ///< A template for the `setmotor` command.
static std::string CMD_GET_TIME; ///< A template for the `gettime` command.
static std::string CMD_GET_LDS_SCAN; ///< A template for the `getldsscan` command.

/**
* @brief Default constructor.
Expand Down

0 comments on commit 7f13e58

Please sign in to comment.