The parsing of Datatxt in the Calculation routine makes an assumption that the serial text stream records are always intact.
I have captured events when there is a partial "R" record which ends after some number (<64) of pixel values, and then in that same buffer after the partial data another "R" record is fully intact.
This type of 'data' event can be triggered by stopping the application in the debugger, stepping around, then continuing; or by using (at least) certain GUI button functionality.
Some time after such a trigger, the Datatxt buffer gets the combination of partial+full records. Without further digging I can't say if it is the IR chip's fault, or the app sending a command that causes the chip to do that, or a bug/design issue in the app causing it to mismanage the incoming text stream.
One way to compensate for the partial+full condition is to fix the parsing to not assume just one complete intact "R" record.
More specifically, when getting the index of "I", don't assume the first "I" is the correct one. Get the "X" index first, then get the LastIndexOf "R" prior to the "X", and the "I" similarly. I also recommend assuring that R, I and X have been found, with a proper order (and separation).
The parsing of Datatxt in the Calculation routine makes an assumption that the serial text stream records are always intact.
I have captured events when there is a partial "R" record which ends after some number (<64) of pixel values, and then in that same buffer after the partial data another "R" record is fully intact.
This type of 'data' event can be triggered by stopping the application in the debugger, stepping around, then continuing; or by using (at least) certain GUI button functionality.
Some time after such a trigger, the Datatxt buffer gets the combination of partial+full records. Without further digging I can't say if it is the IR chip's fault, or the app sending a command that causes the chip to do that, or a bug/design issue in the app causing it to mismanage the incoming text stream.
One way to compensate for the partial+full condition is to fix the parsing to not assume just one complete intact "R" record.
More specifically, when getting the index of "I", don't assume the first "I" is the correct one. Get the "X" index first, then get the LastIndexOf "R" prior to the "X", and the "I" similarly. I also recommend assuring that R, I and X have been found, with a proper order (and separation).