canutils: Update to 2025.01
authorTianling Shen <[email protected]>
Wed, 12 Nov 2025 09:41:49 +0000 (17:41 +0800)
committerHannu Nyman <[email protected]>
Wed, 12 Nov 2025 17:10:09 +0000 (19:10 +0200)
Update build targets and backport an upstream fix for missing header.

Changelog: https://github.com/linux-can/can-utils/releases/tag/v2025.01

Signed-off-by: Tianling Shen <[email protected]>
utils/canutils/Makefile
utils/canutils/patches/010-Include-time-h-for-timespec-struct-definition.patch [new file with mode: 0644]
utils/canutils/patches/010-time.h [deleted file]

index 109ec99685da7ede7d9f838445e9b6e5b14ae18f..ac7fa29251bffc1a6ef918add2420a22e2a0124a 100644 (file)
@@ -8,13 +8,13 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=canutils
-PKG_VERSION:=2023.03
+PKG_VERSION:=2025.01
 PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_VERSION:=v$(PKG_VERSION)
 PKG_SOURCE_URL:=https://github.com/linux-can/can-utils
-PKG_MIRROR_HASH:=bea66321c9cea53f44ace2357ca3829a77dbf5d399a09ed0798a659d682d1afa
+PKG_MIRROR_HASH:=d7941dba33718b6375afef1202491d065355ad361c6fda0aa464260012a1d67d
 
 PKG_MAINTAINER:=Anton Glukhov <[email protected]>
 PKG_LICENSE:=GPL-2.0-or-later
@@ -48,11 +48,12 @@ define GenPlugin
 endef
 
 FILES:= \
-       asc2log bcmserver canbusload \
+       asc2log bcmserver canbusload can-calc-bit-timing \
        candump canfdtest cangen cangw canlogserver canplayer \
-       cansend cansniffer isotpdump isotpperf isotprecv isotpsend \
-       isotpserver isotpsniffer isotptun j1939acd j1939cat j1939spy j1939sr \
-       log2asc log2long slcan_attach slcand slcanpty testj1939
+       cansend cansequence cansniffer isotpdump isotpperf isotprecv \
+       isotpsend isotpserver isotpsniffer isotptun j1939acd j1939cat \
+       j1939spy j1939sr j1939-timedate-cli j1939-timedate-srv log2asc \
+       log2long mcp251xfd-dump slcan_attach slcand slcanpty testj1939
 
 $(foreach a,$(FILES),$(eval $(call GenPlugin,$(a))))
 
