Skip to content

Commit

Permalink
trim invalid characters out of the callsign
Browse files Browse the repository at this point in the history
  • Loading branch information
dbehnke committed Oct 11, 2022
1 parent c2424a7 commit 0dad493
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions USRP2YSF/USRP2YSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ void sig_handler(int signo)
}
}

std::string trim_callsign(const std::string s) {
const std::string ACCEPTABLECHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
size_t start = s.find_first_not_of(ACCEPTABLECHARS);
if (start > 8) {
start = 8;
}
return s.substr(0, start);
}

int main(int argc, char** argv)
{
const char* iniFile = DEFAULT_INI_FILE;
Expand Down Expand Up @@ -257,10 +266,12 @@ int CUSRP2YSF::run()

if( (!memcmp(m_usrpFrame, "USRP", 4)) && len == 352) {
if( (m_usrpFrame[20] == USRP_TYPE_TEXT) && (m_usrpFrame[32] == TLV_TAG_SET_INFO) ){
m_usrpcs = (char *)(m_usrpFrame + 46);
if(!m_usrpFrames){
std::string raw_usrpcs = (char *)(m_usrpFrame + 46);
m_usrpcs = trim_callsign(raw_usrpcs);
if (!m_usrpFrames)
{
m_conv.putUSRPHeader();
LogMessage("USRP text info received as first frame callsign=%s", m_usrpcs.c_str());
LogMessage("USRP text info received as first frame raw_callsign=%s, trim_callsign=%s", raw_usrpcs.c_str(), m_usrpcs.c_str());
}
m_usrpFrames++;
}
Expand Down

0 comments on commit 0dad493

Please sign in to comment.