•             if (+charDecimal == 171 && bufferLength == 10) {
    

    I'd call this highly optimistic, you would simply write

                if (bufferLength == 10) {
    

    If you're out of sync for any reason there would be no more measurements, in both code variants.

About

Avatar for maze1980 @maze1980 started