OK, you get these kind of characters from your device?:
<LF><EX$R$N$03>S$R$ ..... <EX$R$N$03>S$R$N2$
One problem could be the "special" characters. The '$' character are control characters. String functions may not work properly on them and with LEN may not be counted.
Please let us know what is exactly in your variable "LastReceivedString" after you received data from the device?
sString := '<LE>$R$NEXR'; (* 11 written characters *)
length := LEN('sString'); (*result => 7 (!) *)
sString2 := MID(sString, 6, 1); (* take 6 characters from the first one on. Result => '<LE>$R$N' *)
(* 8 characters have been taken from string. The '$' do not count*)
Or make a screen shot.
Or just try it out with different kinds of strings. You have to know how the string functions work on your inputs.