Newer
Older
use core::fmt::Debug;
use arrayvec::{ArrayVec, CapacityError};
use crc::{Crc, CRC_16_IBM_SDLC};
use crate::{
error::{CommentError, DecodeError, EncodeError},
Arbitrary, Comment, Destination, Gps, Identification, Route, Timestamp,
ValidatedWhiskerIter, Whisker, WhiskerIter, COMMENT_TYPE,
};
const X25: Crc<u16> = Crc::<u16>::new(&CRC_16_IBM_SDLC);
macro_rules! uniq_whisker {
($t:meta) => {
::paste::paste! {
pub fn [<$t:lower>](&self) -> Option<$t> {
self.iter().find_map(|w| match w {
Whisker::$t(x) => Some(x),
_ => None,
})
}
pub fn [<add_ $t:lower>](&mut self, w: $t) -> Result<(), EncodeError> {
if self.[<$t:lower>]().is_some() {
return Err(EncodeError::DuplicateData);
}
try_lock(&mut self.data, |data| {
let mut buf = [0; 256];
// safe to unwrap since we know we have enough space
let out = w.encode(&mut buf).unwrap();
data.try_push(crate::whisker::[<$t:upper _TYPE>]).ok().ok_or(EncodeError::CatsOverflow)?;
data.try_extend_from_slice(out).ok().ok_or(EncodeError::CatsOverflow)?;
Ok(())
})?;
Ok(())
}
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// pub fn [<clear_ $t:lower>](&mut self) { }
}
};
}
macro_rules! poly_whisker {
($t: meta) => {
::paste::paste! {
pub fn [<$t:lower _iter>](&self) -> core::iter::FilterMap<ValidatedWhiskerIter, fn(Whisker) -> Option<$t>> {
fn filt(w: Whisker) -> Option<$t> {
match w {
Whisker::$t(x) => Some(x),
_ => None
}
}
self.iter().filter_map(filt)
}
pub fn [<add_ $t:lower>](&mut self, w: $t) -> Result<(), EncodeError> {
try_lock(&mut self.data, |data| {
let mut buf = [0; 256];
// safe to unwrap since we know we have enough space
let out = w.encode(&mut buf).unwrap();
data.try_push(crate::whisker::[<$t:upper _TYPE>]).ok().ok_or(EncodeError::CatsOverflow)?;
data.try_extend_from_slice(out).ok().ok_or(EncodeError::CatsOverflow)?;
Ok(())
})?;
Ok(())
}
/// N is the maximum packet size we can handle
/// Panics if N >= 8191
#[derive(Default, Clone)]
pub struct Packet<const N: usize> {
data: ArrayVec<u8, N>,
}
// TODO need to have methods for removing whiskers from the packet
impl<const N: usize> Packet<N> {
pub fn decode(data: ArrayVec<u8, N>) -> Result<Self, DecodeError> {
// validate the data
for w in WhiskerIter::new(&data) {
w?;
}
let comment_iter = WhiskerIter::new(&data)
.filter_map(|w| match w.unwrap() {
Whisker::Comment(c) => Some(c.internal_data().clone()),
_ => None,
})
.flatten();
if !utf8::validate(comment_iter) {
return Err(DecodeError::InvalidComment);
}
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Ok(Self { data })
}
pub fn encode(&self) -> &[u8] {
&self.data
}
/// Directly after the CRC block in The Pipeline
pub fn semi_encode(mut self) -> Result<ArrayVec<u8, N>, (EncodeError, Self)> {
let crc = X25.checksum(&self.data).to_le_bytes();
let res: Result<(), CapacityError<u8>> = try_lock(&mut self.data, |data| {
data.try_push(crc[0])?;
data.try_push(crc[1])?;
Ok(())
});
match res {
Ok(()) => Ok(self.data),
Err(_) => Err((EncodeError::CatsOverflow, self)),
}
}
/// Directly after the CRC block in The Pipeline
pub fn semi_decode(mut data: ArrayVec<u8, N>) -> Result<Self, DecodeError> {
let crc1 = data.pop().ok_or(DecodeError::UnexpectedEndOfInput)?;
let crc0 = data.pop().ok_or(DecodeError::UnexpectedEndOfInput)?;
let crc_expected = u16::from_le_bytes([crc0, crc1]);
let crc_actual = X25.checksum(&data);
if crc_expected != crc_actual {
return Err(DecodeError::CrcMismatch);
}
Self::decode(data)
}
/// Includes the data length L, but does not include the preamble or sync word.
pub fn fully_encode(self) -> Result<ArrayVec<u8, N>, EncodeError> {
let mut data = self.semi_encode().map_err(|(err, _)| err)?;
whitener::whiten(&mut data);
ldpc::encode(&mut data)?;
let mut out: ArrayVec<u8, N> = ArrayVec::new();
// safe to unwrap - length must be below 8191
out.try_extend_from_slice(&u16::try_from(data.len()).unwrap().to_le_bytes())
.map_err(|_| EncodeError::CatsOverflow)?;
interleaver::interleave(&data, &mut out)?;
}
/// Decodes packet that was received over the air.
/// Packet shouldn't have preamble, sync word, or data langth L.
pub fn fully_decode(data: &[u8]) -> Result<Self, DecodeError> {
let mut data = interleaver::uninterleave(data).map_err(|_| DecodeError::Overflow)?;
ldpc::decode(&mut data).ok_or(DecodeError::LdpcError)?;
whitener::whiten(&mut data);
Self::semi_decode(data)
}
pub fn iter(&self) -> ValidatedWhiskerIter {
ValidatedWhiskerIter::new(&self.data)
}
uniq_whisker!(Identification);
uniq_whisker!(Timestamp);
uniq_whisker!(Gps);
uniq_whisker!(Route);
poly_whisker!(Destination);
poly_whisker!(Arbitrary);
pub fn comment<'a>(&self, buf: &'a mut [u8]) -> Result<&'a str, CommentError> {
let iter = self.iter().filter_map(|w| match w {
Whisker::Comment(c) => Some(c),
_ => None,
});
let mut i = 0;
buf.get_mut(i..(i + data.len()))
.ok_or(CommentError::BufferOverflow)?
.copy_from_slice(data);
if !has_comment {
return Err(CommentError::NoComment);
}
// Safe to unwrap since the comment was pre-validated
Ok(core::str::from_utf8(&buf[0..i]).unwrap())
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
}
pub fn add_comment(&mut self, comment: &str) -> Result<(), EncodeError> {
if self.iter().any(|w| matches!(w, Whisker::Comment(_))) {
// we already have a comment
return Err(EncodeError::DuplicateData);
}
try_lock(&mut self.data, |data| {
let mut comment = comment.as_bytes();
while comment.len() > 255 {
let c = Comment::new(&comment[0..255]).unwrap();
let mut buf = [0; 256];
let out = c.encode(&mut buf).unwrap();
data.try_push(COMMENT_TYPE)
.map_err(|_| EncodeError::CatsOverflow)?;
data.try_extend_from_slice(out)
.map_err(|_| EncodeError::CatsOverflow)?;
comment = &comment[255..];
}
let c = Comment::new(comment).unwrap();
let mut buf = [0; 256];
let out = c.encode(&mut buf).unwrap();
data.try_push(COMMENT_TYPE)
.map_err(|_| EncodeError::CatsOverflow)?;
data.try_extend_from_slice(out)
.map_err(|_| EncodeError::CatsOverflow)?;
Ok(())
})?;
Ok(())
}
}
impl<const N: usize> Debug for Packet<N> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_list()
.entries(ValidatedWhiskerIter::new(&self.data))
.finish()
}
}
// if the function returns an error, we roll back the array
// by rolling it back, we really just pop bytes off the end until the length matches
fn try_lock<const N: usize, T, E, F: Fn(&mut ArrayVec<u8, N>) -> Result<T, E>>(
arr: &mut ArrayVec<u8, N>,
f: F,
) -> Result<T, E> {
let len = arr.len();
match f(arr) {
Ok(x) => Ok(x),
Err(e) => {
arr.truncate(len);
Err(e)
}
}
}
#[cfg(test)]
mod tests {
use arrayvec::ArrayString;
use super::*;
#[test]
fn dest() {
let d1 = Destination::new(false, 7, "CALL1", 23).unwrap();
let d2 = Destination::new(true, 23, "CALL2", 2).unwrap();
let mut packet: Packet<1024> = Packet::default();
packet.add_destination(d1.clone()).unwrap();
packet.add_destination(d2.clone()).unwrap();
let mut dests = packet.destination_iter();
assert_eq!(d1, dests.next().unwrap());
assert_eq!(d2, dests.next().unwrap());
assert_eq!(None, dests.next());
}
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#[test]
fn semi_e2e() {
let comment = "Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.";
let mut packet = Packet::<2048>::default();
packet
.add_identification(Identification {
icon: 123,
callsign: ArrayString::from("ABCXYZ_LONG_CALL").unwrap(),
ssid: 43,
})
.unwrap();
packet.add_comment(comment).unwrap();
let res = packet.add_identification(Identification {
icon: 456,
callsign: ArrayString::from("NOPE").unwrap(),
ssid: 0,
});
assert!(matches!(res, Err(EncodeError::DuplicateData)));
let semi = packet.semi_encode().unwrap();
let packet2 = Packet::semi_decode(semi).unwrap();
assert_eq!(
Identification {
icon: 123,
callsign: ArrayString::from("ABCXYZ_LONG_CALL").unwrap(),
ssid: 43,
},
packet2.identification().unwrap()
);
let mut buf = [0; 1024];
assert_eq!(comment, packet2.comment(&mut buf).unwrap());
}
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#[test]
fn full_e2e() {
let comment = "Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.Hello world! This is a comment. It's long so that it needs to be split across more than one whisker.";
let mut packet = Packet::<4096>::default();
packet
.add_identification(Identification {
icon: 123,
callsign: ArrayString::from("ABCXYZ_LONG_CALL").unwrap(),
ssid: 43,
})
.unwrap();
packet.add_comment(comment).unwrap();
let res = packet.add_identification(Identification {
icon: 456,
callsign: ArrayString::from("NOPE").unwrap(),
ssid: 0,
});
assert!(matches!(res, Err(EncodeError::DuplicateData)));
let mut fully = packet.fully_encode().unwrap();
fully[40] ^= 0x55;
fully[844] ^= 0x7B;
// exclude length
let packet2: Packet<8191> = Packet::fully_decode(&fully[2..]).unwrap();
assert_eq!(
Identification {
icon: 123,
callsign: ArrayString::from("ABCXYZ_LONG_CALL").unwrap(),
ssid: 43,
},
packet2.identification().unwrap()
);
let mut buf = [0; 1024];
assert_eq!(comment, packet2.comment(&mut buf).unwrap());
}
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
#[test]
fn fully_decode_fuzz_tests() {
let data = [
112, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 74, 0, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 114, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 10, 112, 0, 0, 0, 0, 0, 0, 2, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 74, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39,
114, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7, 0, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 145, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
59, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7,
0, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 59, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 228, 0, 0, 0, 64, 0, 65, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 7, 0, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 1, 0, 0, 10, 118, 118, 118, 118, 118, 118, 118, 118, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 64,
0, 65, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 7, 0, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 1, 0, 0, 10, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 1, 2, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 0, 0, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 0, 0, 0, 0, 96, 96,
];
let _ = Packet::<1024>::fully_decode(&data);
}
#[test]
fn semi_decode_fuzz_tests() {
let data: ArrayVec<u8, 1024> = ArrayVec::try_from(
&[
42, 64, 64, 64, 229, 40, 64, 64, 0, 0, 173, 173, 173, 173, 173, 173, 173, 173, 64,
64, 0, 0, 173, 187, 187, 187, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 187, 187,
187, 101, 157, 138, 74, 101, 157, 138, 74, 0, 0, 0, 0, 1, 126, 255, 255, 255, 187,
187, 187, 187, 187, 187, 187, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 187, 101, 157, 138, 74, 101,
157, 138, 106, 0, 0, 0, 0, 1, 126, 255, 255, 255, 0, 212, 0, 0, 0, 0, 1, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 173, 187, 187, 187, 101,
157, 138, 74, 101, 157, 138, 74, 0, 0, 0, 0, 1, 126, 255, 255, 255, 0, 212, 0, 0,
0, 0, 1, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 157, 138, 74, 0, 0, 0,
0, 1, 126, 255, 255, 255, 0, 212, 0, 0, 0, 0, 1, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 173, 187, 187, 64, 187, 101, 157, 138, 74, 101, 157,
50, 138, 74, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 1, 126, 255, 255, 255, 0, 212, 0, 0, 0, 0, 1, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 64, 64, 0, 0, 173, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 187, 187, 187, 101, 157, 138, 74, 101, 157, 138, 74, 0, 0, 0, 0, 1, 126, 255,
255, 255, 0, 212, 0, 0, 0, 0, 1, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 173, 187, 187, 187, 101, 157, 138, 74, 101, 157, 138, 74, 0, 0, 0,
0, 1, 126, 255, 255, 255, 0, 212, 0, 0, 0, 0, 1, 187, 187, 0, 0, 192, 192, 0, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 64, 64, 0, 0, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 187, 187, 187, 101,
157, 138, 74, 101, 157, 138, 74, 0, 0, 0, 0, 1, 126, 255, 255, 255, 0, 212, 0, 0,
0, 0, 1, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 126,
][..],
)
.unwrap();
let _ = Packet::<1024>::semi_decode(data);
}
#[test]
fn decode_fuzz_tests() {
let data = ArrayVec::try_from(&[4, 0, 0, 0][..]).unwrap();
let _ = Packet::<1024>::decode(data);
}