PDA

View Full Version : [solved] QSerialDevice: How to set baudrate?



schlingel
14th October 2009, 11:24
Hi,

I use Qt 4.5 with Windows XP. I want to talk to devices with the serial port and tried out qextserialport but it does seem to have a great input buffer. Thus, I want to try out QSerialDevice 0.1. I started with the reader in the examples but want to change the port setting that do not seem to work since I get errors from

MyDevice->setBaudRate("BaudRate115200");
MyDevice->setBaudRate(19200);

I do not know to to use as parameter.

Thanks in Advance

kuzulis
14th October 2009, 12:52
1. First the need to open! It opens with parameters by default (9600 8 N 1)
2. Further, it is possible to configure:


bool setBaudRate (BaudRate baudRate);
bool setBaudRate (const QString & baudRate);

example:


...
AbstractSerial *MyDevice = new AbstractSerial();
MyDevice->setDeviceName("COM1");
MyDevice->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
MyDevice->setBaudRate(AbstractSerial::BaudRate19200);
...


PS:
use version 0.1.0
PSS:
if you find bugs or would anything is unclear - then write to me at e-mail
(email address in the source code)