Skip to content

Commit 15e534e

Browse files
committed
Add check_cmd_version
1 parent 1a766f4 commit 15e534e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cros_ec_python/commands/general.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ def get_cmd_versions(ec: CrosEcClass, cmd: UInt8 | UInt16, version: Literal[0, 1
152152
# Otherwise, raise the exception
153153
raise e
154154

155+
def check_cmd_version(ec: CrosEcClass, cmd: UInt8 | UInt16, version: int) -> bool:
156+
"""
157+
Check if a command supports a specific version.
158+
:param ec: The CrOS_EC object.
159+
:param cmd: The command to check.
160+
:param version: The version to check for.
161+
:return: True if the command supports the version, False otherwise.
162+
"""
163+
supported_versions = get_cmd_versions(ec, cmd)
164+
if supported_versions is None:
165+
return False
166+
return (supported_versions & (1 << version)) != 0
155167

156168
EC_CMD_GET_COMMS_STATUS: Final = 0x0009
157169

0 commit comments

Comments
 (0)