All you need to check is change the length checking from 54 to 54+3 57 which make sure's that you have total 57 strings and it executes the parse only when 54 +3 char's are in msg string.
was it like this?
if (msg.Length > 57)
substring = msg.Substring(54, 3);
it shuld work for sure