Skip to content

V2.2.1 - #130

Open
RainerZ wants to merge 96 commits into
vectorgrp:masterfrom
RainerZ:V2.2.1
Open

V2.2.1#130
RainerZ wants to merge 96 commits into
vectorgrp:masterfrom
RainerZ:V2.2.1

Conversation

@RainerZ

@RainerZ RainerZ commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

XCP on UDP - RAW ethernet and CMP HAL support

Replaced fragile definition of _GNU_SOURCE in platform.h with a guard
…API header files. Requires XCPLITE_CONFIGURATION and XCPLIB_CFG_OVERRIDE to be public in CMakeLists.txt.
RainerZ and others added 30 commits September 3, 2026 01:21
Prepares for backends which do not belong in this library, in particular an ASAM
CMP implementation for testing XCP tools through capture modules. Until now such
a backend was not possible without patching xcplib: the HAL interface header was
not installed, and the backend was selected purely by platform, so a CMP backend
on Linux could neither be selected nor coexist with the AF_PACKET one.
…kends

The raw transport does not fragment IPv4, so one segment must fit into one
frame and an oversized frame can only be refused. At 1504 a full segment is
already 1514 bytes and fills a 1500 byte path on its own, leaving nothing for
a backend which wraps the frame before putting it on the wire - an out of tree
backend (OPTION_UDP_RAW_HAL_EXTERNAL) adding a header of its own then cannot
send full size segments at all.

  OPTION_MTU              1424
  XCPTL_MAX_SEGMENT_SIZE  1392  (%8)
  largest frame           1434  (42 + segment)
  as an IP packet         1496  (fits 1500 with 4 bytes to spare)

This applies to the whole raw configuration, so udp_raw_demo now sends
segments of 1392 instead of 1472 bytes.
ASAM CMP 12 requires at least one of three approaches to address configuration
and discovery, and "static configuration without Capture Module Discovery" is
one of them - so this was optional. 12.1 is the cheap one: the request is an
ordinary XCP packet in the ordinary XCP on Ethernet transport header, command
0xF2 (CC_TRANSPORT_LAYER_CMD), sub command 0x10, multicast to 239.255.0.0:5556.
The answer carries the HTTP port, which is the point of the whole exchange:
discovery hands the tool the REST interface it then configures the module
through. See docs/XCP_DISCOVERY.md for the XCP side of the same mechanism.

Nothing CMP specific in libxcplite. The response advertises an HTTP port for a
REST interface, which the library has no business knowing, and the library's own
multicast code is unusable here anyway - SOCKET_RAW.md excludes
XCPTL_ENABLE_MULTICAST from the raw transport because socketJoin is not
implemented there. Own socket, own group, own datagram.

No thread of its own: the REST thread was already in a poll() loop and already
knows the HTTP port the response has to advertise, so it now polls two fds.
--no-discovery turns it off.

Three things learned the hard way, all in the code comments:

  - imr_interface = INADDR_ANY does not mean "all interfaces", it lets the stack
    pick one, and on macOS such a join receives nothing at all.
    cmpDiscoveryStart enumerates interfaces and joins each. Loopback is
    deliberately included: a process does not see its own multicast sent via a
    LAN interface, so that is what makes a same-host test possible.
  - A multicast reply needs IP_MULTICAST_IF set per response, or it leaves via
    the default route and the tool that asked never sees it.
  - The multicast RETURN path is filtered far more often than the request path.
    Between a Wi-Fi laptop and a wired Pi the request arrives and is answered,
    and the answer never comes back. 12.1 says the response destination is
    "given by the request", so discovery_probe.py asks both ways and reports
    which worked; the responder honours whatever address it is given.

Table 79 contradicts itself by one about where DeviceDescription ends. N is
taken as the padded byte count ("Dev1" -> 6, "" -> 2), on the strength of the
identical construction in 8.2.1 whose wording is "N is length before". A tool
reading N as a character count mis-parses everything after that field.

discovery_probe.py plays the Data Sink: sweeps interfaces, tries both reply
paths, and deduplicates by SerialNumber, since one module answering over five
routes is one module. Wired into both test scripts.

Verified on macOS over loopback and on a Raspberry Pi 5 over the LAN: codec
74/74, REST, discovery, and XCP CONNECT through the tunnel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
xcpclient: Build warnings removed, README.md updated
    - Improved variable registration for global and static variables
    - Global variables and local static variables in functions without event trigger are registered, but not associated to any specific default DAQ event
    - no_a2l_demo, no_a2l_demo_cpp: more demo cases
… scopes (ELF->A2L)

- Struct/class types with the same DWARF name in different namespaces, classes or
  functions get scope qualified typedef names (motor_control.Input, valve_control.Input).
  Previously all variables of such types referenced the first registered typedef and
  were shown with the wrong type.
