I am receiving this frame $0,S1,B2,Kffffffffffff,T61*34
through UART with this code.
//Receive Data
for(uint8_t i = 0; i < size; i++){
receivedFrame[i] = EUSART1_Read();
if(receivedFrame[i] == '*'){
size = i + 3;
}
}
The start of the frame is always $
and the end is always *
after that comes two bytes holds the check sum for the previous bytes (ex 34
).
The frame length is not fixed but it has a minimum length of 26(from $
to *
) + 2 bytes of check sum and maximum length of 62 and also + 2 bytes of check sum.
but it is not the best thing to use since so many scenarios could happen to make this unstable for example if the *
didn't arrive, this will make every frame I read is wrong.
I searched for better way to receive data through UART but didn't manage to find any thing. I am looking for better ways to deal with receiving frames like this.