Skip to content

Commit

Permalink
communication parameters: remove .is_functional
Browse files Browse the repository at this point in the history
communication parameters themselfs do not provide this information and
determining it from the context does not work for all instances where
communication parameter references are needed (i.e. within
`DiagService`)

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
  • Loading branch information
andlaus committed Oct 18, 2023
1 parent a87461c commit 0509b8d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 34 deletions.
11 changes: 0 additions & 11 deletions examples/somersaultecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,6 @@ class SomersaultSID(IntEnum):
value="500000",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# parameters of the CAN diagnostics frames
Expand Down Expand Up @@ -1850,7 +1849,6 @@ class SomersaultSID(IntEnum):
],
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# timeout for responses [us]
Expand All @@ -1859,7 +1857,6 @@ class SomersaultSID(IntEnum):
value="1000000",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
###
Expand All @@ -1871,7 +1868,6 @@ class SomersaultSID(IntEnum):
value=f"{tester_present_value.hex()}",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# a response is mandatory
Expand All @@ -1880,7 +1876,6 @@ class SomersaultSID(IntEnum):
value="Response expected",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# positive response to "tester present"
Expand All @@ -1889,7 +1884,6 @@ class SomersaultSID(IntEnum):
value=f"{tester_pr_value.hex()}",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# negative response to "tester present"
Expand All @@ -1898,7 +1892,6 @@ class SomersaultSID(IntEnum):
value=f"{tester_nr_value.hex()}",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# when a tester present message must be send
Expand All @@ -1907,7 +1900,6 @@ class SomersaultSID(IntEnum):
value="On idle",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# "tester present" messages are send directly to the CAN IDs
Expand All @@ -1917,7 +1909,6 @@ class SomersaultSID(IntEnum):
value="Physical",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
# is a response from the ECU to "tester present" messages expected
Expand All @@ -1926,7 +1917,6 @@ class SomersaultSID(IntEnum):
value="Response expected",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
###
Expand All @@ -1938,7 +1928,6 @@ class SomersaultSID(IntEnum):
value="4",
protocol_snref="MyProtocol",
prot_stack_snref=None,
is_functional=False,
description=None,
),
]
Expand Down
8 changes: 2 additions & 6 deletions odxtools/communicationparameterref.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from .basecomparam import BaseComparam
from .comparam import Comparam
from .complexcomparam import ComplexComparam, ComplexValue, create_complex_value_from_et
from .diaglayertype import DiagLayerType
from .exceptions import OdxWarning, odxassert, odxraise, odxrequire
from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef
from .utils import create_description_from_et
Expand All @@ -23,11 +22,10 @@ class CommunicationParameterRef:
protocol_snref: Optional[str]
prot_stack_snref: Optional[str]
id_ref: OdxLinkRef
is_functional: bool

@staticmethod
def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment],
dl_type: DiagLayerType) -> "CommunicationParameterRef":
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "CommunicationParameterRef":
id_ref = odxrequire(OdxLinkRef.from_et(et_element, doc_frags))

# ODX standard v2.0.0 defined only VALUE. ODX v2.0.1 decided
Expand All @@ -41,7 +39,6 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment],
else:
value = create_complex_value_from_et(odxrequire(et_element.find("COMPLEX-VALUE")))

is_functional = dl_type == DiagLayerType.FUNCTIONAL_GROUP
description = create_description_from_et(et_element.find("DESC"))

prot_stack_snref = None
Expand All @@ -55,7 +52,6 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment],
return CommunicationParameterRef(
value=value,
id_ref=id_ref,
is_functional=is_functional,
description=description,
protocol_snref=protocol_snref,
prot_stack_snref=prot_stack_snref,
Expand Down
22 changes: 6 additions & 16 deletions odxtools/diaglayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ def get_communication_parameter(
self,
cp_short_name: str,
*,
is_functional: Optional[bool] = None,
protocol_name: Optional[str] = None,
) -> Optional[CommunicationParameterRef]:
"""Find a specific communication parameter according to some criteria.
Expand All @@ -604,8 +603,6 @@ def get_communication_parameter(

# determine the set of applicable communication parameters
cps = [cp for cp in self.communication_parameters if cp.short_name == cp_short_name]
if is_functional is not None:
cps = [cp for cp in cps if cp.is_functional in (None, is_functional)]
if protocol_name is not None:
cps = [cp for cp in cps if cp.protocol_snref in (None, protocol_name)]

Expand Down Expand Up @@ -702,7 +699,7 @@ def get_doip_logical_ecu_address(self, protocol_name: Optional[str] = None) -> O
# ISO_15765_2 subset for CAN. If the wrong one is retrieved,
# try specifying the protocol_name.)
com_param = self.get_communication_parameter(
"CP_UniqueRespIdTable", protocol_name=protocol_name, is_functional=False)
"CP_UniqueRespIdTable", protocol_name=protocol_name)

if com_param is None:
return None
Expand All @@ -720,16 +717,13 @@ def get_doip_logical_ecu_address(self, protocol_name: Optional[str] = None) -> O
return int(ecu_addr)

def get_doip_logical_gateway_address(self,
protocol_name: Optional[str] = None,
is_functional: Optional[bool] = False) -> Optional[int]:
protocol_name: Optional[str] = None) -> Optional[int]:
"""The logical gateway address for the diagnosis over IP transport protocol"""

# retrieve CP_DoIPLogicalGatewayAddress from the
# ISO_13400_2_DIS_2015 subset. hopefully.
com_param = self.get_communication_parameter(
"CP_DoIPLogicalGatewayAddress",
is_functional=is_functional,
protocol_name=protocol_name)
"CP_DoIPLogicalGatewayAddress", protocol_name=protocol_name)
if com_param is None:
return None

Expand All @@ -740,15 +734,13 @@ def get_doip_logical_gateway_address(self,

return int(result)

def get_doip_logical_tester_address(self,
protocol_name: Optional[str] = None,
is_functional: Optional[bool] = False) -> Optional[int]:
def get_doip_logical_tester_address(self, protocol_name: Optional[str] = None) -> Optional[int]:
"""DoIp logical gateway address"""

# retrieve CP_DoIPLogicalTesterAddress from the
# ISO_13400_2_DIS_2015 subset. hopefully.
com_param = self.get_communication_parameter(
"CP_DoIPLogicalTesterAddress", is_functional=is_functional, protocol_name=protocol_name)
"CP_DoIPLogicalTesterAddress", protocol_name=protocol_name)
if com_param is None:
return None

Expand All @@ -760,15 +752,13 @@ def get_doip_logical_tester_address(self,
return int(result)

def get_doip_logical_functional_address(self,
protocol_name: Optional[str] = None,
is_functional: Optional[bool] = False) -> Optional[int]:
protocol_name: Optional[str] = None) -> Optional[int]:
"""The logical functional DoIP address of the ECU."""

# retrieve CP_DoIPLogicalFunctionalAddress from the
# ISO_13400_2_DIS_2015 subset. hopefully.
com_param = self.get_communication_parameter(
"CP_DoIPLogicalFunctionalAddress",
is_functional=is_functional,
protocol_name=protocol_name,
)
if com_param is None:
Expand Down
2 changes: 1 addition & 1 deletion odxtools/diaglayerraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) ->
]

communication_parameters = [
CommunicationParameterRef.from_et(el, doc_frags, variant_type)
CommunicationParameterRef.from_et(el, doc_frags)
for el in et_element.iterfind("COMPARAM-REFS/COMPARAM-REF")
]

Expand Down

0 comments on commit 0509b8d

Please sign in to comment.