diff --git a/serial_port_class_api/include/CLASS_SerialPort.h b/serial_port_class_api/include/CLASS_SerialPort.h index 360e9a5fd34188fd6977064ef01e34857f3f8a6a..1445aeafeb15ecbdd365d9a076fe94842d669366 100644 --- a/serial_port_class_api/include/CLASS_SerialPort.h +++ b/serial_port_class_api/include/CLASS_SerialPort.h @@ -189,6 +189,8 @@ public: std::string ping(); std::string getHelp(); + + std::string sendCustomCommand(std::string &command); }; #endif \ No newline at end of file diff --git a/serial_port_class_api/src/CLASS_SerialPort.cpp b/serial_port_class_api/src/CLASS_SerialPort.cpp index 4eba738ce5167637c7d14acc10baa5bb42a60b17..471f8248688857aae2a6763ecd432d1cf7980609 100644 --- a/serial_port_class_api/src/CLASS_SerialPort.cpp +++ b/serial_port_class_api/src/CLASS_SerialPort.cpp @@ -168,9 +168,9 @@ std::string CLASS_SerialPort::communication(const char *buffer, std::string auxC std::string result; - std::string buf("[" + auxControl + "] "); - buf.append(buffer); - buffer = buf.c_str(); + //std::string buf("[" + auxControl + "] "); + //buf.append(buffer); + //buffer = buf.c_str(); bool ret = write(buffer); if(!ret) @@ -1526,4 +1526,16 @@ std::string CLASS_SerialPort::getHelp() std::string msg = commands::ClassCommands::CMD_HELP; std::string result = communication(msg.c_str()); return result; +} + +/** + * @brief sends custom command to class + * + * @param command custom command string to send to class device + * @return std::string answer + */ +std::string CLASS_SerialPort::sendCustomCommand(std::string &command) +{ + std::string result = communication(command.c_str()); + return result; } \ No newline at end of file diff --git a/serial_port_class_api/src/main.cpp b/serial_port_class_api/src/main.cpp index ad1f26bf4a349973d3668479f1dbcbac5c67bbc8..317788559a3976a3ccca6c63cba33aa76f402997 100644 --- a/serial_port_class_api/src/main.cpp +++ b/serial_port_class_api/src/main.cpp @@ -20,19 +20,23 @@ using namespace std; int main(void) { std::string port; - port = "COM3"; // name of port assigned to class bluetooth device + port = "COM4"; // name of port assigned to class bluetooth device CLASS_SerialPort serial; bool port_status = serial.SetOpenPort(port); cout << "Port Status :"; cout << port_status <<endl; - + if(port_status == 1) { //start communication command depending on device --> startFESCommunication() ; startTACTILITYCommunication() ; startCommunication(std::string &prototipeName) std::string start_communication = serial.startFESCommunication(); cout << "start_communication : " + start_communication << endl; + std::string customcommand = "ping\r\n"; + std::string custom = serial.sendCustomCommand(customcommand); + cout << "custom : " << custom << endl; + std::string setStimulationOn = serial.setStimulationOn(); cout << "setStimulationOn : " << setStimulationOn << endl; @@ -301,13 +305,16 @@ int main(void) //std::string setRTCTime = serial.setRTCTime(time); //cout << "setRTCTime : " << setRTCTime << endl; - std::string ping = serial.ping(); cout << "ping : " + ping << endl; std::string help = serial.getHelp(); cout << "Help : " + help << endl; + std::string customcommand = "ping\r\n"; + std::string custom = serial.sendCustomCommand(customcommand); + cout << "custom : " << custom << endl; + std::string shutDown = serial.shutDown(); cout << "shutDown : " << shutDown << endl;