You could use something like this: https://github.com/tttapa/Projects/tree/master/Arduino/Serial/Input Parsing/Binary-Protocol