Skip to content

Commit 682e01a

Browse files
committed
isotpsend: add SF_BROADCAST support for functional addressing
When CAN_ISOTP_SF_BROADCAST is set in the CAN_ISOTP_OPTS flags the CAN_ISOTP socket is switched into functional addressing mode, where only single frame (SF) protocol data units can be send on the specified CAN interface and the given tp.tx_id after bind(). In opposite to normal and extended addressing this socket does not register a CAN-ID for reception which would be needed for a 1-to-1 ISOTP connection with a segmented bi-directional data transfer. The new option '-S' sets the CAN_ISOTP_SF_BROADCAST to test the option with different length settings, e.g. link layer data lengths. Signed-off-by: Oliver Hartkopp <[email protected]>
1 parent 280ea43 commit 682e01a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: isotpsend.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void print_usage(char *prg)
7272
fprintf(stderr, " -f <time ns> (ignore FC and force local tx stmin value in nanosecs)\n");
7373
fprintf(stderr, " -D <len> (send a fixed PDU with len bytes - no STDIN data)\n");
7474
fprintf(stderr, " -b (block until the PDU transmission is completed)\n");
75+
fprintf(stderr, " -S (SF broadcast mode for functional addressing)\n");
7576
fprintf(stderr, " -L <mtu>:<tx_dl>:<tx_flags> (link layer options for CAN FD)\n");
7677
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
7778
fprintf(stderr, "The pdu data is expected on STDIN in space separated ASCII hex values.\n");
@@ -94,7 +95,7 @@ int main(int argc, char **argv)
9495

9596
addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID;
9697

97-
while ((opt = getopt(argc, argv, "s:d:x:p:P:t:f:D:bL:?")) != -1) {
98+
while ((opt = getopt(argc, argv, "s:d:x:p:P:t:f:D:bSL:?")) != -1) {
9899
switch (opt) {
99100
case 's':
100101
addr.can_addr.tp.tx_id = strtoul(optarg, (char **)NULL, 16);
@@ -181,6 +182,10 @@ int main(int argc, char **argv)
181182
opts.flags |= CAN_ISOTP_WAIT_TX_DONE;
182183
break;
183184

185+
case 'S':
186+
opts.flags |= CAN_ISOTP_SF_BROADCAST;
187+
break;
188+
184189
case 'L':
185190
if (sscanf(optarg, "%hhu:%hhu:%hhu",
186191
&llopts.mtu,
@@ -207,7 +212,8 @@ int main(int argc, char **argv)
207212

208213
if ((argc - optind != 1) ||
209214
(addr.can_addr.tp.tx_id == NO_CAN_ID) ||
210-
(addr.can_addr.tp.rx_id == NO_CAN_ID)) {
215+
((addr.can_addr.tp.rx_id == NO_CAN_ID) &&
216+
(!(opts.flags & CAN_ISOTP_SF_BROADCAST)))) {
211217
print_usage(basename(argv[0]));
212218
exit(1);
213219
}

0 commit comments

Comments
 (0)