Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. SerialPortListener::SerialPortListener(const QString & portName) {
  2.     port = new AbstractSerial();
  3.  
  4.     if(port) {
  5.         port->setDeviceName(portName);
  6.  
  7.         if(port->open(AbstractSerial::ReadOnly)) {
  8.             port->setBaudRate(AbstractSerial::BaudRate9600);
  9.             port->setFlowControl(AbstractSerial::FlowControlOff);
  10.             port->setDataBits(AbstractSerial::DataBits8);
  11.             port->setParity(AbstractSerial::ParityNone);
  12.             port->setStopBits(AbstractSerial::StopBits1);
  13.  
  14.             connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
  15.  
  16.             qDebug() << "Device name            : " << port->deviceName();
  17.             qDebug() << "Baud rate              : " << port->baudRate();
  18.             qDebug() << "Data bits              : " << port->dataBits();
  19.             qDebug() << "Parity                 : " << port->parity();
  20.             qDebug() << "Stop bits              : " << port->stopBits();
  21.             qDebug() << "Flow                   : " << port->flowControl();
  22.         }
  23.     }
  24.     else
  25.         qDebug() << "Device failed to open";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement