fix(#430): accept 176-byte frames (caplog chunks were being rejected)
The frame decoder capped companion frames at 172, but the firmware's real
MAX_FRAME_SIZE is 176 (BaseSerialInterface.h, "+4 for transport codes").
Full-size caplog CHUNK frames (176 B) were silently rejected; only the final
sub-172 partial chunk survived, so a download reassembled just the last chunk
(e.g. "received 95 of 5141"). Caplog is the first feature to use full frames,
so nothing exposed this before.
- usb_serial_frame_codec.dart: usbSerialMaxPayloadLength 172 -> 176.
- serial_capture_screen.dart: erase-on-start (Start / Start&Reboot) for a clean
session ("didn't start at 0").
- 3 decoder regression tests; 113 tests total green; analyze clean.
Root cause confirmed with firmware (TopazHill): firmware streams the full
buffer correctly (wire trace 5175/5175); the client decoder dropped oversized
chunks. My earlier firmware-ring hypothesis was wrong.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix/395-dm-channel-send-wedge
parent
7d03a43bb7
commit
ed8bfdf503
@ -0,0 +1,39 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/services/usb_serial_frame_codec.dart';
|
||||
|
||||
/// Wrap [payload] as an inbound (RX) transport frame: [0x3e, len_lo, len_hi, …].
|
||||
Uint8List _rxFrame(Uint8List payload) => Uint8List.fromList([
|
||||
usbSerialRxFrameStart,
|
||||
payload.length & 0xff,
|
||||
(payload.length >> 8) & 0xff,
|
||||
...payload,
|
||||
]);
|
||||
|
||||
void main() {
|
||||
group('UsbSerialFrameDecoder frame-size boundary (#430)', () {
|
||||
test('accepts a full 176-byte companion frame (caplog chunk)', () {
|
||||
// Regression: 172 used to reject this, dropping every full caplog chunk.
|
||||
final payload = Uint8List(176)..fillRange(0, 176, 0xAB);
|
||||
final packets = UsbSerialFrameDecoder().ingest(_rxFrame(payload));
|
||||
expect(packets, hasLength(1));
|
||||
expect(packets.single.payload.length, 176);
|
||||
});
|
||||
|
||||
test('decodes 30 full chunks batched into one read (caplog stream)', () {
|
||||
final buf = <int>[];
|
||||
for (var i = 0; i < 30; i++) {
|
||||
buf.addAll(_rxFrame(Uint8List(176)..fillRange(0, 176, i)));
|
||||
}
|
||||
final packets = UsbSerialFrameDecoder().ingest(Uint8List.fromList(buf));
|
||||
expect(packets, hasLength(30));
|
||||
expect(packets.every((p) => p.payload.length == 176), isTrue);
|
||||
});
|
||||
|
||||
test('still rejects an over-max (177-byte) frame', () {
|
||||
final packets = UsbSerialFrameDecoder().ingest(_rxFrame(Uint8List(177)));
|
||||
expect(packets, isEmpty);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in new issue