Definitive serial library
Hello,
I apologize if my English is not so good.
I use QT4 to develop applications for Windows and Linux, in both desktop and embedded environments.
I need use a lot of serial connections (often I have 4-5 serial devices connected) so I'm looking for a *reliable* and complete serial library. I don't understand why QT4 doesn't support serial communication natively, I think they are used a lot in embedded applications.
Anyway, I'm playing with the Qextserial but it seems to me a bit buggy and it has many limitations.
Please, may you suggest me a complete serial library that:
* works under Windows and Linux,
* uses signals to tell when data is ready to be read (with buffer thresholds)
* has a working lineread() method
* enumerates available ports under both Windows and Linux
I'm asking too much? What do you embedded programmers use?
Thanks
Marco Trapanese
Italy
Re: Definitive serial library
See this topic:
http://www.qtcentre.org/forum/f-qt-p...lue-21168.html
Try the library.
Add to the library all that you want.
:)
PS: but there is a bug.
Example download: http://www.qtcentre.org/forum/attach...6&d=1242923390
Re: Definitive serial library
Marco Trapanese asks for signal when there is data available. In your code there isn't this features.
See this topic: http://www.qtcentre.org/forum/f-qt-p...ing-21063.html
In the last post there is my class that use QextSerialPort. It implements 2 thread with the signal "dataReceived": it transports the byte available at the serial port. I also made a basic HyperTerminal to test it (It shows ad transmits data in Hexadecimal).
* has a working lineread() method
I don't implement this method: you can add this!
* enumerates available ports under both Windows and Linux
I don't know how to implement this features. In Linux I think I can scan for ttyS* file in /dev/ and maybe also ttyUSB*. I windows I don't know.
Bye
Re: Definitive serial library
I add this method to query available ports name, on both Windows and GNU\Linux
Code:
#ifdef _TTY_POSIX_
#include <QDir>
#endif
const int MAX_COM_PORT = 20;
// Query available SerialPort name
{
QextSerialPort testPort;
testPort.setBaudRate(BAUD115200);
testPort.setFlowControl(FLOW_OFF);
testPort.setParity(PAR_NONE);
testPort.setDataBits(DATA_8);
testPort.setStopBits(STOP_1);
#ifdef _TTY_WIN_
for (i=1; i<MAX_COM_PORT; i++)
{
testPortName
= QString("COM%1").
arg(i
) testPort.setPortName(testPortName);
{
portsName.append(testPortName);
testPort.close();
}
}
#else // _TTY_POSIX_
filters << "ttyS*" << "ttyUSB*";
dir.setNameFilters(filters);
dir.
setFilter(QDir::Files |
QDir::System);
QFileInfoList list = dir.entryInfoList();
for (int i=0; i< list.size(); i++)
{
portsName.append(list.at(i).canonicalFilePath ());
}
#endif
return portsName;
}
Re: Definitive serial library
Thank you very much PaceyIV, I'll play with you class!
It's a pity that QT4 doesn't have a built-in serial class, I can't understand why.
In this way, everybody should reinvent the wheel... And there are many people (like me) who aren't so skilled to implement the library themselves.
Marco
Re: Definitive serial library
Re: Definitive serial library
I use the code at http://www.teuniz.net/RS-232/
It does not use signals but it does work with Linux and windows.