C++, Qt, EIA/TIA-232: qextserialport vs. QtSerialPort

Gast #2946644
Lesenswert?

Es gab ja kürzlich einen Thread, in dem auch Bibliotheken für Qt zum 
Zugriff auf die serielle Schnittstelle Thema waren - es wurde dann 
qextserialport genutzt:
http://code.google.com/p/qextserialport/ (MIT license)

Alternativ gibt es aber offenbar das Bestreben, eine andere Bibliothek 
als "offizielle" Qt-Bibliothek zu integrieren:
http://qt-project.org/wiki/QtSerialPort ()

Letztere habe ich mit Qt 4.8.x Desktop leider noch nicht zum Laufen 
gebracht, das Wiki scheint mir nicht besonders aktuell oder komplett 
(Doku?), und mir ist nicht ersichtlich, ob das der "bessere Weg" ist und 
diese Bibliothek überhaupt integriert wird. Das wäre m.E. aber ein 
Vorteil.

Die Frage ist, was nehme ich?

--
Stichworte: EIA/TIA-232, RS-232, COM port, UART, serial
Gast #2947078
Lesenswert?

Also das Erzeugen klappt schonmal, das Projekt in buildlib/ führt zur 
Bibliothek in lib/ und einer Kopie der DLLs im 
Qt-Installationsverzeichnis.

Hier ein wichtiger Thread:
Beitrag "Daten mittels QextSerialPort senden"

Die Links auf Qt Klassen der Doku 
docs.qextserialport.googlecode.com/git/1.2/qextserialport.html sind 
veraltet, das liegt jetzt alles unter http://qt-project.org/doc/

Das Code-Beispiel ist nicht zu gebrauchen, es fehlen Parameter.

Aber, auch unter Beachtung der TIpps aus o.g. Thread:
Ich kann nichts empfangen, und das Schreiben mit write() führt dazu, 
dass nachfolgende QDebug() Ausgaben mit auf der seriellen landen..

Komisch :-(
Gast #2964742
Lesenswert?

QtSerialPort hat bei mir Probleme mit waitForReadyRead() und 
bytesAvailable(), und irgendwie habe ich manchmal nicht das richtige 
Byte gelesen - da habe ich QextSerialPort nochmal runtergeladen: sobald 
man sich aus den Qt Quellen ein Header-File organisert (seit 1 Jahr 
nicht gefixt) lässt es sich erstellen. Im Polling-Mode ohne Timeout mit 
Warteschleife tut sich jetzt was soll. Es gibt eine Doku online. Symbole 
sind ohne Namespace. Teils haben Funktionen keinen Rückgabewert 
(Fehlerbehandlung?).
Aber auch hier rauscht waitForReadyRead() sofort durch.. also evtl. gar 
nicht implementiert:
1
bool QIODevice::waitForReadyRead ( int msecs ) [virtual]
2
Blocks until new data is available for reading and the readyRead() signal has been emitted, or until msecs milliseconds have passed. If msecs is -1, this function will not time out.
3

4
Returns true if new data is available for reading; otherwise returns false (if the operation timed out or if an error occurred).
5

6
This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.
7

8
If called from within a slot connected to the readyRead() signal, readyRead() will not be reemitted.
9

10
Reimplement this function to provide a blocking API for a custom device. The default implementation does nothing, and returns false.

Falls ich QSerialPort nochmal mit eigener Warteschleife testen sollte, 
melde ich mich.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren