1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-28 15:05:48 -04:00

Also accept +0179+0001 as an acceptable gs232 format for reporting position

This commit is contained in:
Matt Paine 2025-04-20 17:56:11 +10:00
parent e6b3e50fd2
commit fa6a801411

View File

@ -54,23 +54,37 @@ void GS232Protocol::readData()
if (len != -1)
{
QString response = QString::fromUtf8(buf, len);
// MD-02 can return AZ=-00 EL=-00 and other negative angles
QRegularExpression re("AZ=([-\\d]\\d\\d) *EL=([-\\d]\\d\\d)");
QRegularExpressionMatch match = re.match(response);
if (match.hasMatch())
// Handle both formats:
// 1. AZ=XXX EL=XXX (MD-02 can return negative angles like AZ=-00 EL=-00)
// 2. +XXXX+YYYY (direct angle format)
QRegularExpression reAzEl("AZ=([-\\d]\\d\\d) *EL=([-\\d]\\d\\d)");
QRegularExpression reAngles("([+-]\\d{4})([+-]\\d{4})");
QRegularExpressionMatch matchAzEl = reAzEl.match(response);
QRegularExpressionMatch matchAngles = reAngles.match(response);
if (matchAzEl.hasMatch())
{
QString az = match.captured(1);
QString el = match.captured(2);
//qDebug() << "SPIDProtocol::readData read Az " << az << " El " << el;
QString az = matchAzEl.captured(1);
QString el = matchAzEl.captured(2);
qDebug() << "GS232Protocol::readData read Az " << az << " El " << el;
reportAzEl(az.toFloat(), el.toFloat());
}
else if (matchAngles.hasMatch())
{
// Convert from +XXXX format to float
QString az = matchAngles.captured(1);
QString el = matchAngles.captured(2);
qDebug() << "GS232Protocol::readData read direct angles Az " << az << " El " << el;
// The format gives angles in tenths of a degree, so divide by 10
reportAzEl(az.toFloat()/10.0f, el.toFloat()/10.0f);
}
else if (response == "\r\n")
{
// Ignore
}
else
{
qWarning() << "SPIDProtocol::readData - unexpected GS-232 response \"" << response << "\"";
qWarning() << "GS232Protocol::readData - unexpected GS-232 response \"" << response << "\"";
reportError(QString("Unexpected GS-232 response: %1").arg(response));
}
}