qt - write and read data to terminal from serial port without connecting any hardware devices to serialport -


actually have qt code. need send data of packets serial port terminal , display data in terminal , terminal need read data , display in qt window page. main problem is, serial communication terminal, require serial port should connect hardware devices , also.. can write , read data terminal without connecting serial port hardware devices.

the code transceiver layer serial port

transceiver::transceiver(qobject *parent) :    qobject(parent),    mserial(new qserialport(this)) {     mserial->setportname(qstring("com1"));     qint32 baudrate = 9600;     mserial->setbaudrate(baudrate);     mserial->setdatabits(qserialport::data8);     mserial->setparity(qserialport::noparity);     mserial->setstopbits(qserialport::onestop);      connect     (         mserial,         &qserialport::readyread,         [ ]()         {             qbytearray data = mserial->readall();             ondatareceived( data );             qdebug()<<data;         }     ); }   transceiver::~transceiver() {    mserial->close(); }  void transceiver::send_data(const qbytearray & indatastream ) {    qdebug()<<"data_in_transceiver_layer :"<<indatastream;    mserial->write(indatastream); }  bool transceiver::openconnection() {     mserial->open(qiodevice::readwrite);     qserialport::serialporterror error = m`enter code here`serial->error();     return error == qserialport::noerror;     //     connect(mserial, signal(readyread()), this, slot(read_data())); } 

when run shows qiodevice::write (qserialport): device not open


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -