port = new QextSerialPort(namePort); port->setBaudRate(baud); port->setDataBits(data_bits); port->setFlowControl(flow); port->open(QIODevice::ReadWrite); connect(port,SIGNAL(readyRead()),this,SLOT(Receive())); connect(ui->pushButtonSend,SIGNAL(clicked()),this,SLOT(Transmit()));
port->write(usbdata.data(),usbdata.size());
port->close(); port->deleteLater();
port->deleteLater();
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); connection = false; }
void Widget::connect_port(){ if(!connection) { port = new QextSerialPort(namePort); port->setBaudRate(baud); port->setDataBits(data_bits); port->setFlowControl(flow); port->open(QIODevice::ReadWrite); connect(port,SIGNAL(readyRead()),this,SLOT(Receive())); connect(ui->pushButtonSend,SIGNAL(clicked()),this,SLOT(Transmit())); connection = true; } else { }}
void Widget::disconnect_port(){ if(connection) { port->close(); delete port; connection = false; } else { qDebug()<<"connection is not set"; }
connect(ui->pushButtonSend,SIGNAL(clicked()),this,SLOT(Transmit()));