-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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>() { |
There was a problem hiding this comment.
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>() { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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)
Only one survived.
Improved it by passing the expected packet payload size to send.