Skip to content

feat(examples): add ACF-LIN talker/listener example - #138

Open
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:feat/lin-example-21
Open

feat(examples): add ACF-LIN talker/listener example#138
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:feat/lin-example-21

Conversation

@SoundMatt

Copy link
Copy Markdown
Contributor

Closes #21

Summary

Adds a pair of Linux example applications for the ACF-LIN PDU format (IEEE Std. 1722-2016, chapter 9.4.5):

File Description
examples/acf-lin/acf-lin-talker.c Sends simulated LIN frames at 1 Hz over Ethernet or UDP
examples/acf-lin/acf-lin-listener.c Receives ACF-LIN frames and prints bus ID / identifier / payload
examples/acf-lin/CMakeLists.txt Build rules (mirrors hello-world pattern)

examples/CMakeLists.txt gains an add_subdirectory(acf-lin) inside the existing Linux-only block.

Design

Since LIN has no standard Linux socket API (unlike SocketCAN for CAN), the talker simulates LIN data — an incrementing single-byte counter — sent periodically. Both tools follow the CLI conventions of the other examples:

Talker options

  • -t/--tscf — use TSCF instead of NTSCF
  • -u/--udp — use UDP instead of Ethernet
  • -i/--ifname IFNAME — Ethernet interface
  • -d/--dst-addr MACADDR — destination MAC
  • -n/--dst-nw-addr HOST:PORT — UDP destination
  • --lin-bus-id N — LIN bus ID (0-31, default 0)
  • --lin-id N — LIN frame identifier (0-63, default 1)

Listener options

  • -u/--udp, -i/--ifname, -d/--dst-addr, -p/--udp-port

Test plan

# Build
cmake -B build && cmake --build build --target acf-lin-talker acf-lin-listener

# Run on loopback (two terminals)
./build/examples/acf-lin/acf-lin-listener -i lo -d 00:00:00:00:00:00
./build/examples/acf-lin/acf-lin-talker   -i lo -d 00:00:00:00:00:00 --lin-id 5

# UDP mode
./build/examples/acf-lin/acf-lin-listener -u -p 17220
./build/examples/acf-lin/acf-lin-talker   -u -n 127.0.0.1:17220

Add a pair of example applications demonstrating use of the ACF-LIN
PDU (IEEE Std. 1722-2016, chapter 9.4.5):

- acf-lin-talker: sends a simulated LIN frame once per second over
  Ethernet (raw TSN) or UDP, carrying a single-byte incrementing
  counter as payload.  Supports NTSCF and TSCF control formats.

- acf-lin-listener: receives ACF-LIN packets and prints the LIN bus
  ID, identifier, message timestamp, and raw payload bytes to stdout.

CLI options follow the same conventions as the other examples:
  -t/--tscf, -u/--udp, -i/--ifname, -d/--dst-addr, -n/--dst-nw-addr
  (talker); -u/--udp, -i/--ifname, -d/--dst-addr, -p/--udp-port
  (listener).

Both binaries are linked against the existing open1722 and
open1722examples libraries.  The new subdirectory is wired into the
Linux-only block in examples/CMakeLists.txt.

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@nayakned

Copy link
Copy Markdown
Collaborator

Hi @SoundMatt

Thank you for your pull request and interest in incorporating LIN examples into the Open1722 project.
However, I see that the LIN simulator replicates the transmission and reception of LIN frames.
This type of simulation is already done using the VSS listener and talker, for example. The idea of the issue (perhaps not clearly articulated there) is to integrate a real LIN driver in the talker/listener.

There is apparently LIN support in Linux kernel: https://lwn.net/Articles/916049/. Or one can use https://github.com/lin-bus/linux-lin, analogous to the socketCAN.
It would be great if we can work with real LIN frames rather than the values simulated/printed over the console which does not add a lot of value to the examples in my opinion. So I would hold off on this PR.

Currently none of us are actively looking into LIN options in Linux. Would you be interested in this, @SoundMatt?

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.

Add LIN Listener/Talker Application

3 participants