summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/GNUmakefile.am10
-rw-r--r--src/candump.c26
-rw-r--r--src/canecho.c17
-rw-r--r--src/cansend.c33
-rw-r--r--src/cansequence.c36
6 files changed, 65 insertions, 59 deletions
diff --git a/configure.ac b/configure.ac
index 9e3e3ea..d792b1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([canutils], [1.2.0], [socket-can@pengutronix.de])
+AC_INIT([canutils], [2.0.1], [socket-can@pengutronix.de])
AC_CONFIG_HEADERS([include/can_config.h])
AC_CONFIG_SRCDIR([src/canconfig.c])
AC_CONFIG_MACRO_DIR([config/m4])
diff --git a/src/GNUmakefile.am b/src/GNUmakefile.am
index 315600d..14871a0 100644
--- a/src/GNUmakefile.am
+++ b/src/GNUmakefile.am
@@ -1,8 +1,8 @@
-# bin_PROGRAMS = \
-# candump \
-# canecho \
-# cansend \
-# cansequence
+bin_PROGRAMS = \
+ candump \
+ cansend \
+ canecho \
+ cansequence
sbin_PROGRAMS = \
canconfig
diff --git a/src/candump.c b/src/candump.c
index 844bd58..0c344f4 100644
--- a/src/candump.c
+++ b/src/candump.c
@@ -1,3 +1,5 @@
+#include <can_config.h>
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -13,8 +15,9 @@
#include <sys/ioctl.h>
#include <net/if.h>
-#include <socket-can/can.h>
-#include <can_config.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+#include <linux/can/ioctl.h>
extern int optind, opterr, optopt;
@@ -33,14 +36,14 @@ static void print_usage(char *prg)
"Options:\n"
" -f, --family=FAMILY\t" "protocol family (default PF_CAN = %d)\n"
" -t, --type=TYPE\t" "socket type, see man 2 socket (default SOCK_RAW = %d)\n"
- " -p, --protocol=PROTO\t" "CAN protocol (default CAN_PROTO_RAW = %d)\n"
+ " -p, --protocol=PROTO\t" "CAN protocol (default CAN_RAW = %d)\n"
" --filter=id:mask[:id:mask]...\n"
"\t\t\t" "apply filter\n"
" -h, --help\t\t" "this help\n"
" -o <filename>\t\t" "output into filename\n"
" -d\t\t\t" "daemonize\n"
" --version\t\t" "print version information and exit\n",
- prg, PF_CAN, SOCK_RAW, CAN_PROTO_RAW);
+ prg, PF_CAN, SOCK_RAW, CAN_RAW);
}
static void sigterm(int signo)
@@ -69,7 +72,7 @@ int add_filter(u_int32_t id, u_int32_t mask)
int main(int argc, char **argv)
{
- int family = PF_CAN, type = SOCK_RAW, proto = CAN_PROTO_RAW;
+ int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
int opt, optdaemon = 0;
struct sockaddr_can addr;
struct can_frame frame;
@@ -165,7 +168,6 @@ int main(int argc, char **argv)
strncpy(ifr.ifr_name, argv[optind], sizeof(ifr.ifr_name));
ioctl(s, SIOCGIFINDEX, &ifr);
addr.can_ifindex = ifr.ifr_ifindex;
- addr.can_id = CAN_FLAG_ALL;
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
@@ -173,7 +175,7 @@ int main(int argc, char **argv)
}
if(filter) {
- if(setsockopt(s, SOL_CAN_RAW, SO_CAN_SET_FILTER, filter, filter_count * sizeof(struct can_filter)) != 0) {
+ if(setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, filter, filter_count * sizeof(struct can_filter)) != 0) {
perror("setsockopt");
exit(1);
}
@@ -199,16 +201,16 @@ int main(int argc, char **argv)
perror("read");
return 1;
} else {
- if (frame.can_id & CAN_FLAG_EXTENDED)
- n = snprintf(buf, BUF_SIZ, "<0x%08x> ", frame.can_id & CAN_ID_EXT_MASK);
+ if (frame.can_id & CAN_EFF_FLAG)
+ n = snprintf(buf, BUF_SIZ, "<0x%08x> ", frame.can_id & CAN_EFF_MASK);
else
- n = snprintf(buf, BUF_SIZ, "<0x%03x> ", frame.can_id & CAN_ID_STD_MASK);
+ n = snprintf(buf, BUF_SIZ, "<0x%03x> ", frame.can_id & CAN_SFF_MASK);
n += snprintf(buf + n, BUF_SIZ - n, "[%d] ", frame.can_dlc);
for (i = 0; i < frame.can_dlc; i++) {
- n += snprintf(buf + n, BUF_SIZ - n, "%02x ", frame.payload.data_u8[i]);
+ n += snprintf(buf + n, BUF_SIZ - n, "%02x ", frame.data[i]);
}
- if (frame.can_id & CAN_FLAG_RTR)
+ if (frame.can_id & CAN_RTR_FLAG)
n += snprintf(buf + n, BUF_SIZ - n, "remote request");
fprintf(out, "%s\n", buf);
diff --git a/src/canecho.c b/src/canecho.c
index ce397c6..67d5ccf 100644
--- a/src/canecho.c
+++ b/src/canecho.c
@@ -1,3 +1,5 @@
+#include <can_config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -12,8 +14,8 @@
#include <sys/ioctl.h>
#include <net/if.h>
-#include <socket-can/can.h>
-#include <can_config.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
extern int optind, opterr, optopt;
@@ -34,11 +36,11 @@ void print_usage(char *prg)
"Options:\n"
" -f, --family=FAMILY Protocol family (default PF_CAN = %d)\n"
" -t, --type=TYPE Socket type, see man 2 socket (default SOCK_RAW = %d)\n"
- " -p, --protocol=PROTO CAN protocol (default CAN_PROTO_RAW = %d)\n"
+ " -p, --protocol=PROTO CAN protocol (default CAN_RAW = %d)\n"
" -v, --verbose be verbose\n"
" -h, --help this help\n"
" --version print version information and exit\n",
- prg, PF_CAN, SOCK_RAW, CAN_PROTO_RAW);
+ prg, PF_CAN, SOCK_RAW, CAN_RAW);
}
void sigterm(int signo)
@@ -48,7 +50,7 @@ void sigterm(int signo)
int main(int argc, char **argv)
{
- int family = PF_CAN, type = SOCK_RAW, proto = CAN_PROTO_RAW;
+ int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
int opt;
int s[2];
@@ -135,7 +137,6 @@ int main(int argc, char **argv)
strcpy(ifr[i].ifr_name, intf_name[i]);
ioctl(s[i], SIOCGIFINDEX, &ifr[i]);
addr[i].can_ifindex = ifr[i].ifr_ifindex;
- addr[i].can_id = CAN_FLAG_ALL;
if (bind(s[i], (struct sockaddr *)&addr[i], sizeof(addr)) < 0) {
perror("bind");
@@ -150,12 +151,12 @@ int main(int argc, char **argv)
}
if (verbose) {
printf("%04x: ", frame.can_id);
- if (frame.can_id & CAN_FLAG_RTR) {
+ if (frame.can_id & CAN_RTR_FLAG) {
printf("remote request");
} else {
printf("[%d]", frame.can_dlc);
for (i = 0; i < frame.can_dlc; i++) {
- printf(" %02x", frame.payload.data[i]);
+ printf(" %02x", frame.data[i]);
}
}
printf("\n");
diff --git a/src/cansend.c b/src/cansend.c
index 80721c4..5b64886 100644
--- a/src/cansend.c
+++ b/src/cansend.c
@@ -1,3 +1,5 @@
+#include <can_config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -12,9 +14,9 @@
#include <sys/ioctl.h>
#include <net/if.h>
-#include <can_config.h>
-
-#include <socket-can/can.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+#include <linux/can/ioctl.h>
extern int optind, opterr, optopt;
@@ -28,13 +30,13 @@ static void print_usage(char *prg)
" -e --extended send extended frame\n"
" -f, --family=FAMILY Protocol family (default PF_CAN = %d)\n"
" -t, --type=TYPE Socket type, see man 2 socket (default SOCK_RAW = %d)\n"
- " -p, --protocol=PROTO CAN protocol (default CAN_PROTO_RAW = %d)\n"
+ " -p, --protocol=PROTO CAN protocol (default CAN_RAW = %d)\n"
" -l send message infinite times\n"
" --loop=COUNT send message COUNT times\n"
" -v, --verbose be verbose\n"
" -h, --help this help\n"
" --version print version information and exit\n",
- prg, PF_CAN, SOCK_RAW, CAN_PROTO_RAW);
+ prg, PF_CAN, SOCK_RAW, CAN_RAW);
}
enum
@@ -44,7 +46,7 @@ enum
int main(int argc, char **argv)
{
- int family = PF_CAN, type = SOCK_RAW, proto = CAN_PROTO_RAW;
+ int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
struct sockaddr_can addr;
int s, opt, ret, i, dlc = 0, rtr = 0, extended = 0;
struct can_frame frame;
@@ -143,7 +145,6 @@ int main(int argc, char **argv)
return 1;
}
addr.can_ifindex = ifr.ifr_ifindex;
- addr.can_id = frame.can_id;
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
@@ -151,25 +152,25 @@ int main(int argc, char **argv)
}
- for(i = optind + 1; i < argc; i++) {
- frame.payload.data[dlc] = strtoul(argv[i], NULL, 0);
+ for (i = optind + 1; i < argc; i++) {
+ frame.data[dlc] = strtoul(argv[i], NULL, 0);
dlc++;
- if( dlc == 8 )
+ if (dlc == 8)
break;
}
frame.can_dlc = dlc;
- if(rtr)
- frame.can_id |= CAN_FLAG_RTR;
+ if (rtr)
+ frame.can_id |= CAN_RTR_FLAG;
- if(extended)
- frame.can_id |= CAN_FLAG_EXTENDED;
+ if (extended)
+ frame.can_id |= CAN_EFF_FLAG;
- if(verbose) {
+ if (verbose) {
printf("id: %d ",frame.can_id);
printf("dlc: %d\n",frame.can_dlc);
for(i = 0; i < frame.can_dlc; i++)
- printf("0x%02x ",frame.payload.data[i]);
+ printf("0x%02x ",frame.data[i]);
printf("\n");
}
diff --git a/src/cansequence.c b/src/cansequence.c
index e569b1b..c5492ba 100644
--- a/src/cansequence.c
+++ b/src/cansequence.c
@@ -1,3 +1,5 @@
+#include <can_config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -12,8 +14,9 @@
#include <sys/ioctl.h>
#include <net/if.h>
-#include <socket-can/can.h>
-#include <can_config.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+#include <linux/can/ioctl.h>
extern int optind, opterr, optopt;
@@ -37,14 +40,14 @@ void print_usage(char *prg)
"Options:\n"
" -f, --family=FAMILY Protocol family (default PF_CAN = %d)\n"
" -t, --type=TYPE Socket type, see man 2 socket (default SOCK_RAW = %d)\n"
- " -p, --protocol=PROTO CAN protocol (default CAN_PROTO_RAW = %d)\n"
+ " -p, --protocol=PROTO CAN protocol (default CAN_RAW = %d)\n"
" -r, --receive work as receiver\n"
" -l --loop=COUNT send COUNT messages\n"
" -q --quit quit if a wrong sequence is encountered\n"
" -v, --verbose be verbose (twice to be even more verbose\n"
" -h --help this help\n"
" --version print version information and exit\n",
- prg, PF_CAN, SOCK_RAW, CAN_PROTO_RAW);
+ prg, PF_CAN, SOCK_RAW, CAN_RAW);
}
void sigterm(int signo)
@@ -54,7 +57,7 @@ void sigterm(int signo)
int main(int argc, char **argv)
{
- int family = PF_CAN, type = SOCK_RAW, proto = CAN_PROTO_RAW;
+ int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
int opt;
struct sockaddr_can addr;
struct can_frame frame;
@@ -143,7 +146,6 @@ int main(int argc, char **argv)
strncpy(ifr.ifr_name, argv[optind], sizeof(ifr.ifr_name));
ioctl(s, SIOCGIFINDEX, &ifr);
addr.can_ifindex = ifr.ifr_ifindex;
- addr.can_id = CAN_FLAG_ALL;
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
@@ -156,18 +158,18 @@ int main(int argc, char **argv)
perror("read");
return 1;
} else {
- if( sequence_init ) {
+ if (sequence_init) {
sequence_init = 0;
- sequence = frame.payload.data_u8[0];
+ sequence = frame.data[0];
}
- if(verbose>1)
+ if (verbose>1)
printf("received frame. sequence number: %d\n",sequence);
- if( frame.payload.data_u8[0] != sequence) {
+ if (frame.data[0] != sequence) {
printf("received wrong sequence count. expected: %d, got: %d\n",
- frame.payload.data_u8[0], sequence);
+ frame.data[0], sequence);
if(quit)
exit(1);
- sequence = frame.payload.data_u8[0];
+ sequence = frame.data[0];
}
if(verbose && !sequence)
printf("sequence wrap around\n");
@@ -177,17 +179,17 @@ int main(int argc, char **argv)
} else {
frame.can_dlc = 1;
frame.can_id = 2;
- frame.payload.data[0] = 0;
+ frame.data[0] = 0;
while ((infinite || loopcount--) && running) {
- if(verbose>1)
+ if (verbose>1)
printf("sending frame. sequence number: %d\n",sequence);
- if(verbose && !sequence)
+ if (verbose && !sequence)
printf("sequence wrap around\n");
- if( write(s, &frame, sizeof(frame)) < 0) {
+ if (write(s, &frame, sizeof(frame)) < 0) {
perror("write");
break;
}
- (unsigned char)frame.payload.data[0]++;
+ (unsigned char)frame.data[0]++;
sequence++;
}
}