Skip to content

Commit 45ec67a

Browse files
committed
Add RTS and DTR control to rig profiles
Introduces RTS and DTR fields to RigProfile, updates serialization, database schema, and UI to support these options. Hamlib driver now sets serial RTS/DTR states based on profile settings. Migration 035 adds the new columns to the database.
1 parent a3dd56d commit 45ec67a

File tree

9 files changed

+111
-5
lines changed

9 files changed

+111
-5
lines changed

core/Migration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Migration : public QObject
4242
QString fixIntlField(QSqlQuery &query, const QString &columName, const QString &columnNameIntl);
4343
bool refreshUploadStatusTrigger();
4444

45-
static const int latestVersion = 34;
45+
static const int latestVersion = 35;
4646
};
4747

4848
#endif // QLOG_CORE_MIGRATION_H

data/RigProfile.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ QDataStream& operator<<(QDataStream& out, const RigProfile& v)
1919
<< v.xitOffset << v.getRITInfo << v.getXITInfo
2020
<< v.defaultPWR << v.getPTTInfo << v.QSYWiping
2121
<< v.getKeySpeed << v.assignedCWKey << v.keySpeedSync
22-
<< v.driver << v.dxSpot2Rig << v.pttType << v.pttPortPath;
22+
<< v.driver << v.dxSpot2Rig << v.pttType << v.pttPortPath
23+
<< v.rts << v.dtr;
2324

2425
return out;
2526
}
@@ -57,6 +58,8 @@ QDataStream& operator>>(QDataStream& in, RigProfile& v)
5758
in >> v.dxSpot2Rig;
5859
in >> v.pttType;
5960
in >> v.pttPortPath;
61+
in >> v.rts;
62+
in >> v.dtr;
6063

6164
return in;
6265
}
@@ -73,7 +76,8 @@ RigProfilesManager::RigProfilesManager() :
7376
"pollinterval, txfreq_start, txfreq_end, get_freq, get_mode, "
7477
"get_vfo, get_pwr, rit_offset, xit_offset, get_rit, get_xit, "
7578
"default_pwr, get_ptt, qsy_wiping, get_key_speed, assigned_cw_key, "
76-
"key_speed_sync, driver, dxspot2rig, ptt_type, ptt_port_pathname "
79+
"key_speed_sync, driver, dxspot2rig, ptt_type, ptt_port_pathname, "
80+
"rts, dtr "
7781
"FROM rig_profiles") )
7882
{
7983
qWarning()<< "Cannot prepare select";
@@ -115,6 +119,8 @@ RigProfilesManager::RigProfilesManager() :
115119
profileDB.dxSpot2Rig = profileQuery.value(28).toBool();
116120
profileDB.pttType = profileQuery.value(29).toString();
117121
profileDB.pttPortPath = profileQuery.value(30).toString();
122+
profileDB.rts = profileQuery.value(31).toString();
123+
profileDB.dtr = profileQuery.value(32).toString();
118124

119125
addProfile(profileDB.profileName, profileDB);
120126
}
@@ -142,12 +148,12 @@ void RigProfilesManager::save()
142148
"baudrate, databits, stopbits, flowcontrol, parity, pollinterval, txfreq_start, "
143149
"txfreq_end, get_freq, get_mode, get_vfo, get_pwr, rit_offset, xit_offset, get_rit, "
144150
"get_xit, default_pwr, get_ptt, qsy_wiping, get_key_speed, assigned_cw_key, key_speed_sync, "
145-
"driver, dxSpot2Rig, ptt_type, ptt_port_pathname ) "
151+
"driver, dxSpot2Rig, ptt_type, ptt_port_pathname, rts, dtr ) "
146152
"VALUES (:profile_name, :model, :port_pathname, :hostname, :netport, "
147153
":baudrate, :databits, :stopbits, :flowcontrol, :parity, :pollinterval, :txfreq_start, "
148154
":txfreq_end, :get_freq, :get_mode, :get_vfo, :get_pwr, :rit_offset, :xit_offset, :get_rit, "
149155
":get_xit, :default_pwr, :get_ptt, :qsy_wiping, :get_key_speed, :assigned_cw_key, :key_speed_sync, "
150-
":driver, :dxSpot2Rig, :ptt_type, :ptt_port_pathname)") )
156+
":driver, :dxSpot2Rig, :ptt_type, :ptt_port_pathname, :rts, :dtr )") )
151157
{
152158
qWarning() << "cannot prepare Insert statement";
153159
return;
@@ -191,6 +197,9 @@ void RigProfilesManager::save()
191197
insertQuery.bindValue(":dxSpot2Rig", rigProfile.dxSpot2Rig);
192198
insertQuery.bindValue(":ptt_type", rigProfile.pttType);
193199
insertQuery.bindValue(":ptt_port_pathname", rigProfile.pttPortPath);
200+
insertQuery.bindValue(":rts", rigProfile.rts);
201+
insertQuery.bindValue(":dtr", rigProfile.dtr);
202+
194203

195204
if ( ! insertQuery.exec() )
196205
{
@@ -239,6 +248,8 @@ bool RigProfile::operator==(const RigProfile &profile)
239248
&& profile.dxSpot2Rig == this->dxSpot2Rig
240249
&& profile.pttType == this->pttType
241250
&& profile.pttPortPath == this->pttPortPath
251+
&& profile.rts == this->rts
252+
&& profile.dtr == this->dtr
242253
);
243254
}
244255

