37 const std::string
eol(
"\r");
39 const std::regex
rgx_query(
"(.+)=(.+)\r");
40 const std::regex
rgx_cmd(
"(\\+|-)\r");
145 ROS_INFO(
"Commanding driver to enter download mode.");
153 cv.wait_for(lck, std::chrono::seconds(1));
197 if(params.compare(
"") == 0) {
198 msg2 = type + msg +
eol;
200 msg2 = type + msg +
" " + params +
eol;
202 unsigned int counter = 0;
210 cv.wait_for(lck, std::chrono::seconds(1));
230 if(params.compare(
"") == 0) {
231 msg2 = type + msg +
eol;
233 msg2 = type + msg +
" " + params +
eol;
236 unsigned int counter = 0;
244 cv.wait_for(lck, std::chrono::seconds(1));
273 if (std::regex_match(msg,
rgx_cmd))
283 else if(std::regex_match(msg,
rgx_query))
286 string sub_cmd = msg.substr(0, msg.find(
'='));
288 long end_string = (msg.size()-1) - (msg.find(
'=') + 1);
290 sub_data = msg.substr(msg.find(
'=') + 1, end_string);
294 if(
mMessage.compare(sub_cmd) == 0) {
311 else if(msg.compare(
"HLD\r") == 0)
bool script(bool status)
script Run and stop the script inside the Roboteq
size_t readline(std::string &buffer, size_t size=65536, std::string eol="\n")
bool addCallback(const callback_data_t &callback, const string data)
addCallback Add callback message
serial_controller(string port, unsigned long baudrate)
serial_controller Open the serial controller
bool downloadScript()
downloadScript Launch the script update for the Roboteq board
map< string, callback_data_t > hashmap
void setTimeout(Timeout &timeout)
void setBaudrate(uint32_t baudrate)
bool enableDownload()
enableDownload Enable writing script
const std::string eol("\r")
void async_reader()
async_reader Thread to read realtime all charachters sent from roboteq board
bool query(string msg, string params="", string type="?")
const size_t max_line_length(128)
const std::regex rgx_query("(.+)=(.+)\r")
function< void(string data) > callback_data_t
Read complete callback - Array of callback.
virtual const char * what() const
static Timeout simpleTimeout(uint32_t timeout)
#define ROS_DEBUG_STREAM(args)
bool command(string msg, string params="", string type="!")
void setPort(const std::string &port)
const std::regex rgx_cmd("(\\+|-)\r")
#define ROS_ERROR_STREAM(args)
std::condition_variable cv
size_t write(const uint8_t *data, size_t size)
bool start()
start Initialize the serial communcation