7#include "serialsetting.h"
8#include "serialsetting_p.h"
12NetworkManager::SerialSettingPrivate::SerialSettingPrivate()
13 : name(NM_SETTING_SERIAL_SETTING_NAME)
16 , parity(SerialSetting::NoParity)
22NetworkManager::SerialSetting::SerialSetting()
23 : Setting(Setting::Serial)
24 , d_ptr(new SerialSettingPrivate())
28NetworkManager::SerialSetting::SerialSetting(
const Ptr &other)
30 , d_ptr(new SerialSettingPrivate())
32 setBaud(other->baud());
33 setBits(other->bits());
34 setParity(other->parity());
35 setStopbits(other->stopbits());
36 setSendDelay(other->sendDelay());
39NetworkManager::SerialSetting::~SerialSetting()
51void NetworkManager::SerialSetting::setBaud(quint32 speed)
58quint32 NetworkManager::SerialSetting::baud()
const
60 Q_D(
const SerialSetting);
65void NetworkManager::SerialSetting::setBits(quint32 byteWidgh)
72quint32 NetworkManager::SerialSetting::bits()
const
74 Q_D(
const SerialSetting);
79void NetworkManager::SerialSetting::setParity(NetworkManager::SerialSetting::Parity paritysetting)
83 d->parity = paritysetting;
86NetworkManager::SerialSetting::Parity NetworkManager::SerialSetting::parity()
const
88 Q_D(
const SerialSetting);
93void NetworkManager::SerialSetting::setStopbits(quint32 number)
100quint32 NetworkManager::SerialSetting::stopbits()
const
102 Q_D(
const SerialSetting);
107void NetworkManager::SerialSetting::setSendDelay(quint64 delay)
111 d->sendDelay = delay;
114quint64 NetworkManager::SerialSetting::sendDelay()
const
116 Q_D(
const SerialSetting);
123 if (setting.contains(
QLatin1String(NM_SETTING_SERIAL_BAUD))) {
124 setBaud(setting.value(
QLatin1String(NM_SETTING_SERIAL_BAUD)).toUInt());
127 if (setting.contains(
QLatin1String(NM_SETTING_SERIAL_BITS))) {
128 setBits(setting.value(
QLatin1String(NM_SETTING_SERIAL_BITS)).toUInt());
131 if (setting.contains(
QLatin1String(NM_SETTING_SERIAL_PARITY))) {
134 if (character ==
'n') {
136 }
else if (character ==
'E') {
137 setParity(EvenParity);
138 }
else if (character ==
'o') {
139 setParity(OddParity);
143 if (setting.contains(
QLatin1String(NM_SETTING_SERIAL_STOPBITS))) {
144 setStopbits(setting.value(
QLatin1String(NM_SETTING_SERIAL_STOPBITS)).toUInt());
147 if (setting.contains(
QLatin1String(NM_SETTING_SERIAL_SEND_DELAY))) {
148 setSendDelay((Setting::SecretFlagType)setting.value(
QLatin1String(NM_SETTING_SERIAL_SEND_DELAY)).toULongLong());
156 if (baud() != 57600) {
157 setting.insert(
QLatin1String(NM_SETTING_SERIAL_BAUD), baud());
161 setting.insert(
QLatin1String(NM_SETTING_SERIAL_BITS), bits());
164 if (parity() != NoParity) {
165 if (parity() == EvenParity) {
167 }
else if (parity() == OddParity) {
172 if (stopbits() != 1) {
173 setting.insert(
QLatin1String(NM_SETTING_SERIAL_STOPBITS), stopbits());
177 setting.insert(
QLatin1String(NM_SETTING_SERIAL_SEND_DELAY), sendDelay());
185 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
186 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
188 dbg.
nospace() << NM_SETTING_SERIAL_BAUD <<
": " << setting.baud() <<
'\n';
189 dbg.
nospace() << NM_SETTING_SERIAL_BITS <<
": " << setting.bits() <<
'\n';
190 dbg.
nospace() << NM_SETTING_SERIAL_PARITY <<
": " << setting.parity() <<
'\n';
191 dbg.
nospace() << NM_SETTING_SERIAL_STOPBITS <<
": " << setting.stopbits() <<
'\n';
192 dbg.
nospace() << NM_SETTING_SERIAL_SEND_DELAY <<
": " << setting.sendDelay() <<
'\n';
Represents serial setting.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
KIOCORE_EXPORT QString number(KIO::filesize_t size)