mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 13:11:20 -05:00 
			
		
		
		
	Merge pull request #2438 from mattsoftware/gs232_fixes
Also accept +0179+0001 as an acceptable gs232 format for reporting po…
This commit is contained in:
		
						commit
						c8fed979d4
					
				@ -54,23 +54,37 @@ void GS232Protocol::readData()
 | 
				
			|||||||
        if (len != -1)
 | 
					        if (len != -1)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            QString response = QString::fromUtf8(buf, len);
 | 
					            QString response = QString::fromUtf8(buf, len);
 | 
				
			||||||
            // MD-02 can return AZ=-00 EL=-00 and other negative angles
 | 
					            // Handle both formats:
 | 
				
			||||||
            QRegularExpression re("AZ=([-\\d]\\d\\d) *EL=([-\\d]\\d\\d)");
 | 
					            // 1. AZ=XXX EL=XXX (MD-02 can return negative angles like AZ=-00 EL=-00)
 | 
				
			||||||
            QRegularExpressionMatch match = re.match(response);
 | 
					            // 2. +XXXX+YYYY (direct angle format)
 | 
				
			||||||
            if (match.hasMatch())
 | 
					            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 az = matchAzEl.captured(1);
 | 
				
			||||||
                QString el = match.captured(2);
 | 
					                QString el = matchAzEl.captured(2);
 | 
				
			||||||
                //qDebug() << "SPIDProtocol::readData read Az " << az << " El " << el;
 | 
					                //qDebug() << "GS232Protocol::readData read Az " << az << " El " << el;
 | 
				
			||||||
                reportAzEl(az.toFloat(), el.toFloat());
 | 
					                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")
 | 
					            else if (response == "\r\n")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // Ignore
 | 
					                // Ignore
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            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));
 | 
					                reportError(QString("Unexpected GS-232 response: %1").arg(response));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user