Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scapy/contrib/automotive/xcp/cto_commands_slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def post_dissection(self, pkt):
conf.contribs["XCP"][
"Address_Granularity_Byte"] = self.get_address_granularity()

if conf.contribs["XCP"]["allow_cto_and_dto_change"] and self.max_cto != 0:
if conf.contribs["XCP"]["allow_cto_and_dto_change"]:
conf.contribs["XCP"]["MAX_CTO"] = self.max_cto
conf.contribs["XCP"]["MAX_DTO"] = self.max_dto or self.max_dto_le

Expand Down
12 changes: 12 additions & 0 deletions scapy/contrib/automotive/xcp/xcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

# scapy.contrib.description = Universal calibration and measurement protocol (XCP) # noqa: E501
# scapy.contrib.status = loads

"""
Universal calibration and measurement protocol (XCP)

When using this module, one must at least define the following values:

>>> # These are example values, please change them to your setup.
>>> conf.contribs["XCP"]["MAX_CTO"] = 255
>>> conf.contribs["XCP"]["MAX_DTO"] = 65535
>>> conf.contribs["XCP"]["Address_Granularity_Byte"] = 4
"""

import struct

from scapy.config import conf
Expand Down
8 changes: 0 additions & 8 deletions test/contrib/automotive/xcp/xcp.uts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ load_layer("can", globals_dict=globals())
conf.contribs['CAN']['swap-bytes'] = False
load_contrib("automotive.xcp.xcp", globals_dict=globals())

= Reject a zero MAX_CTO response before changing state
conf.contribs["XCP"]["MAX_CTO"] = None
request = CTORequest()/Connect()
response = CTOResponse(bytes.fromhex("ffff000000000101"))
assert not response.answers(request)
assert conf.contribs["XCP"]["MAX_CTO"] is None


= Test padding

conf.contribs["XCP"]["add_padding_for_can"] = True
Expand Down
Loading