Addressing
ISO-15765 defines several addressing modes and this module supports them all. Depending on the addressing mode, the source/target addresses will be defined in a different way.
An IsoTP address is represented by the isotp.Address
object.
Definitions
- class isotp.Address(addressing_mode=AddressingMode.Normal_11bits, txid=None, rxid=None, target_address=None, source_address=None, physical_id=None, functional_id=None, address_extension=None, rx_only=False, tx_only=False)[source]
Represents the addressing information (N_AI) of the IsoTP layer. Will define what messages will be received and how to craft transmitted message to reach a specific party.
Parameters must be given according to the addressing mode. When not needed, a parameter may be left unset or set to
None
.Both the
TransportLayer
and theisotp.socket
expects this address object- Parameters:
addressing_mode (int) – The addressing mode. Valid values are defined by the
AddressingMode
classtxid (int | None) – The CAN ID for transmission. Used for these addressing mode:
Normal_11bits
,Normal_29bits
,Extended_11bits
,Extended_29bits
,Mixed_11bits
rxid (int | None) – The CAN ID for reception. Used for these addressing mode:
Normal_11bits
,Normal_29bits
,Extended_11bits
,Extended_29bits
,Mixed_11bits
target_address (int | None) – Target address (N_TA) used in
NormalFixed_29bits
andMixed_29bits
addressing mode.source_address (int | None) – Source address (N_SA) used in
NormalFixed_29bits
andMixed_29bits
addressing mode.physical_id (int | None) – The CAN ID for physical (unicast) messages. Only bits 28-16 are used. Used for these addressing modes:
NormalFixed_29bits
,Mixed_29bits
. Set to standard mandated value if None.functional_id (int | None) – The CAN ID for functional (multicast) messages. Only bits 28-16 are used. Used for these addressing modes:
NormalFixed_29bits
,Mixed_29bits
. Set to standard mandated value if None.address_extension (int | None) – Address extension (N_AE) used in
Mixed_11bits
,Mixed_29bits
addressing moderx_only (bool) – When using
AsymmetricAddress
, indicates that this address is the RX part, disabling validation of TX parttx_only (bool) – When using
AsymmetricAddress
, indicates that this address is the TX part, disabling validation of RX part
Addressing modes
Normal addressing
In normal addressing, a CAN arbitration ID is selected for transmission (txid) and reception (rxid).
- Condition to receive a message (discarded if not met):
Message arbitration ID must match receiver
rxid
This mode is possible in both legislated 11-bits and extended 29-bits CAN identifiers
- Example :
rxid : 0x123
txid : 0x456
// Reception of a 10 bytes payload
0x123 [8] 10 0A 00 01 02 03 04 // First frame
0x456 [4] 30 00 08 00 // Flow control
0x123 [6] 21 05 06 07 08 09 // Consecutive frame
Normal fixed addressing
In normal fixed addressing, a target_address
and a source_address
is encoded in the CAN arbitration ID.
- Condition to receive a message (discarded if not met):
Message Target Address must match receiver
source_address
Message Source Address must match the receiver
target_address
This mode is only possible with extended 29-bits CAN identifiers.
A message arbitration ID sent in normal fixed addressing is encoded like the following (with <TA>=Target Address and <SA>=Source Address)
1-to-1 communication (target_address_type = Physical) : 0x18DA<TA><SA>
1-to-n communication (target_address_type = Functional) : 0x18DB<TA><SA>
- Example :
source_address : 0x55
target_address : 0xAA
// Reception of a 10 bytes payload
0x18DA55AA [8] 10 0A 00 01 02 03 04 // First frame
0x18DAAA55 [4] 30 00 08 00 // Flow control
0x18DA55AA [6] 21 05 06 07 08 09 // Consecutive frame
Extended addressing
In extended addressing, rxid
and txid
must be set just like normal addressing, but an additional source_address
and target_address
must be given. The additional addresses will be added as the first byte of each CAN message sent.
- Condition to receive a message (discarded if not met):
Message arbitration ID must match receiver
rxid
Payload first byte must match receiver
source_address
This mode is possible in both legislated 11-bits and extended 29-bits CAN identifiers
- Example :
rxid : 0x123
txid : 0x456
source_address : 0x55
target_address : 0xAA
// Reception of a 10 bytes payload
0x123 [8] 55 10 0A 00 01 02 03 // First frame
0x456 [5] AA 30 00 08 00 // Flow control
0x123 [8] 55 21 04 05 06 07 08 09 // consecutive frame
Mixed addressing - 11 bits
Mixed addressing (11 bits) is a mix of normal addressing and extended addressing. The payload prefix is called address_extension
When used in legislated 11-bits CAN, Mixed addressing behaves like extended addressing with both source_address and target_address being defined by address_extension
- Condition to receive a message (discarded if not met):
Message arbitration ID must match receiver
rxid
Payload first byte must match receiver
address_extension
- Example :
rxid : 0x123
txid : 0x456
address_extension : 0x99
// Reception of a 10 bytes payload
0x123 [8] 99 10 0A 00 01 02 03 // First frame
0x456 [5] 99 30 00 08 00 // Flow control
0x123 [8] 99 21 04 05 06 07 08 09 // consecutive frame
Mixed addressing - 29 bits
Mixed addressing (29 bits) is a mix of normal fixed addressing and extended addressing. The payload prefix is called address_extension
A message arbitration ID sent in 29 bits mixed addressing is encoded like the following (with <TA>=Target Address and <SA>=Source Address)
1-to-1 communication (target_address_type = Physical) : 0x18CE<TA><SA>
1-to-n communication (target_address_type = Functional) : 0x18CD<TA><SA>
- Condition to receive a message (discarded if not met):
Message Target Address must match receiver
source_address
Message Source Address must match the receiver
target_address
Payload first byte must match receiver
address_extension
- Example :
source_address : 0x55
target_address : 0xAA
address_extension : 0x99
// Reception of a 10 bytes payload
0x18CE55AA [8] 99 10 0A 00 01 02 03 // First frame
0x18CEAA55 [5] 99 30 00 08 00 // Flow control
0x18CE55AA [8] 99 21 04 05 06 07 08 09 // consecutive frame
Asymmetric addresses
It is possible to send and receive with different address schemes. The AsymmetricAddress
serves that purpose
- class isotp.AsymmetricAddress(tx_addr, rx_addr)[source]
Address that uses independent addressing modes for transmission and reception.
When using an asymmetric, both tx_addr
and rx_addr
must be partial addresses, meaning that either tx_only=True
or rx_only=True
is set.
Address objects instantiated with rx_only=True
will not expect the parameters meant for transmission and conversely, when instantiated with tx_only=True
parameters required for reception won’t be needed.
Example :
Transmission (
NormalFixed_29bits
):
source_address : 0x55
target_address : 0xAA
Reception (
Mixed_11bits
)
rxid : 0x123
address_extension : 0x99
import isotp
address = isotp.AsymmetricAddress(
tx_addr=isotp.Address(isotp.AddressingMode.NormalFixed_29bits, target_address=ta, source_address=sa, tx_only=True),
rx_addr=isotp.Address(isotp.AddressingMode.Mixed_11bits, rxid=0x123, address_extension=0x99, rx_only=True) # txid is not required
)
// Reception of a 10 bytes payload
0x123 [8] 99 10 0A 00 01 02 03 04 // First frame
0x18DAAA55 [4] 30 00 08 00 // Flow control
0x123 [7] 99 21 05 06 07 08 09 // Consecutive frame
The following table indicates the required parameters to construct a Address
object for all possible scenarios
Addressing mode |
Full address |
Partial Tx ( |
Partial Rx ( |
---|---|---|---|
Normal_11bits |
|
|
|
Normal_29bits |
|
|
|
NormalFixed_29bits |
|
|
|
Extended_11bits |
|
|
|
Extended_29bits |
|
|
|
Mixed_11bits |
|
|
|
Mixed_29bits |
|
|
|