Mr-Ntic / qextserialport

Automatically exported from code.google.com/p/qextserialport
Other
0 stars 0 forks source link

How to supply Baud Rate from a config file (convert QString to BaudRateType)? #119

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, 
qextserialport accepts baud rate of type 'Enum BaudRateType'. How do I send 
baud date from an external config file which is in text format? The Baud Rate 
that config file sends (BAUD4800) will be QString. How do I convert this 
QString to BaudRateType?

Original issue reported on code.google.com by sarang.t...@gmail.com on 10 Mar 2012 at 3:07

GoogleCodeExporter commented 8 years ago
Hi, 
I made a class called qextserialporthelper which helps to resolve this problem. 
I attach it. 
With this class I can read settings from ini like this:
ser->setDataBits(serHelp.dataBitsMap[s.value("SERIAL/DATABITS").toString()]);
s is a QSetting object

The ini file looks like:
[SERIAL]
ENABLED=0
PORTNAME=COM3
BAUDRATE=38400
DATABITS=8
#DATABITS: 5, 6, 7, 8
PARITY=NONE
#PARITY: NONE, ODD, EVEN, MARK, SPACE
STOPBITS=1
#STOPBITS: 1, 1.5, 2
FLOW=OFF
#FLOW: OFF, HARDWARE, XONXOFF
TERM=\r

Original comment by gosztola...@gmail.com on 12 Mar 2012 at 9:42

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks a lot! Will try to use it today....

Original comment by sarang.t...@gmail.com on 12 Mar 2012 at 1:04

GoogleCodeExporter commented 8 years ago
Yup, it works like a charm, thanks again!

Original comment by sarang.t...@gmail.com on 13 Mar 2012 at 4:32

GoogleCodeExporter commented 8 years ago
Fixed in Version 2.0

Original comment by dbzhang...@gmail.com on 19 Apr 2012 at 2:52

GoogleCodeExporter commented 8 years ago

Original comment by dbzhang...@gmail.com on 13 Dec 2012 at 6:21