Skip to content

Add restart_ms option for automatic bus-off recovery - #1

Open
CaptChrisD wants to merge 1 commit into
protolux-electronics:mainfrom
Big-Cove:main
Open

Add restart_ms option for automatic bus-off recovery#1
CaptChrisD wants to merge 1 commit into
protolux-electronics:mainfrom
Big-Cove:main

Conversation

@CaptChrisD

Copy link
Copy Markdown

Summary

Adds a :restart_ms config option to VintageNetSocketCAN so CAN controllers can automatically recover from a bus-off condition.

When a CAN controller's transmit error counter crosses the bus-off threshold (e.g. it powers up before any other node is present to ACK its frames), it goes bus-off. With the kernel default restart-ms 0, it stays off until the interface is manually cycled — on a Nerves device that effectively means a reboot. Passing a positive restart-ms to ip link set ... type can lets the controller automatically rejoin the bus.

Changes

  • Add :restart_ms (integer) to the validated options, defaulting to 0. The default preserves existing behavior (kernel default, auto-recovery disabled).
  • Pass restart-ms <value> through to the ip link set ... type can up command.
  • Replace the placeholder test with real coverage of normalize/1 and to_raw_config/3. Tests that shell out to ip are tagged :requires_ip and auto-excluded when ip isn't on PATH.
  • Add a test-only config that redirects VintageNet's filesystem writes to a temp dir so mix test runs hermetically on a host.
  • Document the supported options in the README.

Usage

config :vintage_net,
  config: [
    {"can0",
     %{
       type: VintageNetSocketCAN,
       vintage_net_socket_can: %{
         bitrate: 250_000,
         restart_ms: 100
       }
     }}
  ]

Add a `:restart_ms` config option (default 0, preserving the kernel
default of disabled) that is passed to `ip link set ... type can` as
`restart-ms`. A positive value lets the CAN controller automatically
rejoin the bus after a bus-off condition instead of staying off until
the interface is manually cycled.

Also replace the placeholder test with real coverage of normalize/1 and
to_raw_config/3, add a hermetic test config, and document the options.

Bump version to 0.2.0.
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