If your sender sends <3, val1, val2, val3> or <1, val>, then you can use strtok to extract the tokens, and test whether the first token is 1 or 3, then use strtok to extract that number of tokens from the rest of the string.
If your sender sends <3, val1, val2, val3> or <1, val>, then you can use strtok to extract the tokens, and test whether the first token is 1 or 3, then use strtok to extract that number of tokens from the rest of the string.