Repository navigation
Conversation
…he next one The receive loop kept unparsed bytes in a static buffer between datagrams and never reset its read index after moving leftover bytes to the front. A packet shorter than 8 bytes (AOG's 7-byte section control request, PGN 241) waited in the buffer for the next datagram, and the packet after it was then read from the wrong offset, logged as "Unknown start of message" and dropped. It also read the 2 start bytes with two unsequenced index++ in one expression, and did not check that a whole packet was present before handing it on. AgIO never splits a packet across datagrams, so each datagram is now parsed on its own by aog_packet::parse_datagram (header-only, unit tested), shared by the AOG and address detection sockets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The field log showed datagrams with 2 or 4 bytes after a complete packet, and others that are not AOG packets at all (one starts with "$P"). The log only said how many bytes were dropped, so the sender could not be identified. Log the sender's address and port, and up to 64 bytes as hex with a "|" where parsing stopped, followed by the printable characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The AOG UDP receive loop kept unparsed bytes in a static buffer between datagrams, and didn't reset its read index after moving leftover bytes to the front. A packet shorter than 8 bytes waited in the buffer for the next datagram; AOG's section control request (PGN 241) is 7 bytes. The packet after it was then read from the wrong offset, logged as
Unknown start of messageand dropped.Other problems in the same loop:
index++in one expression;indexwas astd::uint8_t.Changes
aog_packet::parse_datagram()(include/aog_packet_parser.hpp). It passes every complete packet in one datagram to a callback, and reports whether it stopped on an unknown start or a truncated packet, and where.handle_incoming_packets()andhandle_address_detection()both use it. The log line now says how many bytes of the datagram were dropped.tools/test_aog_packet_parser.cppcovers the field case (a 7-byte PGN 241 followed by a PGN 229), several packets in one datagram, an unknown start after a valid packet, truncated packets and empty packets. It is registered liketest_async_log.Notes
parse_datagram().Testing
test_aog_packet_parserpasses (MSVC and clang).🤖 Generated with Claude Code