Skip to content

Commit 38a7a65

Browse files
authored
Change get_tx_bias return type to list (sonic-net#342)
* Change get_tx_bias return type to list Signed-off-by: Mihir Patel <[email protected]>
1 parent ecb7dde commit 38a7a65

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

sonic_platform_base/sonic_xcvr/api/public/cmis.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def get_transceiver_bulk_status(self):
207207

208208
for i in range(1, self.NUM_CHANNELS + 1):
209209
bulk_status["tx%ddisable" % i] = tx_disable[i-1] if self.get_tx_disable_support() else 'N/A'
210-
bulk_status["tx%dbias" % i] = tx_bias['LaserBiasTx%dField' % i] if self.get_tx_bias_support() else 'N/A'
210+
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
211211
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'
212212
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'
213213

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

500500
def get_tx_power(self):
501501
'''

tests/sonic_xcvr/test_cmis.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,11 @@ def test_get_tx_bias_support(self, mock_response, expected):
358358
assert result == expected
359359

360360
@pytest.mark.parametrize("mock_response, expected", [
361-
([True, 2, {'TxBias1': 2}], {'TxBias1': 8}),
362-
([True, 3, {'TxBias1': 2}], {'TxBias1': 2}),
363-
([False, 0, {'TxBias1': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']),
361+
([True, 2, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}],
362+
[8, 8, 8, 8, 8, 8, 8, 8]),
363+
([True, 3, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}],
364+
[2, 2, 2, 2, 2, 2, 2, 2]),
365+
([False, 0, {'LaserBiasTx1Field': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']),
364366
([None, 0, None], None)
365367
])
366368
def test_get_tx_bias(self, mock_response, expected):
@@ -1221,10 +1223,7 @@ def test_get_transceiver_info(self, mock_response, expected):
12211223
0,
12221224
50,
12231225
3.3,
1224-
{'LaserBiasTx1Field': 70, 'LaserBiasTx2Field': 70,
1225-
'LaserBiasTx3Field': 70, 'LaserBiasTx4Field': 70,
1226-
'LaserBiasTx5Field': 70, 'LaserBiasTx6Field': 70,
1227-
'LaserBiasTx7Field': 70, 'LaserBiasTx8Field': 70},
1226+
[70, 70, 70, 70, 70, 70, 70, 70],
12281227
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
12291228
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
12301229
True, True, True, True, True, True,

0 commit comments

Comments
 (0)