Commit 587238c2 authored by James Goppert's avatar James Goppert

Fixed serial lag issues.

parent cbcb6dc5
......@@ -100,7 +100,8 @@ namespace qmapcontrol
// Silently ignore map request for a
// 0xn pixel map
qDebug() << "QMapControl: IGNORED 0x0 pixel map request, widthxheight:" << pm.width() << "x" << pm.height();
qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
// showing this html error message is horribly time consuming
//qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
}
else
{
......@@ -108,7 +109,8 @@ namespace qmapcontrol
// TODO Error is currently undetected
//qDebug() << "NETWORK_PIXMAP_ERROR: " << ax;
qDebug() << "QMapControl external library: ERROR loading map:" << "width:" << pm.width() << "heigh:" << pm.height() << "at " << __FILE__ << __LINE__;
qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
// showing this html error message is horribly time consuming
//qDebug() << "QMapControl: HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
}
}
......
......@@ -118,7 +118,7 @@ public:
virtual bool isOpen() = 0;
virtual bool isWritable() = 0;
virtual bool bytesAvailable() = 0;
virtual qint64 bytesAvailable() = 0;
virtual int write(const char * data, qint64 size) = 0;
virtual void read(char * data, qint64 numBytes) = 0;
virtual void flush() = 0;
......@@ -141,17 +141,20 @@ signals:
void aboutToClose();
public:
SerialQextserial(QString porthandle, QextSerialPort::QueryMode mode) : _port(NULL) {
std::cout << "DEBUG: " << porthandle.toStdString() << std::endl;
_port = new QextSerialPort(porthandle, QextSerialPort::Polling);
QObject::connect(_port,SIGNAL(aboutToClose()),this,SIGNAL(aboutToClose()));
}
~SerialQextserial() {
delete _port;
_port = NULL;
}
virtual bool isOpen() {
return _port->isOpen();
}
virtual bool isWritable() {
return _port->isWritable();
}
virtual bool bytesAvailable() {
virtual qint64 bytesAvailable() {
return _port->bytesAvailable();
}
virtual int write(const char * data, qint64 size) {
......@@ -203,12 +206,17 @@ public:
SerialQserial(QString porthandle, QIODevice::OpenModeFlag flag=QIODevice::ReadWrite)
: _port(NULL) {
QObject::connect(_port,SIGNAL(aboutToClose()),this,SIGNAL(aboutToClose()));
settings.setBaudRate(QPortSettings::BAUDR_38400);
settings.setStopBits(QPortSettings::STOP_2);
settings.setBaudRate(QPortSettings::BAUDR_57600);
settings.setStopBits(QPortSettings::STOP_1);
settings.setDataBits(QPortSettings::DB_8);
settings.setFlowControl(QPortSettings::FLOW_OFF);
settings.setParity(QPortSettings::PAR_NONE);
_port = new QSerialPort(porthandle,settings);
_port->setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead);
}
~SerialQserial() {
delete _port;
_port = NULL;
}
virtual bool isOpen() {
return _port->isOpen();
......@@ -216,7 +224,7 @@ public:
virtual bool isWritable() {
_port->isWritable();
}
virtual bool bytesAvailable() {
virtual qint64 bytesAvailable() {
return _port->bytesAvailable();
}
virtual int write(const char * data, qint64 size) {
......@@ -234,11 +242,11 @@ public:
}
virtual void open(QIODevice::OpenModeFlag flag) {
_port->open(flag);
std::cout << "opened port" << std::endl;
//flush();
}
virtual void setBaudRate(SerialInterface::baudRateType baudrate) {
// TODO get the baudrate enum to map to one another
settings.setBaudRate(QPortSettings::BAUDR_38400);
settings.setBaudRate(QPortSettings::BAUDR_57600);
}
virtual void setParity(SerialInterface::parityType parity) {
settings.setParity(QPortSettings::PAR_NONE);
......
......@@ -191,6 +191,7 @@ void SerialLink::readBytes()
const qint64 maxLength = 2048;
char data[maxLength];
qint64 numBytes = port->bytesAvailable();
//qDebug() << "numBytes: " << numBytes;
if(numBytes > 0) {
/* Read as much data in buffer as possible without overflow */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment