Skip to contentSkip to conversation

package: add socketcan package

PATCH New kevin.joly at armadeus.com 2 participants 3 messages Apr 18, 2011 – Apr 20, 2011 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package: add socketcan package

From: Kevin JOLY <[email protected]>

---
 package/Config.in              |    1 +
 package/socketcan/Config.in    |   15 +++++++++++++++
 package/socketcan/socketcan.mk |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 package/socketcan/Config.in
 create mode 100644 package/socketcan/socketcan.mk
package/Config.in +1 -0
index 014c2c0..f41d915 100644
@@ -427,6 +427,7 @@ source "package/rsync/Config.in"
 source "package/samba/Config.in"
 source "package/ser2net/Config.in"
 source "package/socat/Config.in"
+source "package/socketcan/Config.in"
 source "package/spawn-fcgi/Config.in"
 source "package/squid/Config.in"
 source "package/tcpdump/Config.in"
package/socketcan/Config.in new file +15 -0
new file mode 100644
index 0000000..e8d7a39
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_SOCKETCAN
+	bool "Socket CAN"
+	help
+	  The socketcan package is an implementation of CAN protocols
+	  (Controller Area Network) for Linux. CAN is a networking technology
+	  which has wide-spread use in automation, embedded devices, and
+	  automotive fields.
+
+	  While there have been other CAN implementations for Linux based on
+	  character devices, Socket CAN uses the Berkeley socket API,
+	  the Linux network stack and implements the CAN device drivers as
+	  network interfaces.  The CAN socket API has been designed as similar
+	  as possible to the TCP/IP protocols to allow programmers, familiar
+	  with network programming, to easily learn how to use CAN sockets.
+
package/socketcan/socketcan.mk new file +33 -0
new file mode 100644
index 0000000..ee8efc0
@@ -0,0 +1,33 @@
+#############################################################
+#
+# Socket CAN
+#
+#############################################################
+PROGRAMS_ISOTP = isotpdump,isotprecv,isotpsend,isotpsniffer,isotptun,isotpserver
+PROGRAMS_CANGW = cangw
+PROGRAMS_SLCAN = slcan_attach,slcand
+PROGRAMS_CAN_UTILS = can-calc-bit-timing,candump,cansniffer,cansend,canplayer,cangen,canbusload,log2long,log2asc,asc2log,canlogserver,bcmserver,slcanpty,canfdtest
+PROGRAMS = {$(PROGRAMS_ISOTP),$(PROGRAMS_CANGW),$(PROGRAMS_SLCAN),$(PROGRAMS_CAN_UTILS)}
+SOCKETCAN_VERSION = 1235
+SOCKETCAN_SOURCE = socketcan-svn-rev$(SOCKETCAN_VERSION).tar.gz
+SOCKETCAN_SITE = http://svn.berlios.de/svnroot/repos/socketcan/trunk/
+SOCKETCAN_SITE_METHOD = svn
+
+define SOCKETCAN_BUILD_CMDS
+	$(MAKE) -C $(SOCKETCAN_DIR)/can-utils CC="$(TARGET_CC)"
+endef
+
+define SOCKETCAN_INSTALL_TARGET_CMDS
+	$(MAKE) DESTDIR=$(TARGET_DIR) -C $(SOCKETCAN_DIR)/can-utils install
+	$(TARGET_STRIP) $(TARGET_DIR)/usr/local/bin/$(PROGRAMS)
+endef
+
+define SOCKETCAN_CLEAN_CMDS
+	$(MAKE) -C $(SOCKETCAN_DIR)/can-utils clean
+endef
+
+define SOCKETCAN_UNINSTALL_TARGET_CMDS
+	rm -rf $(SOCKETCAN_DIR)
+endef
+
+$(eval $(call GENTARGETS,package,socketcan))
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 package: add socketcan package

Hello Kevin,

Thanks for this submission. A couple of comments below.

Quoted 10 lines · On Mon, 18 Apr 2011 18:52:40 +0200 kevin.joly at armadeus.com wrote:
package/socketcan/Config.in new file +4 -0
new file mode 100644
index 0000000..e8d7a39
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_SOCKETCAN
+	bool "Socket CAN"
+	help
+	  The socketcan package is an implementation of CAN protocols

package/socketcan/Config.in line 14

Quoted 10 lines
package/socketcan/Config.in new file +10 -0
+	  (Controller Area Network) for Linux. CAN is a networking technology
+	  which has wide-spread use in automation, embedded devices, and
+	  automotive fields.
+
+	  While there have been other CAN implementations for Linux based on
+	  character devices, Socket CAN uses the Berkeley socket API,
+	  the Linux network stack and implements the CAN device drivers as
+	  network interfaces.  The CAN socket API has been designed as similar
+	  as possible to the TCP/IP protocols to allow programmers, familiar
+	  with network programming, to easily learn how to use CAN sockets.

Maybe this package should be called SOCKETCANUTILS or something like that ? It isn't the Socket CAN implementation by itself, since that thing is inside the kernel.

Moreover, we typically insert the project URL as a last line of the help text.

package/socketcan/Config.in line 10

Quoted 11 lines
package/socketcan/Config.in new file +10 -0
@@ -0,0 +1,33 @@
+#############################################################
+#
+# Socket CAN
+#
+#############################################################
+PROGRAMS_ISOTP = isotpdump,isotprecv,isotpsend,isotpsniffer,isotptun,isotpserver
+PROGRAMS_CANGW = cangw
+PROGRAMS_SLCAN = slcan_attach,slcand
+PROGRAMS_CAN_UTILS = can-calc-bit-timing,candump,cansniffer,cansend,canplayer,cangen,canbusload,log2long,log2asc,asc2log,canlogserver,bcmserver,slcanpty,canfdtest
+PROGRAMS = {$(PROGRAMS_ISOTP),$(PROGRAMS_CANGW),$(PROGRAMS_SLCAN),$(PROGRAMS_CAN_UTILS)}

This program list is only used for stripping and it's useless, see below.

package/socketcan/Config.in line 18

Quoted 8 lines
package/socketcan/Config.in new file +8 -0
+SOCKETCAN_VERSION = 1235
+SOCKETCAN_SOURCE = socketcan-svn-rev$(SOCKETCAN_VERSION).tar.gz
+SOCKETCAN_SITE = http://svn.berlios.de/svnroot/repos/socketcan/trunk/
+SOCKETCAN_SITE_METHOD = svn
+
+define SOCKETCAN_BUILD_CMDS
+	$(MAKE) -C $(SOCKETCAN_DIR)/can-utils CC="$(TARGET_CC)"
+endef

Replace $(SOCKETCAN_DIR) with $(@D).

If you pass TARGET_CC, you also probably want to pass TARGET_CFLAGS somehow, so that the code gets compiled for the proper sub-architecture.

package/socketcan/Config.in line 20

Quoted 2 lines
package/socketcan/Config.in new file +2 -0
+define SOCKETCAN_INSTALL_TARGET_CMDS
+	$(MAKE) DESTDIR=$(TARGET_DIR) -C $(SOCKETCAN_DIR)/can-utils install

SOCKETCAN_DIR -> @D

package/socketcan/Config.in line 21

Quoted 1 line
package/socketcan/Config.in new file +1 -0
+	$(TARGET_STRIP) $(TARGET_DIR)/usr/local/bin/$(PROGRAMS)

This is not needed, Buildroot will automagically strip all binaries from the target filesystem. So just remove this line.

However, I see that things are installed into usr/local/bin in the target filesystem, which is unusual. Could you tweak the think so that it gets installed in usr/bin ?

package/socketcan/Config.in line 28

Quoted 7 lines
package/socketcan/Config.in new file +7 -0
+define SOCKETCAN_CLEAN_CMDS
+	$(MAKE) -C $(SOCKETCAN_DIR)/can-utils clean
+endef
+
+define SOCKETCAN_UNINSTALL_TARGET_CMDS
+	rm -rf $(SOCKETCAN_DIR)
+endef

@D and @D here as well.

Thanks again!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 package: add socketcan package

Hello,

Please keep the list in Cc.

Quoted 4 lines · On Wed, 20 Apr 2011 09:18:23 +0200 JOLY <[email protected]> wrote:

Thanks for your reply. I will correct that but I can't change the install location (/usr/local/bin) because there is no options in the makefile of socketcan-utils, we can choose the target root but not the directory to install the binaries.

You can make a one-line patch to can-utils/Makefile to change

PREFIX = /usr/local

to

PREFIX ?= /usr/local

and then pass "PREFIX=/usr" at make install.

This patch could be submitted to the upstream SocketCAN project, but in the mean time, you can add it to the package directory in Buildroot.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com