11 : syntax(syntax), dispatcher(dispatcher)
13 data = std::queue<std::string>();
47 boost::remove_if(message, boost::is_any_of(
syntax->endOfFrame +
50 if (message.size() > 1)
56 catch (std::exception& e)
59 error(
"An error occured while reading from the serial connection\n " 61 std::string(e.what()));
70 std::string out(
data.front());
76 return std::string(
"");
void workerFunction()
Worker function, responsible for polling the serial input buffer.
void registerErrorCallback(errorCallbackPtr error)
Register an error function pointer to handle errors during communication.
static SerialInterface & instance()
Returns a singleton auf this class.
Header file for the ReadingThread class.
The ThreadDispatcher class coordinates other communication threads and handles start up and shut down...
ThreadDispatcher * dispatcher
boost::function< void(const std::string &)> errorCallbackPtr
std::shared_ptr< Syntax > syntax
ReadingThread(std::shared_ptr< Syntax > syntax, ThreadDispatcher *dispatcher)
ReadingThread constructor.
void startThread()
Start the polling of the serial input buffer..
void stopThread()
Stop the polling of the serial input buffer..
std::queue< std::string > data
void wakeUp()
Unlocks the current worker thread.
const bool isQueueEmpty() const
Is a new line availible?
std::string getData()
Get retrieved data vom the serial input buffer.
The SerialInterface class provides an interface to a connected serial device.
void read(std::string &message, std::string &delimiter)
read a message from the serial input buffer