diff --git a/odxtools/parameters/lengthkeyparameter.py b/odxtools/parameters/lengthkeyparameter.py index aa1af915..bf76290c 100644 --- a/odxtools/parameters/lengthkeyparameter.py +++ b/odxtools/parameters/lengthkeyparameter.py @@ -105,9 +105,8 @@ def encode_placeholder_into_pdu(self, physical_value: Optional[ParameterValue], # emplace a value of zero into the encode state, but pretend the bits not to be used n = odxrequire(self.dop.get_static_bit_length()) + encode_state.cursor_bit_position tmp_val = b'\x00' * ((n + 7) // 8) - encode_state.emplace_bytes(tmp_val, obj_used_mask=tmp_val) - encode_state.cursor_bit_position = 0 + encode_state.emplace_bytes(tmp_val, obj_used_mask=tmp_val) def encode_value_into_pdu(self, encode_state: EncodeState) -> None: diff --git a/odxtools/parameters/tablekeyparameter.py b/odxtools/parameters/tablekeyparameter.py index 911c4b83..3d0d51e5 100644 --- a/odxtools/parameters/tablekeyparameter.py +++ b/odxtools/parameters/tablekeyparameter.py @@ -80,18 +80,23 @@ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: super()._resolve_odxlinks(odxlinks) # Either table_ref or table_row_ref will be defined - if self.table_ref: + if self.table_ref is not None: if TYPE_CHECKING: self._table = odxlinks.resolve(self.table_ref, Table) else: self._table = odxlinks.resolve(self.table_ref) - if self.table_row_ref: + if self.table_row_ref is not None: if TYPE_CHECKING: self._table_row = odxlinks.resolve(self.table_row_ref, TableRow) else: self._table_row = odxlinks.resolve(self.table_row_ref) - self._table = self._table_row.table + + if self.table_ref is None and self.table_snref is None: + if TYPE_CHECKING: + self._table = odxlinks.resolve(self._table_row.table_ref, Table) + else: + self._table = odxlinks.resolve(self._table_row.table_ref) @override def _resolve_snrefs(self, context: SnRefContext) -> None: @@ -116,11 +121,7 @@ def _resolve_snrefs(self, context: SnRefContext) -> None: @property def table(self) -> "Table": - if self._table is not None: - return self._table - if self._table_row is not None: - return self._table_row.table - odxraise(f'Could not resolve the table of {self.short_name}') + return self._table @property def table_row(self) -> Optional["TableRow"]: