From 0a29e99b6c232c120956bc1667434c9e3e61367d Mon Sep 17 00:00:00 2001 From: Leonard Yu Date: Wed, 29 Nov 2023 22:13:21 +0100 Subject: [PATCH] Add PX_I2C_CONFIG to HLI and LLI --- xoa_driver/internals/commands/px_commands.py | 41 +++++++++++++++++++ .../ports/port_l23/bases/port_transceiver.py | 6 +++ .../ports/port_l23/bases/port_transceiver.py | 6 +++ 3 files changed, 53 insertions(+) diff --git a/xoa_driver/internals/commands/px_commands.py b/xoa_driver/internals/commands/px_commands.py index 75faab64..716cb862 100644 --- a/xoa_driver/internals/commands/px_commands.py +++ b/xoa_driver/internals/commands/px_commands.py @@ -16,6 +16,7 @@ XmpByte, XmpHex, XmpSequence, + XmpInt, Hex, ) @@ -190,3 +191,43 @@ def get(self) -> Token[GetDataAttr]: """ return Token(self._connection, build_get_request(self, module=self._module, port=self._port)) + +@register_command +@dataclass +class PX_I2C_CONFIG: + """ + Set the get the access speed on a transceiver I2C access in the unit of KHz. Default to 100. When the transceiver is plugged out and in again, the speed will be reset to the default value 100. The speed has a minimum and a maximum, which can be obtained from P_CAPABILITIES. The I2C speed configuration will not be included in the port configuration file (.xpc). When you load a port configuration to a port, the transceiver I2C access speed will be reset to default 100. + """ + + code: typing.ClassVar[int] = 539 + pushed: typing.ClassVar[bool] = False + + _connection: 'interfaces.IConnection' + _module: int + _port: int + + class GetDataAttr(ResponseBodyStruct): + frequency: int = field(XmpInt()) + """integer, frequency in kHz, default is 100.""" + + class SetDataAttr(RequestBodyStruct): + frequency: int = field(XmpInt()) + """integer, frequency in kHz, default is 100.""" + + def get(self) -> Token[GetDataAttr]: + """Get the speed on a transceiver I2C access in the unit of KHz. + + :return: frequency in kHz. + :rtype: PX_I2C_CONFIG.GetDataAttr + """ + + return Token(self._connection, build_get_request(self, module=self._module, port=self._port)) + + def set(self, frequency: int) -> Token[None]: + """Set the speed on a transceiver I2C access in the unit of KHz. + + :param frequency: frequency in kHz + :type frequency: int + """ + + return Token(self._connection, build_set_request(self, module=self._module, port=self._port, frequency=frequency)) \ No newline at end of file diff --git a/xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transceiver.py b/xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transceiver.py index 8f5e6f33..b7d18ec5 100644 --- a/xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transceiver.py +++ b/xoa_driver/internals/hli_v1/ports/port_l23/bases/port_transceiver.py @@ -6,6 +6,7 @@ PX_MII, PX_TEMPERATURE, PX_RW_SEQ, + PX_I2C_CONFIG, ) @@ -17,6 +18,11 @@ def __init__(self, conn: "itf.IConnection", module_id: int, port_id: int) -> Non self.__module_id = module_id self.__port_id = port_id + self.i2c_config = PX_I2C_CONFIG(conn, module_id, port_id) + """Access speed on a transceiver. + :type: PX_I2C_CONFIG + """ + def access_temperature(self): """Transceiver temperature in Celsius. diff --git a/xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transceiver.py b/xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transceiver.py index 8f5e6f33..b7d18ec5 100644 --- a/xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transceiver.py +++ b/xoa_driver/internals/hli_v2/ports/port_l23/bases/port_transceiver.py @@ -6,6 +6,7 @@ PX_MII, PX_TEMPERATURE, PX_RW_SEQ, + PX_I2C_CONFIG, ) @@ -17,6 +18,11 @@ def __init__(self, conn: "itf.IConnection", module_id: int, port_id: int) -> Non self.__module_id = module_id self.__port_id = port_id + self.i2c_config = PX_I2C_CONFIG(conn, module_id, port_id) + """Access speed on a transceiver. + :type: PX_I2C_CONFIG + """ + def access_temperature(self): """Transceiver temperature in Celsius.