I wouldn't bother with such complicated code ...
The ascii codes are well known .. just open character map :
0x30 = 0 , 0x39 = 9 A = 0x41 , U = 0x55 , X = 0x58 , Y = 0x59 , Z = 0x5A
Define an array of five integer (4 bytes variabiles) ... Initialize all with 0
Initialize the current value you work with with 0 ( A = 0 , U=1 , X = 2 , Y = 3, Z = 4 in the array)
array_position = 0; // a byte that holds the position in the array you work with.
Loop through the bytes you receive from the serial..
if byte = 0x41 then byte = 0x57;
if byte = 0x55 then byte = 0x56; // now you have U , A, X , Y , Z in a row :: 0x56, 0x57, 0x58 , 0x59, 0x5A (VWXYZ in ascii table)
if byte < 0x30 then byte = 0; // ignore anything under "0" digit
if byte > 0x39 and byte < 0x56 then byte = 0; // ignore anything between digits and "V", which is our new code for U ... from V to Z we have our codes)
if byte > 0x5A then byte = 0; // ignore anything after Z
so now you have either u,a, x,y,z (well actually the characters V, W, X, Y, Z) or "0"-"9" ... or 0 which is invalid character for our program
if byte !=0 then {
if byte > 0x39 then // not a digit, so that means it's one of our codes ... change the array position we work with depending on the character here
array_position = byte - 0x56; // so position becomes a value between 0 and 4
else
array [ array_position] = array [array_position] * 10 + byte; // if it's the first digit ever, you have here array [ # ] = array [ # ] * 10 + digit ... that's why it's important to initialize the array values with 0.
end if
}
read next byte from serial
end loop
(above is pseudocode, it's not supposed to be c or something like that)
That's pretty much it, just "byte banging" - no need for atoi and other functions for something so simple. You can made it better by adding the lower case letters in the ifs to treat them as valid.
The loop will just ignore anything that's not digit or uppercase u,a,x,y,z so you can use , and other characters to separate them.
PS. and since it initializes all with 0, you can skip some of them if you want to, or write something like UA10X2YZ ... all would be 0 except A and X ... optionally, you can initialize the array with -1 or something like that and do a check after the serial reading is done and whatever remains -1 is not transferred to the main code.