Quantcast
Channel: Programmer's Town - Unix
Viewing all articles
Browse latest Browse all 227

//programmer2640.rssing.com/chan-67947766/article42-live.html

$
0
0

All greetings! At me reception and date transmission is carried out by means of QSerialDevice. I transfer the data everyone 10. A problem of such plan I transfer 1 sending - on reception it appeared nothing, when the second sending went on transmission - on reception it appeared sending from previous and new to sending here an example:
Proverka:: writeDataTime "a50155de0000002f"
Proverka:: writeDataTime "a50155e000000011"
Read message "a5035955de01a4d1a5035955e0019ad1"
How to adjust port so that it was not (. to separate)?
Here the code qserialdevice

#include "QUART.h"
QUART* QUART:: instance (QWidget* _parent) {
static QUART* __ self = 0;
if (__ self == 0) __ self = new QUART (_parent);
return __ self;
}
void QUART:: setSettings (QUartSettings pSettings) {
if (pSettings == portSettings) return;
portSettings = pSettings;
}
QUART:: QUART (QWidget* _parent) {
serial = new QSerialPort (this);
//connect (serial, SIGNAL (readyRead(), this, SLOT (readFromPort ()));
connect (serial, SIGNAL (error (QSerialPort:: SerialPortError));
this, SLOT (handleError (QSerialPort:: SerialPortError)));
}
QUART:: ~QUART () {
emit finished ();
delete serial;
}
void QUART:: disconnectPort () {
if (serial-> isOpen ()) serial-> close ();
}
void QUART:: openPort () {
serial-> setPortName (portSettings.name);
serial-> setBaudRate (portSettings.baudrate);
serial-> setDataBits (portSettings.dataBits);
serial-> setParity (portSettings.parityCtrl);
serial-> setStopBits (portSettings.stopBits);
serial-> setFlowControl (portSettings.flowCtrl);
if (serial-> open (QIODevice:: ReadWrite)) {
emit openSuccessfully (true);
emit statusMessage (tr ("Connected to %1: %2, %3, %4, %5, %6")
.arg (portSettings.name)
.arg (portSettings.baudrate)
.arg (portSettings.dataBits)
.arg (portSettings.parityCtrl)
.arg (portSettings.stopBits)
.arg (portSettings.flowCtrl));
} else {
emit openSuccessfully (false);
}
}
void QUART:: writeToPort (QByteArray dataArray) {
if (serial-> isOpen ()) {
serial-> write (dataArray);
}
else emit statusMessage ("Write UART error. Port closed");
}
void QUART:: readFromPort () {
if (serial-> isOpen ()) {
emit readedData (serial-> readAll ());
}
//while (serial-> bytesAvailable ())
//{
//emit readedData (serial-> readAll ());
//}
//qDebug () <<"Port Read" <<serial;
}
void QUART:: handleError (QSerialPort:: SerialPortError errorStr) {
emit statusMessage (portSettings.name + "error:" + QString ().number (errorStr));
}

Signal ReadyRead removed so sending on reception generally disappeared


Viewing all articles
Browse latest Browse all 227

Latest Images

Trending Articles



Latest Images