2

Background

At the moment, I have TelosB motes that using to collect sensor data, and then transmit it over its USB serial port at 115200 baud.

In the past, I used Python to develop the program that will interface with the mote, but Python's GIL has its share of threading problems which can only be solved by not using Python (I needed its concurrency after the initial testing phase), so I shifted to C++/Qt. I spent a lot of time with Qt, as I didn't have prior knowledge, learnt most its best practices and got everything working perfectly. Everything except this problem.

The Problem

When I try to read the port, if there is a lot of data coming through, some sets of data will mysteriously error out, leading to a higher than desirable loss rate in my project.

This happens when I use qextserialport but it does not happen with pySerial.

This is how I initialize the port with qextserialport:

port.setName("COM3");
port.setQueryMode(QextSerialPort::EventDriven);
port.setBaudRate(BAUD115200);
port.setParity(PAR_NONE);
port.setDataBits(DATA_8);
port.setStopBits(STOP_1);
port.setFlowControl(FLOW_OFF);

and pySerial:

port = Serial('COM3', 115200)

Question

So I suspect that there is something different in the way the two libraries are initialising the port, but I have no experience in serial programming and could be wrong.

Does anybody have any idea what might be causing this error?

Alex Koay
  • 2,915
  • 4
  • 18
  • 16
  • It's most likely because the input buffer for the serial port is filling up faster than you're reading it. You probably need to either read/check it faster or more frequently or figure out a way to increase the buffer size. But I don't know how to do that, which is why this is a comment and not an answer :-P – Wes Hardaker Mar 15 '12 at 04:13

1 Answers1

2

It turns out that I've been erroneously using QextSerialPort::bytesAvailable() instead of QextSerialPort::atEnd(). I saw this over in another question, and it helped me get rid of the error messages that basically blocked my application while waiting for the timeout, and

Wes' comment led to solving my other problem, which was that the mote didn't have enough memory allocated to storing all the data, which led to lost data.

Alex Koay
  • 2,915
  • 4
  • 18
  • 16