Skip to content

Commit

Permalink
Do not read build string without first checking XNCP feature bitmap (#…
Browse files Browse the repository at this point in the history
…660)

* Do not read build string without first checking XNCP feature bitmap

* Fix unit test
  • Loading branch information
puddly authored Dec 17, 2024
1 parent b7f3ef9 commit 0948eef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ async def get_board_info(
patch, ver_info_bytes = t.uint8_t.deserialize(ver_info_bytes)
special, ver_info_bytes = t.uint8_t.deserialize(ver_info_bytes)
version = f"{major}.{minor}.{patch}.{special} build {build}"
build_string = None

try:
build_string = await self.xncp_get_build_string()
except InvalidCommandError:
build_string = None
if FirmwareFeatures.BUILD_STRING in self._xncp_features:
with contextlib.suppress(InvalidCommandError):
build_string = await self.xncp_get_build_string()

if build_string:
version = f"{version} ({build_string})"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_ezsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ async def replacement(command_name, tokenId=None, valueId=None):

return replacement

if not isinstance(xncp_build_string, InvalidCommandError):
ezsp_f._xncp_features |= xncp.FirmwareFeatures.BUILD_STRING

with patch.object(
ezsp_f,
"_command",
Expand Down

0 comments on commit 0948eef

Please sign in to comment.