1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-26 17:33:02 -04:00

Merge pull request #2497 from srcejon/fix_2486

Rotator Controller: Add line ending setting for GS-232 protocol.
This commit is contained in:
Edouard Griffiths 2025-08-08 20:09:38 +02:00 committed by GitHub
commit 6fedef4c45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 87 additions and 16 deletions

View File

@ -491,6 +491,7 @@ void GS232ControllerGUI::displaySettings()
ui->highSensitivity->setChecked(m_settings.m_highSensitivity);
ui->enableTargetControl->setChecked(m_settings.m_targetControlEnabled);
ui->enableOffsetControl->setChecked(m_settings.m_offsetControlEnabled);
ui->lineEnding->setCurrentIndex((int) m_settings.m_lineEnding);
ui->dfmTrack->setChecked(m_settings.m_dfmTrackOn);
ui->dfmLubePumps->setChecked(m_settings.m_dfmLubePumpsOn);
ui->dfmBrakes->setChecked(m_settings.m_dfmBrakesOn);
@ -643,17 +644,20 @@ void GS232ControllerGUI::setProtocol(GS232ControllerSettings::Protocol protocol)
ui->precision->setValue(0);
ui->precision->setEnabled(false);
ui->precisionLabel->setEnabled(false);
ui->lineEnding->setEnabled(true);
}
else if (protocol == GS232ControllerSettings::SPID)
{
ui->precision->setValue(1);
ui->precision->setEnabled(false);
ui->precisionLabel->setEnabled(false);
ui->lineEnding->setEnabled(false);
}
else
{
ui->precision->setEnabled(true);
ui->precisionLabel->setEnabled(true);
ui->lineEnding->setEnabled(false);
}
bool dfm = protocol == GS232ControllerSettings::DFM;
ui->dfmLine->setVisible(dfm);
@ -869,6 +873,12 @@ void GS232ControllerGUI::on_sources_currentTextChanged(const QString& text)
applySetting("source");
}
void GS232ControllerGUI::on_lineEnding_currentIndexChanged(int index)
{
m_settings.m_lineEnding = (GS232ControllerSettings::LineEnding)index;
applySetting("lineEnding");
}
void GS232ControllerGUI::on_dfmTrack_clicked(bool checked)
{
m_settings.m_dfmTrackOn = checked;
@ -1004,6 +1014,7 @@ void GS232ControllerGUI::makeUIConnections()
QObject::connect(ui->highSensitivity, &QToolButton::clicked, this, &GS232ControllerGUI::on_highSensitivity_clicked);
QObject::connect(ui->enableTargetControl, &QToolButton::clicked, this, &GS232ControllerGUI::on_enableTargetControl_clicked);
QObject::connect(ui->enableOffsetControl, &QToolButton::clicked, this, &GS232ControllerGUI::on_enableOffsetControl_clicked);
QObject::connect(ui->lineEnding, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_lineEnding_currentIndexChanged);
QObject::connect(ui->dfmTrack, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmTrack_clicked);
QObject::connect(ui->dfmLubePumps, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmLubePumps_clicked);
QObject::connect(ui->dfmBrakes, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmBrakes_clicked);

View File

@ -125,6 +125,7 @@ private slots:
void on_tolerance_valueChanged(double value);
void on_precision_valueChanged(int value);
void on_coordinates_currentIndexChanged(int index);
void on_lineEnding_currentIndexChanged(int index);
void on_dfmTrack_clicked(bool checked=false);
void on_dfmLubePumps_clicked(bool checked=false);
void on_dfmBrakes_clicked(bool checked=false);

View File

@ -85,7 +85,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -107,7 +107,7 @@
<string>Azimuth</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
@ -146,7 +146,7 @@
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
</widget>
</item>
@ -162,7 +162,7 @@
<string>Elevation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
@ -240,7 +240,7 @@
<item>
<widget class="Line" name="dfmLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
@ -765,6 +765,35 @@
</item>
</layout>
</item>
<item row="7" column="3">
<widget class="QComboBox" name="lineEnding">
<property name="toolTip">
<string>Character sequence to transmit at end of line</string>
</property>
<item>
<property name="text">
<string>CR/LF</string>
</property>
</item>
<item>
<property name="text">
<string>CR</string>
</property>
</item>
<item>
<property name="text">
<string>LF</string>
</property>
</item>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="lineEndingLabel">
<property name="text">
<string>Line ending</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -70,6 +70,7 @@ void GS232ControllerSettings::resetToDefaults()
for (int i = 0; i < INPUTCONTROLLER_MAX_AXES; i++) {
m_inputControllerSettings.m_deadzone[i] = 10.0f;
}
m_lineEnding = CRLF;
m_dfmTrackOn = false;
m_dfmLubePumpsOn = false;
m_dfmBrakesOn = false;
@ -129,6 +130,7 @@ QByteArray GS232ControllerSettings::serialize() const
s.writeBool(37, m_targetControlEnabled);
s.writeBool(38, m_offsetControlEnabled);
s.writeBool(39, m_highSensitivity);
s.writeS32(40, m_lineEnding);
s.writeFloat(50, m_inputControllerSettings.m_lowSensitivity);
s.writeFloat(51, m_inputControllerSettings.m_highSensitivity);
@ -207,6 +209,7 @@ bool GS232ControllerSettings::deserialize(const QByteArray& data)
d.readBool(37, &m_targetControlEnabled, true);
d.readBool(38, &m_offsetControlEnabled, true);
d.readBool(39, &m_highSensitivity, true);
d.readS32(40, (int *) &m_lineEnding, (int) CRLF);
d.readFloat(50, &m_inputControllerSettings.m_lowSensitivity, 5.0f);
d.readFloat(51, &m_inputControllerSettings.m_highSensitivity, 50.0f);
@ -312,6 +315,9 @@ void GS232ControllerSettings::applySettings(const QStringList& settingsKeys, con
if (settingsKeys.contains("highSensitivity")) {
m_highSensitivity = settings.m_highSensitivity;
}
if (settingsKeys.contains("lineEnding")) {
m_lineEnding = settings.m_lineEnding;
}
if (settingsKeys.contains("dfmTrackOn")) {
m_dfmTrackOn = settings.m_dfmTrackOn;
}
@ -430,6 +436,9 @@ QString GS232ControllerSettings::getDebugString(const QStringList& settingsKeys,
if (settingsKeys.contains("highSensitivity") || force) {
ostr << " m_highSensitivity: " << m_highSensitivity;
}
if (settingsKeys.contains("lineEnding") || force) {
ostr << " m_lineEnding: " << m_lineEnding;
}
if (settingsKeys.contains("title") || force) {
ostr << " m_title: " << m_title.toStdString();
}

View File

@ -54,6 +54,7 @@ struct GS232ControllerSettings
bool m_targetControlEnabled;
bool m_offsetControlEnabled;
bool m_highSensitivity;
enum LineEnding { CRLF, CR, LF } m_lineEnding; // GS232 only
bool m_dfmTrackOn;
bool m_dfmLubePumpsOn;

View File

@ -28,7 +28,7 @@ GS232Protocol::GS232Protocol()
void GS232Protocol::setAzimuth(float azimuth)
{
QString cmd = QString("M%1\r\n").arg((int)std::round(azimuth), 3, 10, QLatin1Char('0'));
QString cmd = QString("M%1%2").arg((int)std::round(azimuth), 3, 10, QLatin1Char('0')).arg(lineEnding());
QByteArray data = cmd.toLatin1();
m_device->write(data);
m_lastAzimuth = azimuth;
@ -36,7 +36,7 @@ void GS232Protocol::setAzimuth(float azimuth)
void GS232Protocol::setAzimuthElevation(float azimuth, float elevation)
{
QString cmd = QString("W%1 %2\r\n").arg((int)std::round(azimuth), 3, 10, QLatin1Char('0')).arg((int)std::round(elevation), 3, 10, QLatin1Char('0'));
QString cmd = QString("W%1 %2%3").arg((int)std::round(azimuth), 3, 10, QLatin1Char('0')).arg((int)std::round(elevation), 3, 10, QLatin1Char('0')).arg(lineEnding());
QByteArray data = cmd.toLatin1();
m_device->write(data);
ControllerProtocol::setAzimuthElevation(azimuth, elevation);
@ -94,7 +94,18 @@ void GS232Protocol::readData()
// Request current Az/El from controller
void GS232Protocol::update()
{
QByteArray cmd("C2\r\n");
m_device->write(cmd);
QString cmd = QString("C2%1").arg(lineEnding());
QByteArray data = cmd.toLatin1();
m_device->write(data);
}
QString GS232Protocol::lineEnding() const
{
if (m_settings.m_lineEnding == GS232ControllerSettings::CRLF) {
return "\r\n";
} else if (m_settings.m_lineEnding == GS232ControllerSettings::CR) {
return "\r";
} else {
return "\n";
}
}

View File

@ -31,6 +31,7 @@ public:
void setAzimuthElevation(float azimuth, float elevation) override;
void readData() override;
void update() override;
QString lineEnding() const;
};
#endif // INCLUDE_FEATURE_GS232PROTOCOL_H_

View File

@ -107,7 +107,15 @@ Specifies the coordinate system used by the GUI for entry and display of the pos
Equations for translating between these coordinate systems can be found [here](https://ntrs.nasa.gov/citations/19670030005).
<h3>22: Input Control</h3>
<h3>22: Line Ending</h3>
For the GS-232 protocol only, sets the control characters that are transmitted after each command:
* CRLF - "\r\n"
* CR - "\r"
* LF - "\n"
<h3>23: Input Control</h3>
Specifies a controller/gamepad that can be used to specify target coordinates or azimuth and elevation offset.
@ -130,21 +138,21 @@ On Linux, using Qt Gamepad with the evdev backend, all joysticks & gamepads appe
If using a joystick which only has 2 axes, whether it corresponds to the left or right stick can be configured by pressing the 'Config...' button.
On Linux, the [xone driver](https://github.com/medusalix/xone) has support for the Xbox Wireless Controller, that isn't supported by the older xpad driver that is included with Ubuntu.
<h3>23: High or Low Sensitivity</h3>
<h3>24: High or Low Sensitivity</h3>
Specifies High (H) or Low (L) Sensitivity mode. This is how fast coordinates will change for a given control stick movement.
High Sensitivity is used for coarse target/offset adjustment, whereas Low sensitivity is used for fine target/offset adjustment.
The sensitivity in each mode can be set in the Input Configuration Dialog (22).
The sensitivity in each mode can be set in the Input Configuration Dialog (23).
<h3>24: (T) Enable Target Control</h3>
<h3>25: (T) Enable Target Control</h3>
When checked, the target coordinates can be set with the input controller. When unchecked, the axes controlling the target will be ignored.
<h3>25: (O) Enable Offset Control</h3>
<h3>26: (O) Enable Offset Control</h3>
When checked, the offset coordinates can be set with the input controller. When unchecked, the axes controlling the offset will be ignored.
<h3>26: Input Control Configuration</h3>
<h3>27: Input Control Configuration</h3>
Pressing the Config... button will display the Input Configuration Dialog:
@ -160,7 +168,7 @@ when a stick is centered, but is reporting a non-zero position on the axis.
<h4>3: Sensitivity</h4>
Specifies the sensitivity of the input in Low and High Sensitivity mode (23). The higher the value, the faster coordinates will change for a given control stick movement.
Specifies the sensitivity of the input in Low and High Sensitivity mode (24). The higher the value, the faster coordinates will change for a given control stick movement.
<h2>Protocol Implementations</h2>