Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions xoa_driver/internals/commands/px_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
XmpByte,
XmpHex,
XmpSequence,
XmpInt,
Hex,
)

Expand Down Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
PX_MII,
PX_TEMPERATURE,
PX_RW_SEQ,
PX_I2C_CONFIG,
)


Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
PX_MII,
PX_TEMPERATURE,
PX_RW_SEQ,
PX_I2C_CONFIG,
)


Expand All @@ -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.

Expand Down