- Typedefs with identical content are merged (same type in several compilation units),
  a name still used by different content gets a numeric suffix. A type used for
  measurement and for calibration variables gets separate typedefs.
- Global variables with the same name in different namespaces get namespace qualified
  instance names instead of being dropped as duplicates.
- GCC declaration/definition entry pairs of namespace scope variables are merged.
- Symbol table address resolution: mangled names for namespace scope statics without
  DWARF location, only local symbols for function local variables (no more stack
  variables mapped onto same-named globals).
- Metadata macros in the same namespace or function as the variable need no scope
  prefix (XCP_COMMENT(input, ...) in namespace motor_control annotates
  motor_control.input), explicit prefixes keep working. Metadata for typedef fields
  of namespace qualified instances.
- Fixture cpp_namespaces.elf and unit tests, README, TECHNICAL.md and CHANGELOG updated.
- no_a2l_demo_cpp: same-named types and variables in namespaces with XCP_COMMENT,
  volatile test_array, regenerated CANape A2L/ELF.
- xcpclient version 3.0.10

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…fixtures and tests

- DebugData::qualified_type_names is filled once after the types are loaded: it follows
  const/volatile qualifiers to the named type, finds the names used in more than one
  scope and stores the dotted name for those types only. DebugData::get_type_name
  returns it or the plain DWARF name; register_struct keeps only the content
  signature and the numeric suffix. No change in the generated A2L files.
- cpp_namespaces.cpp: volatile and const qualified variables of the colliding Input types
- c_local_types_a.c/_b.c: struct tags with the same name but different content in two
  compilation units, registered as state and state_1
- cpp_type_name_collisions.cpp: fixture contributed with pull request
  vectorgrp#126
- Unit tests for the three fixtures and for the qualified names at DWARF level

Co-Authored-By: Pamir Mundt and Claude Fable 5.1
TECHNICAL.md restructured
Different READMEs updated
xcpclient: Build warnings removed, README.md updated
    - Improved variable registration for global and static variables
    - Global variables and local static variables in functions without event trigger are registered, but not associated to any specific default DAQ event
    - no_a2l_demo, no_a2l_demo_cpp: more demo cases
… scopes (ELF->A2L)

- Struct/class types with the same DWARF name in different namespaces, classes or
  functions get scope qualified typedef names (motor_control.Input, valve_control.Input).
  Previously all variables of such types referenced the first registered typedef and
  were shown with the wrong type.
- Typedefs with identical content are merged (same type in several compilation units),
  a name still used by different content gets a numeric suffix. A type used for
  measurement and for calibration variables gets separate typedefs.
- Global variables with the same name in different namespaces get namespace qualified
  instance names instead of being dropped as duplicates.
- GCC declaration/definition entry pairs of namespace scope variables are merged.
- Symbol table address resolution: mangled names for namespace scope statics without
  DWARF location, only local symbols for function local variables (no more stack
  variables mapped onto same-named globals).
- Metadata macros in the same namespace or function as the variable need no scope
  prefix (XCP_COMMENT(input, ...) in namespace motor_control annotates
  motor_control.input), explicit prefixes keep working. Metadata for typedef fields
  of namespace qualified instances.
- Fixture cpp_namespaces.elf and unit tests, README, TECHNICAL.md and CHANGELOG updated.
- no_a2l_demo_cpp: same-named types and variables in namespaces with XCP_COMMENT,
  volatile test_array, regenerated CANape A2L/ELF.
- xcpclient version 3.0.10

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…fixtures and tests

- DebugData::qualified_type_names is filled once after the types are loaded: it follows
  const/volatile qualifiers to the named type, finds the names used in more than one
  scope and stores the dotted name for those types only. DebugData::get_type_name
  returns it or the plain DWARF name; register_struct keeps only the content
  signature and the numeric suffix. No change in the generated A2L files.
- cpp_namespaces.cpp: volatile and const qualified variables of the colliding Input types
- c_local_types_a.c/_b.c: struct tags with the same name but different content in two
  compilation units, registered as state and state_1
- cpp_type_name_collisions.cpp: fixture contributed with pull request
  vectorgrp#126
- Unit tests for the three fixtures and for the qualified names at DWARF level

Co-Authored-By: Pamir Mundt and Claude Fable 5.1
TECHNICAL.md restructured
Different READMEs updated
# Conflicts:
#	CHANGELOG.md
#	src/platform.c
Fixed older protocol layer versions
Restore dropped the CMP CHANGELOG entries
Changed several places still describing the old MTU convention
Added MTU check to lwip sendto

Version aligned to 2.2.1 in CMakeLists.txt and in OPTION_VERSION_MAJOR/_MINOR/_PATCH in xcplib_cfg.h
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.

1 participant