Searching and parsing data from serial.read

lawt:
Robin - can other bytes in the message carry the value 0x80? I would say yes it can. The PID byte that follows the MID byte identifies which engine parameter is coming next may also have a value of 0x80, I see no reason why the data bytes also should contain 0x80 - the engine load for example is ranged 0-200 which equates to 0-100%, so when the engine load is 64% the data byte for engine load will also be 0x80.

That presents a major complication.

You need a system that is able to tell whether a particular 0x80 is the MID byte or just a data byte.

It seems strange that someone would design a system without a simple means to resolve that. Some form of delimiter (perhaps a special byte value or a sequence of byte values) would be common - the equivalent of a linefeed in a text stream. Another way of distinguishing messages is to have a minimum time interval between messages. If no byte is received for N millisecs then you know the message has ended.

...R