Last active
February 16, 2020 08:10
-
-
Save chokelive/a9899ef0a8d5a20670c692d442acf4b2 to your computer and use it in GitHub Desktop.
extract call-sign and suffix value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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