data/RigProfile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class RigProfile
6363
bool dxSpot2Rig;
6464
QString pttType;
6565
QString pttPortPath;
66+
QString rts;
67+
QString dtr;
6668

6769
bool operator== (const RigProfile &profile);
6870
bool operator!= (const RigProfile &profile);

res/res.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
<file>sql/migration_032.sql</file>
4848
<file>sql/migration_033.sql</file>
4949
<file>sql/migration_034.sql</file>
50+
<file>sql/migration_035.sql</file>
5051
</qresource>
5152
</RCC>

res/sql/migration_035.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE rig_profiles ADD COLUMN rts TEXT DEFAULT '';
2+
ALTER TABLE rig_profiles ADD COLUMN dtr TEXT DEFAULT '';

rig/drivers/HamlibRigDrv.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ bool HamlibRigDrv::open()
217217
rig->state.rigport.parm.serial.stop_bits = rigProfile.stopbits;
218218
rig->state.rigport.parm.serial.handshake = stringToHamlibFlowControl(rigProfile.flowcontrol);
219219
rig->state.rigport.parm.serial.parity = stringToHamlibParity(rigProfile.parity);
220+
rig->state.rigport.parm.serial.dtr_state = stringToHamlibForceFlowControl(rigProfile.dtr);
221+
rig->state.rigport.parm.serial.rts_state = stringToHamlibForceFlowControl(rigProfile.rts);
220222

221223
qCDebug(runtime) << "Using PTT Type" << rigProfile.pttType.toLocal8Bit().constData()
222224
<< "PTT Path" << rigProfile.pttPortPath;
@@ -1149,6 +1151,21 @@ serial_parity_e HamlibRigDrv::stringToHamlibParity(const QString &in_parity)
11491151
return RIG_PARITY_NONE;
11501152
}
11511153

1154+
serial_control_state_e HamlibRigDrv::stringToHamlibForceFlowControl(const QString &flowcontrol)
1155+
{
1156+
FCT_IDENTIFICATION;
1157+
1158+
qCDebug(function_parameters) << flowcontrol;
1159+
1160+
if (flowcontrol == "HIGH")
1161+
return RIG_SIGNAL_ON;
1162+
if (flowcontrol == "LOW")
1163+
return RIG_SIGNAL_OFF;
1164+
1165+
return RIG_SIGNAL_UNSET;
1166+
}
1167+
1168+
11521169
QString HamlibRigDrv::hamlibErrorString(int errorCode)
11531170
{
11541171
FCT_IDENTIFICATION;

rig/drivers/HamlibRigDrv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private slots:
7676
const QString hamlibVFO2String(const vfo_t vfo) const;
7777
serial_handshake_e stringToHamlibFlowControl(const QString &in_flowcontrol);
7878
serial_parity_e stringToHamlibParity(const QString &in_parity);
79+
serial_control_state_e stringToHamlibForceFlowControl(const QString &flowcontrol);
7980
QString hamlibErrorString(int);
8081
RIG* rig;
8182
QTimer timer;

ui/SettingsDialog.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ void SettingsDialog::addRigProfile()
470470
profile.parity = ui->rigParitySelect->currentData().toString();
471471
profile.pttType = ui->rigPTTTypeCombo->currentData().toString();
472472
profile.pttPortPath = ui->rigPTTPortEdit->text();
473+
profile.rts = ui->cmbRigRTS->currentText();
474+
profile.dtr = ui->cmbRigDTR->currentText();
473475
}
474476

