[v7,4/5] package/canvenient: new package

Message ID 20261125161404.859000-5-dario.binacchi@amarulasolutions.com
State New
Headers
Series package: add CANopenterm and dependencies |

Commit Message

Dario Binacchi Nov. 25, 2026, 4:14 p.m. UTC
CANvenient is an abstraction layer for multiple CAN APIs on Windows and
Linux. It provides a unified interface for CAN communication, allowing
developers to write code that is portable across different platforms and
CAN hardware.

Project page: https://github.com/CANopenTerm/CANvenient

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 .../canvenient/0001-Fix-build-with-musl.patch | 43 +++++++++++++++++++
 package/canvenient/Config.in                  | 13 ++++++
 package/canvenient/canvenient.hash            |  3 ++
 package/canvenient/canvenient.mk              | 14 ++++++
 6 files changed, 75 insertions(+)
 create mode 100644 package/canvenient/0001-Fix-build-with-musl.patch
 create mode 100644 package/canvenient/Config.in
 create mode 100644 package/canvenient/canvenient.hash
 create mode 100644 package/canvenient/canvenient.mk

-- 
2.43.0
  

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index b98c85996f97..88d5ff1b7080 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -828,6 +828,7 @@  F:	package/armadillo/
 F:	package/atf/
 F:	package/babeld/
 F:	package/bc/
+F:	package/canvenient/
 F:	package/cmocka/
 F:	package/connman/
 F:	package/drogon/
diff --git a/package/Config.in b/package/Config.in
index 03267168a667..76d2743430ad 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2013,6 +2013,7 @@  menu "Networking"
 	source "package/batman-adv/Config.in"
 	source "package/bluez5_utils-headers/Config.in"
 	source "package/c-ares/Config.in"
+	source "package/canvenient/Config.in"
 	source "package/cni-plugins/Config.in"
 	source "package/cpp-httplib/Config.in"
 	source "package/cppzmq/Config.in"
diff --git a/package/canvenient/0001-Fix-build-with-musl.patch b/package/canvenient/0001-Fix-build-with-musl.patch
new file mode 100644
index 000000000000..cc8c7cfa0c55
--- /dev/null
+++ b/package/canvenient/0001-Fix-build-with-musl.patch
@@ -0,0 +1,43 @@ 
+From 46ac90d46b7773a804cd0bbaf71fa487bcc4cca8 Mon Sep 17 00:00:00 2001
+From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
+Date: Sat, 22 Aug 2026 17:38:47 +0200
+Subject: [PATCH] Fix build with musl
+
+This was exposed while integrating the package into Buildroot and
+testing its compilation with a musl-based toolchain:
+
+  CANvenient_SocketCAN.c: In function 'socketcan_open':
+  CANvenient_SocketCAN.c:186:24: error: storage size of 'tv' isn't known
+    186 |         struct timeval tv;
+        |                        ^~
+  CANvenient_SocketCAN.c: In function 'socketcan_recv':
+  CANvenient_SocketCAN.c:364:36: error: invalid application of 'sizeof' to incomplete type 'struct timeval'
+    364 |     char ctrlmsg[CMSG_SPACE(sizeof(struct timeval))];
+        |                                    ^~~~~~
+  CANvenient_SocketCAN.c:406:28: error: invalid use of undefined type 'const struct timeval'
+    406 |             *timestamp = tv->tv_sec * 1000000ULL + tv->tv_usec;
+        |                            ^~
+
+Include <sys/time.h> to fix the build.
+
+Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
+Upstream: https://github.com/CANopenTerm/CANvenient/commit/46ac90d46b7773a804cd0bbaf71fa487bcc4cca8
+---
+ src/drivers/CANvenient_SocketCAN.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/drivers/CANvenient_SocketCAN.c b/src/drivers/CANvenient_SocketCAN.c
+index d4db584ff51d..fb356b8f227f 100644
+--- a/src/drivers/CANvenient_SocketCAN.c
++++ b/src/drivers/CANvenient_SocketCAN.c
+@@ -20,6 +20,7 @@ void socketcan_close(int index);
+ #include <dirent.h>
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
++#include <sys/time.h>
+ #include <net/if.h>
+ #include <linux/can.h>
+ #include <linux/can/raw.h>
+-- 
+2.43.0
+
diff --git a/package/canvenient/Config.in b/package/canvenient/Config.in
new file mode 100644
index 000000000000..6989bf496ef3
--- /dev/null
+++ b/package/canvenient/Config.in
@@ -0,0 +1,13 @@ 
+config BR2_PACKAGE_CANVENIENT
+	bool "canvenient"
+	depends on !BR2_STATIC_LIBS
+	select BR2_PACKAGE_LIBSOCKETCAN
+	help
+	  CANvenient is a portable CAN abstraction library
+	  supporting several driver backends. On Linux it is
+	  implemented on top of SocketCAN.
+
+	  https://github.com/CANopenTerm/CANvenient
+
+comment "canvenient needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
diff --git a/package/canvenient/canvenient.hash b/package/canvenient/canvenient.hash
new file mode 100644
index 000000000000..32b5559d3503
--- /dev/null
+++ b/package/canvenient/canvenient.hash
@@ -0,0 +1,3 @@ 
+# Locally computed
+sha256  dae4c0a4b6a2b62220341466509a57d9a10ee5cc60be5a2def42d0afd345dc41  canvenient-1.02.tar.gz
+sha256  877e5e09cf4243583c7b0593d1453343f6e8d67977e3e4e97ed001dd0856a334  LICENSE.md
diff --git a/package/canvenient/canvenient.mk b/package/canvenient/canvenient.mk
new file mode 100644
index 000000000000..68b5af3dcc4d
--- /dev/null
+++ b/package/canvenient/canvenient.mk
@@ -0,0 +1,14 @@ 
+################################################################################
+#
+# canvenient
+#
+################################################################################
+
+CANVENIENT_VERSION = 1.02
+CANVENIENT_SITE = $(call github,CANopenTerm,CANvenient,v$(CANVENIENT_VERSION))
+CANVENIENT_LICENSE = MIT
+CANVENIENT_LICENSE_FILES = LICENSE.md
+CANVENIENT_INSTALL_STAGING = YES
+CANVENIENT_DEPENDENCIES = libsocketcan
+
+$(eval $(cmake-package))