mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-21 18:05:28 +10:00
Add initial load scheduling and tests for USB screen and frame codec functionality
This commit is contained in:
committed by
just-stuff-tm
parent
781090243c
commit
f39a22668e
@@ -13,6 +13,21 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('wrapUsbSerialTxFrame rejects payloads above protocol maximum', () {
|
||||
final payload = Uint8List(usbSerialMaxPayloadLength + 1);
|
||||
|
||||
expect(
|
||||
() => wrapUsbSerialTxFrame(payload),
|
||||
throwsA(
|
||||
isA<ArgumentError>().having(
|
||||
(error) => error.name,
|
||||
'name',
|
||||
'payload.length',
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('UsbSerialFrameDecoder buffers partial frames until complete', () {
|
||||
final decoder = UsbSerialFrameDecoder();
|
||||
|
||||
@@ -81,4 +96,28 @@ void main() {
|
||||
expect(packets[1].payload, orderedEquals(<int>[0x33]));
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'UsbSerialFrameDecoder drops oversized frames and resyncs on the next valid packet',
|
||||
() {
|
||||
final decoder = UsbSerialFrameDecoder();
|
||||
|
||||
final packets = decoder.ingest(
|
||||
Uint8List.fromList(<int>[
|
||||
usbSerialRxFrameStart,
|
||||
0xAD,
|
||||
0x00,
|
||||
0x99,
|
||||
usbSerialRxFrameStart,
|
||||
0x01,
|
||||
0x00,
|
||||
0x44,
|
||||
]),
|
||||
);
|
||||
|
||||
expect(packets, hasLength(1));
|
||||
expect(packets.single.isRxFrame, isTrue);
|
||||
expect(packets.single.payload, orderedEquals(<int>[0x44]));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user