Skip to content

Commit

Permalink
Change get_tx_bias return type to list (sonic-net#342)
Browse files Browse the repository at this point in the history
* Change get_tx_bias return type to list

Signed-off-by: Mihir Patel <patelmi@microsoft.com>
  • Loading branch information
mihirpat1 authored Jan 25, 2023
1 parent ecb7dde commit 38a7a65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def get_transceiver_bulk_status(self):

for i in range(1, self.NUM_CHANNELS + 1):
bulk_status["tx%ddisable" % i] = tx_disable[i-1] if self.get_tx_disable_support() else 'N/A'
bulk_status["tx%dbias" % i] = tx_bias['LaserBiasTx%dField' % i] if self.get_tx_bias_support() else 'N/A'
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
bulk_status["rx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(rx_power[i - 1]))) if self.get_rx_power_support() else 'N/A'
bulk_status["tx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(tx_power[i - 1]))) if self.get_tx_power_support() else 'N/A'

Expand Down Expand Up @@ -495,7 +495,7 @@ def get_tx_bias(self):
tx_bias = self.xcvr_eeprom.read(consts.TX_BIAS_FIELD)
for key, value in tx_bias.items():
tx_bias[key] *= scale
return tx_bias
return [tx_bias['LaserBiasTx%dField' % i] for i in range(1, self.NUM_CHANNELS + 1)]

def get_tx_power(self):
'''
Expand Down
13 changes: 6 additions & 7 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ def test_get_tx_bias_support(self, mock_response, expected):
assert result == expected

@pytest.mark.parametrize("mock_response, expected", [
([True, 2, {'TxBias1': 2}], {'TxBias1': 8}),
([True, 3, {'TxBias1': 2}], {'TxBias1': 2}),
([False, 0, {'TxBias1': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']),
([True, 2, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}],
[8, 8, 8, 8, 8, 8, 8, 8]),
([True, 3, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}],
[2, 2, 2, 2, 2, 2, 2, 2]),
([False, 0, {'LaserBiasTx1Field': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']),
([None, 0, None], None)
])
def test_get_tx_bias(self, mock_response, expected):
Expand Down Expand Up @@ -1221,10 +1223,7 @@ def test_get_transceiver_info(self, mock_response, expected):
0,
50,
3.3,
{'LaserBiasTx1Field': 70, 'LaserBiasTx2Field': 70,
'LaserBiasTx3Field': 70, 'LaserBiasTx4Field': 70,
'LaserBiasTx5Field': 70, 'LaserBiasTx6Field': 70,
'LaserBiasTx7Field': 70, 'LaserBiasTx8Field': 70},
[70, 70, 70, 70, 70, 70, 70, 70],
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
True, True, True, True, True, True,
Expand Down

0 comments on commit 38a7a65

Please sign in to comment.