Skip to content

Commit 9af4576

Browse files
committed
canutils: use bps units for bitrate in SocketCAN interfaces.
This matches PR apache/nuttx#16225 in Nuttx where units for SocketCAN bitrate ioctls were changed.
1 parent 57365ac commit 9af4576

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

canutils/lely-canopen/0005-add-NuttX-support.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ index ca7e7d95..fed1ae16 100644
120120
+ return -1;
121121
+ }
122122
+
123-
+ *pbitrate = ifr.ifr_ifru.ifru_can_data.arbi_bitrate * 1000;
123+
+ *pbitrate = ifr.ifr_ifru.ifru_can_data.arbi_bitrate;
124124
+
125125
+ return 0;
126126
+}
@@ -141,8 +141,8 @@ index ca7e7d95..fed1ae16 100644
141141
+ struct ifreq ifr;
142142
+ if_indextoname(can->ifindex, ifr.ifr_name);
143143
+
144-
+ ifr.ifr_ifru.ifru_can_data.arbi_bitrate = bitrate / 1000;
145-
+ ifr.ifr_ifru.ifru_can_data.data_bitrate = bitrate / 1000;
144+
+ ifr.ifr_ifru.ifru_can_data.arbi_bitrate = bitrate;
145+
+ ifr.ifr_ifru.ifru_can_data.data_bitrate = bitrate;
146146
+ ifr.ifr_ifru.ifru_can_data.arbi_samplep = 0;
147147
+ ifr.ifr_ifru.ifru_can_data.data_samplep = 0;
148148
+

canutils/slcan/slcan.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,7 @@ int main(int argc, char *argv[])
363363
/* set the device name */
364364

365365
strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
366-
367-
ifr.ifr_ifru.ifru_can_data.arbi_bitrate =
368-
canspeed / 1000; /* Convert bit/s to kbit/s */
366+
ifr.ifr_ifru.ifru_can_data.arbi_bitrate = canspeed;
369367
ifr.ifr_ifru.ifru_can_data.arbi_samplep = 80;
370368

371369
if (ioctl(s, SIOCSCANBITRATE, &ifr) < 0)

0 commit comments

Comments
 (0)