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 <socketcan@hartkopp.net>
pull/268/head
Oliver Hartkopp 2020-12-03 20:48:12 +01:00
parent 280ea436d4
commit 682e01a40a
1 changed files with 8 additions and 2 deletions

View File

@ -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, " -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, " -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, " -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, " -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, "\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"); 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)
addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID; 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) { switch (opt) {
case 's': case 's':
addr.can_addr.tp.tx_id = strtoul(optarg, (char **)NULL, 16); addr.can_addr.tp.tx_id = strtoul(optarg, (char **)NULL, 16);
@ -181,6 +182,10 @@ int main(int argc, char **argv)
opts.flags |= CAN_ISOTP_WAIT_TX_DONE; opts.flags |= CAN_ISOTP_WAIT_TX_DONE;
break; break;
case 'S':
opts.flags |= CAN_ISOTP_SF_BROADCAST;
break;
case 'L': case 'L':
if (sscanf(optarg, "%hhu:%hhu:%hhu", if (sscanf(optarg, "%hhu:%hhu:%hhu",
&llopts.mtu, &llopts.mtu,
@ -207,7 +212,8 @@ int main(int argc, char **argv)
if ((argc - optind != 1) || if ((argc - optind != 1) ||
(addr.can_addr.tp.tx_id == NO_CAN_ID) || (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])); print_usage(basename(argv[0]));
exit(1); exit(1);
} }