diff --git a/utils/canutils/patches/010-Include-time-h-for-timespec-struct-definition.patch b/utils/canutils/patches/010-Include-time-h-for-timespec-struct-definition.patch
new file mode 100644 (file)
index 0000000..9710e06
--- /dev/null
@@ -0,0 +1,24 @@
+From 2b8c7c5f4b71726806de0d718c4c56eeba2c7332 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 13 Feb 2025 22:14:47 -0800
+Subject: [PATCH] Include time.h for timespec struct definition
+
+Fixes
+git/isobusfs/../libj1939.h:33:18: error: field has incomplete type 'struct timespec'
+   33 |         struct timespec next_send_time;
+      |                         ^
+Signed-off-by: Khem Raj <[email protected]>
+---
+ libj1939.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/libj1939.h
++++ b/libj1939.h
+@@ -17,6 +17,7 @@
+ #include <linux/can/j1939.h>
+ #include <stdbool.h>
+ #include <stdint.h>
++#include <time.h>
+ #include <sys/socket.h>
+ #ifndef J1939_LIB_H
diff --git a/utils/canutils/patches/010-time.h b/utils/canutils/patches/010-time.h
deleted file mode 100644 (file)
index 08d4c23..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-From ceda93bd5c56927c72d48dcaa30e17d6ecea86b8 Mon Sep 17 00:00:00 2001
-From: TyK <[email protected]>
-Date: Mon, 27 Nov 2023 10:59:21 +0800
-Subject: [PATCH] timestamp formatting: always use 64-bit for timesstamp
- formatting.
-
-Using C99 `unsigned long long` to format `struct timeval`'s `tv_sec`
-and `tv_usec`, fix incorrect print under some 32bit platform which
- using time64.
----
- asc2log.c      | 38 +++++++++++++++++++++++---------------
- candump.c      |  6 +++---
- canlogserver.c |  4 ++--
- canplayer.c    |  9 +++++++--
- isotpdump.c    |  8 ++++----
- isotpperf.c    |  4 ++--
- isotpsniffer.c |  6 +++---
- j1939cat.c     |  4 ++--
- j1939spy.c     |  6 +++---
- log2asc.c      | 11 +++++++----
- slcanpty.c     |  4 ++--
- 11 files changed, 58 insertions(+), 42 deletions(-)
-
---- a/asc2log.c
-+++ b/asc2log.c
-@@ -73,7 +73,7 @@ void print_usage(char *prg)
- void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, unsigned int max_dlen, char *extra_info) {
--      fprintf(file, "(%lu.%06lu) ", tv->tv_sec, tv->tv_usec);
-+      fprintf(file, "(%llu.%06llu) ", (unsigned long long)tv->tv_sec, (unsigned long long)tv->tv_usec);
-       if (dev > 0)
-               fprintf(file, "can%d ", dev-1);
-@@ -141,11 +141,14 @@ void eval_can(char* buf, struct timeval
-       char dir[3]; /* 'Rx' or 'Tx' plus terminating zero */
-       char *extra_info;
-       int i, items;
-+      unsigned long long sec, usec;
-       /* check for ErrorFrames */
--      if (sscanf(buf, "%lu.%lu %d %s",
--                 &read_tv.tv_sec, &read_tv.tv_usec,
-+      if (sscanf(buf, "%llu.%llu %d %s",
-+                 &sec, &usec,
-                  &interface, tmp1) == 4) {
-+              read_tv.tv_sec = sec;
-+              read_tv.tv_usec = usec;
-               if (!strncmp(tmp1, "ErrorFrame", strlen("ErrorFrame"))) {
-@@ -165,18 +168,20 @@ void eval_can(char* buf, struct timeval
-       /* check for CAN frames with (hexa)decimal values */
-       if (base == 'h')
--              items = sscanf(buf, "%lu.%lu %d %s %2s %c %x %x %x %x %x %x %x %x %x",
--                             &read_tv.tv_sec, &read_tv.tv_usec, &interface,
-+              items = sscanf(buf, "%llu.%llu %d %s %2s %c %x %x %x %x %x %x %x %x %x",
-+                             &sec, &usec, &interface,
-                              tmp1, dir, &rtr, &dlc,
-                              &data[0], &data[1], &data[2], &data[3],
-                              &data[4], &data[5], &data[6], &data[7]);
-       else
--              items = sscanf(buf, "%lu.%lu %d %s %2s %c %x %d %d %d %d %d %d %d %d",
--                             &read_tv.tv_sec, &read_tv.tv_usec, &interface,
-+              items = sscanf(buf, "%llu.%llu %d %s %2s %c %x %d %d %d %d %d %d %d %d",
-+                             &sec, &usec, &interface,
-                              tmp1, dir, &rtr, &dlc,
-                              &data[0], &data[1], &data[2], &data[3],
-                              &data[4], &data[5], &data[6], &data[7]);
-+      read_tv.tv_sec = sec;
-+      read_tv.tv_usec = usec;
-       if (items < 7 ) /* make sure we've read the dlc */
-               return;
-@@ -246,6 +251,7 @@ void eval_canfd(char* buf, struct timeva
-       char *extra_info;
-       char *ptr;
-       int i;
-+      unsigned long long sec, usec;
-       /* The CANFD format is mainly in hex representation but <DataLength>
-          and probably some content we skip anyway. Don't trust the docs! */
-@@ -255,19 +261,21 @@ void eval_canfd(char* buf, struct timeva
-          100000  214   223040 80000000 46500250 460a0250 20011736 20010205 */
-       /* check for valid line without symbolic name */
--      if (sscanf(buf, "%lu.%lu %*s %d %2s %s %hhx %hhx %x %d ",
--                 &read_tv.tv_sec, &read_tv.tv_usec, &interface,
-+      if (sscanf(buf, "%llu.%llu %*s %d %2s %s %hhx %hhx %x %d ",
-+                 &sec, &usec, &interface,
-                  dir, tmp1, &brs, &esi, &dlc, &dlen) != 9) {
-               /* check for valid line with a symbolic name */
--              if (sscanf(buf, "%lu.%lu %*s %d %2s %s %*s %hhx %hhx %x %d ",
--                         &read_tv.tv_sec, &read_tv.tv_usec, &interface,
-+              if (sscanf(buf, "%llu.%llu %*s %d %2s %s %*s %hhx %hhx %x %d ",
-+                         &sec, &usec, &interface,
-                          dir, tmp1, &brs, &esi, &dlc, &dlen) != 9) {
-                       /* no valid CANFD format pattern */
-                       return;
-               }
-       }
-+      read_tv.tv_sec = sec;
-+      read_tv.tv_usec = usec;
-       /* check for allowed (unsigned) value ranges */
-       if ((dlen > CANFD_MAX_DLEN) || (dlc > CANFD_MAX_DLC) ||
-@@ -427,12 +435,12 @@ int main(int argc, char **argv)
-       FILE *infile = stdin;
-       FILE *outfile = stdout;
-       static int verbose;
--      static struct timeval tmp_tv; /* tmp frame timestamp from ASC file */
-       static struct timeval date_tv; /* date of the ASC file */
-       static int dplace; /* decimal place 4, 5 or 6 or uninitialized */
-       static char base; /* 'd'ec or 'h'ex */
-       static char timestamps; /* 'a'bsolute or 'r'elative */
-       int opt;
-+      unsigned long long sec, usec;
-       while ((opt = getopt(argc, argv, "I:O:v?")) != -1) {
-               switch (opt) {
-@@ -505,12 +513,12 @@ int main(int argc, char **argv)
-                                       gettimeofday(&date_tv, NULL);
-                               }
-                               if (verbose)
--                                      printf("date %lu => %s", date_tv.tv_sec, ctime(&date_tv.tv_sec));
-+                                      printf("date %llu => %s", (unsigned long long)date_tv.tv_sec, ctime(&date_tv.tv_sec));
-                               continue;
-                       }
-                       /* check for decimal places length in valid CAN frames */
--                      if (sscanf(buf, "%lu.%s %s ", &tmp_tv.tv_sec, tmp2,
-+                      if (sscanf(buf, "%llu.%s %s ", &sec, tmp2,
-                                  tmp1) != 3)
-                               continue; /* dplace remains zero until first found CAN frame */
-@@ -529,7 +537,7 @@ int main(int argc, char **argv)
-               /* so try to get CAN frames and ErrorFrames and convert them */
-               /* check classic CAN format or the CANFD tag which can take both types */
--              if (sscanf(buf, "%lu.%lu %s ", &tmp_tv.tv_sec,  &tmp_tv.tv_usec, tmp1) == 3){
-+              if (sscanf(buf, "%llu.%llu %s ", &sec,  &usec, tmp1) == 3){
-                       if (!strncmp(tmp1, "CANFD", 5))
-                               eval_canfd(buf, &date_tv, timestamps, dplace, outfile);
-                       else
---- a/candump.c
-+++ b/candump.c
-@@ -224,7 +224,7 @@ static inline void sprint_timestamp(cons
- {
-       switch (timestamp) {
-       case 'a': /* absolute with timestamp */
--              sprintf(ts_buffer, "(%010lu.%06lu) ", tv->tv_sec, tv->tv_usec);
-+              sprintf(ts_buffer, "(%010llu.%06llu) ", (unsigned long long)tv->tv_sec, (unsigned long long)tv->tv_usec);
-               break;
-       case 'A': /* absolute with date */
-@@ -234,7 +234,7 @@ static inline void sprint_timestamp(cons
-               tm = *localtime(&tv->tv_sec);
-               strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", &tm);
--              sprintf(ts_buffer, "(%s.%06lu) ", timestring, tv->tv_usec);
-+              sprintf(ts_buffer, "(%s.%06llu) ", timestring, (unsigned long long)tv->tv_usec);
-       }
-       break;
-@@ -251,7 +251,7 @@ static inline void sprint_timestamp(cons
-                       diff.tv_sec--, diff.tv_usec += 1000000;
-               if (diff.tv_sec < 0)
-                       diff.tv_sec = diff.tv_usec = 0;
--              sprintf(ts_buffer, "(%03lu.%06lu) ", diff.tv_sec, diff.tv_usec);
-+              sprintf(ts_buffer, "(%03llu.%06llu) ", (unsigned long long)diff.tv_sec, (unsigned long long)diff.tv_usec);
-               if (timestamp == 'd')
-                       *last_tv = *tv; /* update for delta calculation */
---- a/canlogserver.c
-+++ b/canlogserver.c
-@@ -408,8 +408,8 @@ int main(int argc, char **argv)
-                               idx = idx2dindex(addr.can_ifindex, s[i]);
--                              sprintf(temp, "(%lu.%06lu) %*s ",
--                                      tv.tv_sec, tv.tv_usec, max_devname_len, devname[idx]);
-+                              sprintf(temp, "(%llu.%06llu) %*s ",
-+                                      (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec, max_devname_len, devname[idx]);
-                               sprint_canframe(temp+strlen(temp), &frame, 0, maxdlen); 
-                               strcat(temp, "\n");
---- a/canplayer.c
-+++ b/canplayer.c
-@@ -259,6 +259,7 @@ int main(int argc, char **argv)
-       int txidx;       /* sendto() interface index */
-       int eof, txmtu, i, j;
-       char *fret;
-+      unsigned long long sec, usec;
-       while ((opt = getopt(argc, argv, "I:l:tin:g:s:xv?")) != -1) {
-               switch (opt) {
-@@ -419,11 +420,12 @@ int main(int argc, char **argv)
-               eof = 0;
--              if (sscanf(buf, "(%lu.%lu) %s %s", &log_tv.tv_sec, &log_tv.tv_usec,
--                         device, ascframe) != 4) {
-+              if (sscanf(buf, "(%llu.%llu) %s %s", &sec, &usec, device, ascframe) != 4) {
-                       fprintf(stderr, "incorrect line format in logfile\n");
-                       return 1;
-               }
-+              log_tv.tv_sec = sec;
-+              log_tv.tv_usec = usec;
-               if (use_timestamps) { /* throttle sending due to logfile timestamps */
-@@ -505,11 +507,12 @@ int main(int argc, char **argv)
-                                       break;
-                               }
--                              if (sscanf(buf, "(%lu.%lu) %s %s", &log_tv.tv_sec, &log_tv.tv_usec,
--                                         device, ascframe) != 4) {
-+                              if (sscanf(buf, "(%llu.%llu) %s %s", &sec, &usec, device, ascframe) != 4) {
-                                       fprintf(stderr, "incorrect line format in logfile\n");
-                                       return 1;
-                               }
-+                              log_tv.tv_sec = sec;
-+                              log_tv.tv_usec = usec;
-                               /*
-                                * ensure the fractions of seconds are 6 decimal places long to catch
---- a/isotpdump.c
-+++ b/isotpdump.c
-@@ -361,7 +361,7 @@ int main(int argc, char **argv)
-                       switch (timestamp) {
-                       case 'a': /* absolute with timestamp */
--                              printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec);
-+                              printf("(%llu.%06llu) ", (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec);
-                               break;
-                       case 'A': /* absolute with date */
-@@ -372,7 +372,7 @@ int main(int argc, char **argv)
-                               tm = *localtime(&tv.tv_sec);
-                               strftime(timestring, 24, "%Y-%m-%d %H:%M:%S",
-                                        &tm);
--                              printf("(%s.%06lu) ", timestring, tv.tv_usec);
-+                              printf("(%s.%06llu) ", timestring, (unsigned long long)tv.tv_usec);
-                       } break;
-                       case 'd': /* delta */
-@@ -388,8 +388,8 @@ int main(int argc, char **argv)
-                                       diff.tv_sec--, diff.tv_usec += 1000000;
-                               if (diff.tv_sec < 0)
-                                       diff.tv_sec = diff.tv_usec = 0;
--                              printf("(%lu.%06lu) ", diff.tv_sec,
--                                     diff.tv_usec);
-+                              printf("(%llu.%06llu) ", (unsigned long long)diff.tv_sec,
-+                                     (unsigned long long)diff.tv_usec);
-                               if (timestamp == 'd')
-                                       last_tv =
---- a/isotpperf.c
-+++ b/isotpperf.c
-@@ -403,9 +403,9 @@ int main(int argc, char **argv)
-                               /* check devisor to be not zero */
-                               if (diff_tv.tv_sec * 1000 + diff_tv.tv_usec / 1000){
--                                      printf("%lu.%06lus ", diff_tv.tv_sec, diff_tv.tv_usec);
-+                                      printf("%llu.%06llus ", (unsigned long long)diff_tv.tv_sec, (unsigned long long)diff_tv.tv_usec);
-                                       printf("=> %lu byte/s", (fflen * 1000) /
--                                             (diff_tv.tv_sec * 1000 + diff_tv.tv_usec / 1000));
-+                                             (unsigned long)(diff_tv.tv_sec * 1000 + diff_tv.tv_usec / 1000));
-                               } else
-                                       printf("(no time available)     ");
---- a/isotpsniffer.c
-+++ b/isotpsniffer.c
-@@ -101,7 +101,7 @@ void printbuf(unsigned char *buffer, int
-               switch (timestamp) {
-               case 'a': /* absolute with timestamp */
--                      printf("(%lu.%06lu) ", tv->tv_sec, tv->tv_usec);
-+                      printf("(%llu.%06llu) ", (unsigned long long)tv->tv_sec, (unsigned long long)tv->tv_usec);
-                       break;
-               case 'A': /* absolute with date */
-@@ -111,7 +111,7 @@ void printbuf(unsigned char *buffer, int
-                       tm = *localtime(&tv->tv_sec);
-                       strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", &tm);
--                      printf("(%s.%06lu) ", timestring, tv->tv_usec);
-+                      printf("(%s.%06llu) ", timestring, (unsigned long long)tv->tv_usec);
-               }
-               break;
-@@ -128,7 +128,7 @@ void printbuf(unsigned char *buffer, int
-                               diff.tv_sec--, diff.tv_usec += 1000000;
-                       if (diff.tv_sec < 0)
-                               diff.tv_sec = diff.tv_usec = 0;
--                      printf("(%lu.%06lu) ", diff.tv_sec, diff.tv_usec);
-+                      printf("(%llu.%06llu) ", (unsigned long long)diff.tv_sec, (unsigned long long)diff.tv_usec);
-                       if (timestamp == 'd')
-                               *last_tv = *tv; /* update for delta calculation */
---- a/j1939cat.c
-+++ b/j1939cat.c
-@@ -148,8 +148,8 @@ static void j1939cat_print_timestamp(str
-       if (!(cur->tv_sec | cur->tv_nsec))
-               return;
--      fprintf(stderr, "  %s: %lu s %lu us (seq=%03u, send=%07u)",
--                      name, cur->tv_sec, cur->tv_nsec / 1000,
-+      fprintf(stderr, "  %s: %llu s %llu us (seq=%03u, send=%07u)",
-+                      name, (unsigned long long)cur->tv_sec, (unsigned long long)cur->tv_nsec / 1000,
-                       stats->tskey, stats->send);
-       fprintf(stderr, "\n");
---- a/j1939spy.c
-+++ b/j1939spy.c
-@@ -267,15 +267,15 @@ int main(int argc, char **argv)
-                               tdut = ttmp;
-                               goto abs_time;
-                       } else if ('a' == s.time) {
--                              abs_time:
--                              printf("(%lu.%04lu)", tdut.tv_sec, tdut.tv_usec / 100);
-+abs_time:
-+                              printf("(%llu.%04llu)", (unsigned long long)tdut.tv_sec, (unsigned long long)tdut.tv_usec / 100);
-                       } else if ('A' == s.time) {
-                               struct tm tm;
-                               tm = *localtime(&tdut.tv_sec);
--                              printf("(%04u%02u%02uT%02u%02u%02u.%04lu)",
-+                              printf("(%04u%02u%02uT%02u%02u%02u.%04llu)",
-                                       tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-                                       tm.tm_hour, tm.tm_min, tm.tm_sec,
--                                      tdut.tv_usec/100);
-+                                      (unsigned long long)tdut.tv_usec/100);
-                       }
-               }
-               printf(" %s ", libj1939_addr2str(&src));
---- a/log2asc.c
-+++ b/log2asc.c
-@@ -190,6 +190,7 @@ int main(int argc, char **argv)
-       FILE *infile = stdin;
-       FILE *outfile = stdout;
-       static int maxdev, devno, i, crlf, fdfmt, nortrdlc, d4, opt, mtu;
-+      unsigned long long sec, usec;
-       while ((opt = getopt(argc, argv, "I:O:4nfr?")) != -1) {
-               switch (opt) {
-@@ -259,18 +260,20 @@ int main(int argc, char **argv)
-               if (buf[0] != '(')
-                       continue;
--              if (sscanf(buf, "(%lu.%lu) %s %s %s", &tv.tv_sec, &tv.tv_usec,
-+              if (sscanf(buf, "(%llu.%llu) %s %s %s", &sec, &usec,
-                          device, ascframe, extra_info) != 5) {
-                       /* do not evaluate the extra info */
-                       extra_info[0] = 0;
--                      if (sscanf(buf, "(%lu.%lu) %s %s", &tv.tv_sec, &tv.tv_usec,
-+                      if (sscanf(buf, "(%llu.%llu) %s %s", &sec, &usec,
-                                  device, ascframe) != 4) {
-                               fprintf(stderr, "incorrect line format in logfile\n");
-                               return 1;
-                       }
-               }
-+              tv.tv_sec = sec;
-+              tv.tv_usec = usec;
-               if (!start_tv.tv_sec) { /* print banner */
-                       start_tv = tv;
-@@ -305,9 +308,9 @@ int main(int argc, char **argv)
-                               tv.tv_sec = tv.tv_usec = 0;
-                       if (d4)
--                              fprintf(outfile, "%4lu.%04lu ", tv.tv_sec, tv.tv_usec/100);
-+                              fprintf(outfile, "%4llu.%04llu ", (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec/100);
-                       else
--                              fprintf(outfile, "%4lu.%06lu ", tv.tv_sec, tv.tv_usec);
-+                              fprintf(outfile, "%4llu.%06llu ", (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec);
-                       if ((mtu == CAN_MTU) && (fdfmt == 0))
-                               can_asc(&cf, devno, nortrdlc, extra_info, outfile);
---- a/slcanpty.c
-+++ b/slcanpty.c
-@@ -363,8 +363,8 @@ int can2pty(int pty, int socket, int *ts
-               if (ioctl(socket, SIOCGSTAMP, &tv) < 0)
-                       perror("SIOCGSTAMP");
--              sprintf(&buf[ptr + 2*frame.can_dlc], "%04lX",
--                      (tv.tv_sec%60)*1000 + tv.tv_usec/1000);
-+              sprintf(&buf[ptr + 2*frame.can_dlc], "%04llX",
-+                      (unsigned long long)(tv.tv_sec%60)*1000 + tv.tv_usec/1000);
-       }
-       strcat(buf, "\r"); /* add terminating character */