Add missing sentinel specifc code (to allow sentinels other than 0)
This commit is contained in:
parent
e1d18942dc
commit
2dfb1cc56c
1 changed files with 5 additions and 1 deletions
|
@ -201,6 +201,10 @@ impl Codec {
|
|||
}
|
||||
let cobs_len = cobs_enc.finalize()
|
||||
.map_err(|_| Error::CobsEncodeFailed)?;
|
||||
// make sure sentinel is not in output buffer
|
||||
for x in &mut dest[..cobs_len] {
|
||||
*x ^= FRAME_END_SYMBOL;
|
||||
}
|
||||
cobs_len
|
||||
};
|
||||
dest[cobs_len] = FRAME_END_SYMBOL;
|
||||
|
@ -288,7 +292,7 @@ impl Codec {
|
|||
if cobs_payload.len() == 0 {
|
||||
0
|
||||
} else {
|
||||
cobs::decode(cobs_payload, dest)
|
||||
cobs::decode_with_sentinel(cobs_payload, dest, FRAME_END_SYMBOL)
|
||||
.map_err(|_| Error::CobsDecodeFailed)?
|
||||
};
|
||||
let cobs_decoded = &dest[0..cobs_decoded_len];
|
||||
|
|
Loading…
Reference in a new issue