Working TCP subsystem

This commit is contained in:
IMback
2017-11-02 20:17:05 +01:00
parent 88ef0be4a2
commit 08dc57d385
19 changed files with 1679 additions and 76 deletions

View File

@ -1,6 +1,36 @@
#include "serialwatcher.h"
SerialWatcher::SerialWatcher()
void SerialWatcher::run()
{
abort();
loop.reset(new QEventLoop);
QTimer timer;
connect(&timer, SIGNAL(timeout()), this, SLOT(doTick()));
timer.setInterval(500);
timer.start();
loop->exec();
}
void SerialWatcher::abort()
{
if (!loop.isNull()){
loop->quit();
}
}
void SerialWatcher::doTick()
{
char charBuf;
while(sRead(_serial, &charBuf, 1) == 1)
{
_buffer.push_back(charBuf);
if( _buffer.endsWith('\n') )
{
textRecived(_buffer);
_buffer.clear();
}
}
}