[Development] Proposal - QtSerialPort graduation from the Playground

Denis Shienkov scapig2 at yandex.ru
Thu Jan 24 08:20:12 CET 2013


About enumerating BaudRate, my opinion:

1. Enumeration should be kept, similar to other enums for another settings (data bits, flow and etc.). 
If we abandon the enums of baud rate - this will somehow ugly.

2. The names of the enums and their value should be changed.

3. Number of basic types of baud rates to enums can be added / deleted. For example, to do the same as:
http://msdn.microsoft.com/en-us/library/dd187599.aspx

4. Method names getters / setters should be changed.

---------------------------------------------------------------------------------
Summarizing all the above can be done as follows:

1)  Enums:

    enum BaudRate {
        Baud4800 = 4800,
        Baud9600 = 9600,
        Baud19200 = 19200,
        Baud38400 = 38400,
        Baud57600 = 57600,
        Baud115200 = 115200,
        Baud230400 = 230400,
        UnknownBaudRate = -1
    };

2)  Methods names:

bool setBaudRate(qint32 baud /* or baudRate */, Directions dir = AllDirections);

int baudRate(Directions dir = AllDirections) const;


Who thinks that? Let's vote! :)





Best regards,
Denis




24.01.2013, 06:36, "Thiago A. Corrêa" <thiago.correa at gmail.com>:
> On Wed, Jan 23, 2013 at 8:49 PM, Laszlo Papp <lpapp at kde.org> wrote:
>
>>  On Wed, Jan 23, 2013 at 9:45 PM, Thiago A. Corrêa <thiago.correa at gmail.com>
>>  wrote:
>>>  You mean filling the Combo Box with available rates right? (
>>>  ui->rateBox->addItem(QLatin1String("9600"), SerialPort::Rate9600); )
>>>  I would just fill in the numbers in the second argument of addItem.
>>>  Other than maybe getting a compiler error in case of a typo, there
>>>  isn't much gain in the enums themselfs.
>>  That is a nice gain in my opinion to avoid the unintentional bugs thay may
>>  take some time to debug (wrong setting, data not going through properly
>>  towards the modem, perhaps causing random issues and so forth).
>
> [..]
>
>>  I would assume that people prefer enumeration to raw values when possible. I
>
> I agree completly. I was just not too convinced in this particular
> case, but there is a choice either way which is good.
>
> It's interesting that .Net have added Baud230400 while we have both
> Rate1200 and Rate2400 that they left out.
>
> In my use cases I usually have to store the port configuration in some
> configuration file, and the conversion between the 3rdparty library
> enuns (which I shouldn't assume a value for) and my serialized
> representation is boring.
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list