Skip to content

Commit

Permalink
isotpsend: add SF_BROADCAST support for functional addressing
Browse files Browse the repository at this point in the history
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 <socketcan@hartkopp.net>
  • Loading branch information
hartkopp committed Dec 6, 2020
1 parent 280ea43 commit 682e01a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions isotpsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void print_usage(char *prg)
fprintf(stderr, " -f <time ns> (ignore FC and force local tx stmin value in nanosecs)\n");
fprintf(stderr, " -D <len> (send a fixed PDU with len bytes - no STDIN data)\n");
fprintf(stderr, " -b (block until the PDU transmission is completed)\n");
fprintf(stderr, " -S (SF broadcast mode for functional addressing)\n");
fprintf(stderr, " -L <mtu>:<tx_dl>:<tx_flags> (link layer options for CAN FD)\n");
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
fprintf(stderr, "The pdu data is expected on STDIN in space separated ASCII hex values.\n");
Expand All @@ -94,7 +95,7 @@ int main(int argc, char **argv)

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

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

case 'S':
opts.flags |= CAN_ISOTP_SF_BROADCAST;
break;

case 'L':
if (sscanf(optarg, "%hhu:%hhu:%hhu",
&llopts.mtu,
Expand All @@ -207,7 +212,8 @@ int main(int argc, char **argv)

if ((argc - optind != 1) ||
(addr.can_addr.tp.tx_id == NO_CAN_ID) ||
(addr.can_addr.tp.rx_id == NO_CAN_ID)) {
((addr.can_addr.tp.rx_id == NO_CAN_ID) &&
(!(opts.flags & CAN_ISOTP_SF_BROADCAST)))) {
print_usage(basename(argv[0]));
exit(1);
}
Expand Down

0 comments on commit 682e01a

Please sign in to comment.