isotp: added support for separate extended address in rx path

As requested by Laurent Vaudoit the extended address can be different in the
tx and he rx path:

(..) how can i have a segmented transfer like this:
0x6a7  0x55 0x10 0x08 ........
0x687  0xAA 0x30 0x00 0x00
0x6a7  0x55 0x21 .....

The connection i need is between two ECU, using IDs 0x6a7/687 and one has
adress extension 0x55, the other 0xAA (this adressing method is used on some
FIAT ECUs for example).

http://marc.info/?l=linux-can&m=140354647413513&w=2

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
Oliver Hartkopp
2014-11-16 20:38:31 +01:00
parent c517af5a0b
commit 4ffb7fe5c7
5 changed files with 84 additions and 18 deletions
+12 -1
View File
@@ -64,6 +64,7 @@ void print_usage(char *prg)
fprintf(stderr, "Options: -s <can_id> (source can_id. Use 8 digits for extended IDs)\n");
fprintf(stderr, " -d <can_id> (destination can_id. Use 8 digits for extended IDs)\n");
fprintf(stderr, " -x <addr> (extended addressing mode.)\n");
fprintf(stderr, " -X <addr> (extended addressing mode (rx addr).)\n");
fprintf(stderr, " -p <byte> (set and enable padding byte)\n");
fprintf(stderr, " -P <mode> (check padding in SF/CF. (l)ength (c)ontent (a)ll)\n");
fprintf(stderr, " -b <bs> (blocksize. 0 = off)\n");
@@ -93,7 +94,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:b:m:w:f:l?")) != -1) {
while ((opt = getopt(argc, argv, "s:d:x:X:p:P:b:m:w:f:l?")) != -1) {
switch (opt) {
case 's':
addr.can_addr.tp.tx_id = strtoul(optarg, (char **)NULL, 16);
@@ -112,6 +113,11 @@ int main(int argc, char **argv)
opts.ext_address = strtoul(optarg, (char **)NULL, 16) & 0xFF;
break;
case 'X':
opts.flags |= CAN_ISOTP_RX_EXT_ADDR;
opts.rx_ext_address = strtoul(optarg, (char **)NULL, 16) & 0xFF;
break;
case 'p':
opts.flags |= CAN_ISOTP_RX_PADDING;
opts.rxpad_content = strtoul(optarg, (char **)NULL, 16) & 0xFF;
@@ -172,6 +178,11 @@ int main(int argc, char **argv)
exit(1);
}
if ((opts.flags & CAN_ISOTP_RX_EXT_ADDR) && (!(opts.flags & CAN_ISOTP_EXTEND_ADDR))) {
print_usage(basename(argv[0]));
exit(1);
}
if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP)) < 0) {
perror("socket");
exit(1);