Working TCP subsystem
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user