Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/posix/native_posix/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ config NET_L2_ETHERNET
config ETH_NATIVE_POSIX
default y if NET_L2_ETHERNET

config CAN_NATIVE_POSIX
default y if NET_SOCKETS_CAN

endif # NETWORKING

config FAKE_ENTROPY_NATIVE_POSIX
Expand Down
20 changes: 20 additions & 0 deletions boards/posix/native_posix/native_posix.dts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@
current-speed = <0>;
};

can1: can_1 {
status = "okay";
compatible = "zephyr,native-posix-can";
label = "CAN_1";
/* Dummy bus-speed entry to comply with can
* DTS binding
*/
bus-speed = <500000>;
};

can2: can_2 {
status = "okay";
compatible = "zephyr,native-posix-can";
label = "CAN_2";
/* Dummy bus-speed entry to comply with can
* DTS binding
*/
bus-speed = <500000>;
};

rng: rng {
status = "okay";
compatible = "zephyr,native-posix-rng";
Expand Down
12 changes: 12 additions & 0 deletions drivers/can/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ zephyr_sources_ifdef(CONFIG_CAN_RCAR can_rcar.c)
zephyr_sources_ifdef(CONFIG_USERSPACE can_handlers.c)
zephyr_sources_ifdef(CONFIG_CAN_SHELL can_shell.c)
zephyr_sources_ifdef(CONFIG_CAN_NET can_net.c)

if(CONFIG_CAN_NATIVE_POSIX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick comment: socket CAN is only available on Linux, so I think a name other than "native_posix" should be used. The build should only be available on Linux hosts actually (maybe CMAKE_HOST_SYSTEM_NAME can be useful here?)

zephyr_library()
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/l2)
zephyr_library_compile_definitions(NO_POSIX_CHEATS)
zephyr_library_compile_definitions(_BSD_SOURCE)
zephyr_library_compile_definitions(_DEFAULT_SOURCE)
zephyr_library_sources(
can_native_posix.c
can_native_posix_adapt.c
)
endif()
1 change: 1 addition & 0 deletions drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ source "drivers/can/Kconfig.mcan"
source "drivers/can/Kconfig.rcar"
source "drivers/can/Kconfig.loopback"
source "drivers/can/Kconfig.net"
source "drivers/can/Kconfig.native_posix"

endif # CAN
71 changes: 71 additions & 0 deletions drivers/can/Kconfig.native_posix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Native posix CAN configuration options

# Copyright (c) 2019 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

config CAN_NATIVE_POSIX
bool "native_posix CAN Driver"
depends on ARCH_POSIX && NETWORKING
help
Enable native_posix CAN driver

if CAN_NATIVE_POSIX

config CAN_MAX_FILTER
int "Maximum number of concurrent active filters"
depends on CAN_NATIVE_POSIX
default 32
range 1 56
help
Defines the array size of the callback/msgq pointers.
Must be at least the size of concurrent reads.

## Interface 1
config CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
bool "CANBUS interface 1"
default y
depends on CAN_NATIVE_POSIX
help
This option enables the CANBUS network interface for Native POSIX board.

config CAN_NATIVE_POSIX_INTERFACE_1_NAME
string "CANBUS interface 1 name on Linux side"
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
default "vcan0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeviceTree can likely be used for that

help
This option sets the CANBUS network interface 1 name in host system.

config CAN_NATIVE_POSIX_INTERFACE_1_SOCKETCAN_NAME
string "Network device name"
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
default "SOCKET_CAN_1"
help
Name of the network device driver for SocketCAN.

## Interface 2
config CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
bool "CANBUS interface 2"
default n
depends on CAN_NATIVE_POSIX
help
This option enables the CANBUS network interface for Native POSIX board.

if CAN_NATIVE_POSIX_INTERFACE_2_ENABLED

config CAN_NATIVE_POSIX_INTERFACE_2_NAME
string "CANBUS interface 2 name on Linux side"
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
default "vcan1"
help
This option sets the CANBUS network interface 2 name in host system.

config CAN_NATIVE_POSIX_INTERFACE_2_SOCKETCAN_NAME
string "Network device name"
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
default "SOCKET_CAN_2"
help
Name of the network device driver for SocketCAN.

endif #CAN_NATIVE_POSIX_INTERFACE_2_ENABLED

endif #CAN_NATIVE_POSIX
Loading