475477
if ( ui->rigPollIntervalSpinBox->isEnabled() )
@@ -582,6 +584,12 @@ void SettingsDialog::doubleClickRigProfile(QModelIndex i)
582584
ui->rigPTTTypeCombo->setCurrentIndex(( pttIndex < 0 ) ? PTT_TYPE_CAT_INDEX : pttIndex);
583585
ui->rigPTTPortEdit->setText(profile.pttPortPath);
584586

587+
int rtsIndex = ui->cmbRigRTS->findText(profile.rts);
588+
ui->cmbRigRTS->setCurrentIndex(( rtsIndex < 0 ) ? PTT_TYPE_CAT_INDEX : rtsIndex);
589+
590+
int dtrIndex = ui->cmbRigDTR->findText(profile.dtr);
591+
ui->cmbRigDTR->setCurrentIndex(( dtrIndex < 0 ) ? PTT_TYPE_CAT_INDEX : dtrIndex);
592+
585593
setUIBasedOnRigCaps(caps);
586594

587595
ui->rigAddProfileButton->setText(tr("Modify"));
@@ -726,12 +734,17 @@ void SettingsDialog::rigInterfaceChanged(int)
726734
ui->rigModelSelect->setCurrentIndex(( driverID == Rig::HAMLIB_DRIVER ) ? ui->rigModelSelect->findData(DEFAULT_HAMLIB_RIG_MODEL)
727735
: 0 );
728736
ui->rigPTTTypeCombo->clear();
737+
ui->cmbRigRTS->setCurrentIndex(0);
738+
ui->cmbRigDTR->setCurrentIndex(0);
729739

730740
const QList<QPair<QString, QString>> &pttTypes = Rig::instance()->getPTTTypeList(static_cast<Rig::DriverID>(driverID));
731741

732742
for ( const QPair<QString, QString> &type : pttTypes )
733743
ui->rigPTTTypeCombo->addItem(type.second, type.first);
734744

745+
ui->cmbRigRTS->setVisible((driverID == Rig::HAMLIB_DRIVER));
746+
ui->cmbRigDTR->setVisible((driverID == Rig::HAMLIB_DRIVER));
747+
735748
ui->rigPTTTypeCombo->setVisible(( driverID == Rig::HAMLIB_DRIVER ));
736749
ui->rigPTTTypeLabel->setVisible(( driverID == Rig::HAMLIB_DRIVER ));
737750
ui->rigPTTPortEdit->setVisible(( driverID == Rig::HAMLIB_DRIVER ));

ui/SettingsDialog.ui

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,65 @@
22572257
</item>
22582258
</layout>
22592259
</item>
2260+
<item row="7" column="0">
2261+
<widget class="QLabel" name="rigFlowControlLines">
2262+
<property name="text">
2263+
<string>DTR</string>
2264+
</property>
2265+
</widget>
2266+
</item>
2267+
<item row="7" column="1">
2268+
<layout class="QHBoxLayout" name="horizontalLayout_39">
2269+
<item>
2270+
<widget class="QComboBox" name="cmbRigDTR">
2271+
<item>
2272+
<property name="text">
2273+
<string></string>
2274+
</property>
2275+
</item>
2276+
<item>
2277+
<property name="text">
2278+
<string>High</string>
2279+
</property>
2280+
</item>
2281+
<item>
2282+
<property name="text">
2283+
<string>Low</string>
2284+
</property>
2285+
</item>
2286+
</widget>
2287+
</item>
2288+
<item>
2289+
<widget class="QLabel" name="label_6">
2290+
<property name="text">
2291+
<string>RTS</string>
2292+
</property>
2293+
<property name="alignment">
2294+
<set>Qt::AlignRight|Qt::AlignVCenter</set>
2295+
</property>
2296+
</widget>
2297+
</item>
2298+
<item>
2299+
<widget class="QComboBox" name="cmbRigRTS">
2300+
<item>
2301+
<property name="text">
2302+
<string></string>
2303+
</property>
2304+
</item>
2305+
<item>
2306+
<property name="text">
2307+
<string>High</string>
2308+
</property>
2309+
</item>
2310+
<item>
2311+
<property name="text">
2312+
<string>Low</string>
2313+
</property>
2314+
</item>
2315+
</widget>
2316+
</item>
2317+
</layout>
2318+
</item>
22602319
</layout>
22612320
</widget>
22622321
<widget class="QWidget" name="rigNetworkPage">

0 commit comments

Comments
 (0)