Skip to content

feat(receive): add --no_dlt_headers option for serial mode#167

Open
mbehr1 wants to merge 6 commits into
mainfrom
feat/recv_ser_nondlt
Open

feat(receive): add --no_dlt_headers option for serial mode#167
mbehr1 wants to merge 6 commits into
mainfrom
feat/recv_ser_nondlt

Conversation

@mbehr1
Copy link
Copy Markdown
Owner

@mbehr1 mbehr1 commented May 3, 2026

Allows to capture raw ascii/utf8 text from serial ports as DLT messages.
Messages get apid/ctid SER/ASC.
Messages are split by newlines or by a 500ms timeout.

Allows to capture raw ascii/utf8 text from serial ports
as DLT messages.
Messages get apid/ctid SER/ASC.
Messages are split by newlines or by a 500ms timeout.

Co-authored-by: Copilot <copilot@github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 88.67925% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.61%. Comparing base (229b81c) to head (5f91cb5).

Files with missing lines Patch % Lines
src/utils/ipdltmsgreceiver.rs 88.07% 47 Missing ⚠️
src/bin/adlt/receive.rs 96.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   83.48%   83.61%   +0.12%     
==========================================
  Files          40       40              
  Lines       21550    21973     +423     
==========================================
+ Hits        17992    18373     +381     
- Misses       3558     3600      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for capturing raw ASCII/UTF-8 serial data and wrapping it into synthesized DLT messages (SER/ASC), controlled via a new --no_dlt_headers flag for serial receive mode.

Changes:

  • Add --no_dlt_headers CLI flag (serial-only) and plumb it into SerialParams via expect_serial_header.
  • Add ExpectedHeader::None mode and a new parse_dlt_without_header path to build DLT messages from newline-delimited (or chunked) serial text.
  • Add unit/integration-style tests for headerless serial parsing and CLI validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/utils/ipdltmsgreceiver.rs Adds headerless serial parsing (ExpectedHeader::None), new parser, and tests for the feature.
src/bin/adlt/receive.rs Adds --no_dlt_headers flag, validates usage, and passes configuration into serial receive mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/ipdltmsgreceiver.rs
Comment thread src/utils/ipdltmsgreceiver.rs
Comment thread src/bin/adlt/receive.rs
Comment on lines +1686 to +1750
fn serial_recv_non_dlt_header_split_by_timeout() {
let logger = new_logger();
// create a pipe and use the read end as serial port for the receiver
let (read_end, mut write_end) = std::io::pipe().expect("create pipe");
let read_end = std::mem::ManuallyDrop::new(read_end);
let read_fd = read_end.as_raw_fd();

let mut serial_port = unsafe { serial2::SerialPort::from_raw_fd(read_fd) };
serial_port
.set_read_timeout(std::time::Duration::from_millis(500))
.expect("set read timeout");

let receiver = IpDltMsgReceiver {
log: logger,
recv_mode: RecvMode::Serial(SerialParams {
device_name: "test".to_string(),
baudrate: 0,
expect_serial_header: false,
}),
recv_method: RecvMethod::Serial(serial_port),
expected_header: ExpectedHeader::None,
interface: InterfaceIndexOrAddress::Index(0),
addr: SocketAddr::new("127.0.0.1".parse().unwrap(), 0),
recv_buffer: Vec::with_capacity(65536),
storage_header_ecu: DltChar4::from_buf(b"EcuS"),
buffered_msgs: std::collections::VecDeque::new(),
recv_buffer_list: Vec::new(),
#[cfg(feature = "pcap")]
plp_stats: None,
#[cfg(feature = "pcap")]
fragment_cache: HashMap::new(),
index: 0,
};

use std::io::Write;
let recv_thread = std::thread::spawn(move || {
let mut receiver = receiver;
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(3);
let mut msgs = Vec::with_capacity(2);
while std::time::Instant::now() < deadline && msgs.len() < 2 {
match receiver.recv_msg() {
Ok((msg, _src_addr)) => msgs.push(msg),
Err(e)
if matches!(
e.kind(),
std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut
) =>
{
continue;
}
Err(e) => panic!("recv_msg failed: {e}"),
}
}
assert_eq!(msgs.len(), 2, "Expected 2 messages within deadline");
(msgs.remove(0), msgs.remove(0))
});

let first_chunk = "first chunk with Ċ without line separator"; // lets test a UTF8 char as well
write_end
.write_all(first_chunk.as_bytes())
.expect("write first chunk to serial pipe");
std::thread::sleep(std::time::Duration::from_millis(600));
write_end
.write_all(b"second chunk with line separator\n")
.expect("write second chunk to serial pipe");
…al headerless mode

Agent-Logs-Url: https://github.com/mbehr1/adlt/sessions/886c3e58-fe99-443e-9c0b-fa6abc1bfc43

Co-authored-by: mbehr1 <3258891+mbehr1@users.noreply.github.com>
…arse_dlt_without_header

Agent-Logs-Url: https://github.com/mbehr1/adlt/sessions/4c30da48-b545-404f-991d-f8007827071f

Co-authored-by: mbehr1 <3258891+mbehr1@users.noreply.github.com>
Copilot finished work on behalf of mbehr1 May 3, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants