Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and refactoring of PcapStreamer #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix and refactoring of PcapStreamer #145

wants to merge 3 commits into from

Conversation

gbin
Copy link
Collaborator

@gbin gbin commented Dec 11, 2024

Only one survived.

Improved it by passing the expected packet payload size to send.

@@ -235,7 +165,8 @@ mod tests {

xt32.reftime = (datetime, clock.now());

while streamer.send_next() {
// 1076 is the expected payload size for Hesai XT32
while streamer.send_next::<1076>() {
Copy link

Choose a reason for hiding this comment

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

Not a fan of magic static value, since its statically deductible from packet struct with a size_of::<lidar_parser::Packet>

let socket = UdpSocket::bind("0.0.0.0:2367").unwrap();
socket.send_to(data, "127.0.0.1:2368").unwrap();
// process
if streamer.send_next::<1206>() {
Copy link

Choose a reason for hiding this comment

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

same remark

@@ -0,0 +1,14 @@
[package]
name = "cu-udpinject"
Copy link

Choose a reason for hiding this comment

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

cu-udp-inject and cu_udp_inject in project would be better consistant with other packages (and easier to read)

let payload_offset = 42;

// Extract only the payload, excluding headers and trailing FCS if present
let payload = &packet.data[payload_offset..payload_offset + PS];
Copy link

Choose a reason for hiding this comment

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

A test is missing : if the packet is smaller than expected, the slicing will panick (case occurs mix a traffic of mixed size packets)

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.

2 participants