Skip to content

Instantly share code, notes, and snippets.

@chokelive
Last active February 16, 2020 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chokelive/a9899ef0a8d5a20670c692d442acf4b2 to your computer and use it in GitHub Desktop.
Save chokelive/a9899ef0a8d5a20670c692d442acf4b2 to your computer and use it in GitHub Desktop.
extract call-sign and suffix value
void extract_callsign()
{
char* callsign_raw = "E2X-1";
char callsign_format[7];
char* pch;
Serial.println(callsign_raw);
// clear array
memset(callsign_format, 0, sizeof(callsign_format));
// split callsign
pch = strtok(callsign_raw,"-");
// copy callsign
strcpy(callsign_format, pch);
// split suffix
pch = strtok(NULL, "-");
if(pch != NULL) //copy suffix to last array
{
callsign_format[callsign_format)-1] = pch[0];
}
else //no suffix, set last array to zero value
{
callsign_format[callsign_format)-1] = '0';
}
// Just Display
for(int i =0; i<callsign_format); i++)
{
Serial.print("chr");
Serial.print(i);
Serial.print(" ");
Serial.println(callsign_format[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment