|
16 | 16 | import threading
|
17 | 17 | import time
|
18 | 18 |
|
| 19 | + from enum import Enum |
19 | 20 | from sonic_py_common import daemon_base, device_info, logger
|
20 | 21 | from sonic_py_common import multi_asic
|
21 | 22 | from swsscommon import swsscommon
|
@@ -45,21 +46,13 @@ XCVRD_MAIN_THREAD_SLEEP_SECS = 60
|
45 | 46 | SFP_STATUS_REMOVED = '0'
|
46 | 47 | SFP_STATUS_INSERTED = '1'
|
47 | 48 |
|
48 |
| -# SFP error codes, stored as strings. Can add more as needed. |
49 |
| -SFP_STATUS_ERR_I2C_STUCK = '2' |
50 |
| -SFP_STATUS_ERR_BAD_EEPROM = '3' |
51 |
| -SFP_STATUS_ERR_UNSUPPORTED_CABLE = '4' |
52 |
| -SFP_STATUS_ERR_HIGH_TEMP = '5' |
53 |
| -SFP_STATUS_ERR_BAD_CABLE = '6' |
54 |
| - |
55 |
| -# Store the error codes in a set for convenience |
56 |
| -errors_block_eeprom_reading = { |
57 |
| - SFP_STATUS_ERR_I2C_STUCK, |
58 |
| - SFP_STATUS_ERR_BAD_EEPROM, |
59 |
| - SFP_STATUS_ERR_UNSUPPORTED_CABLE, |
60 |
| - SFP_STATUS_ERR_HIGH_TEMP, |
61 |
| - SFP_STATUS_ERR_BAD_CABLE |
62 |
| -} |
| 49 | +# SFP error code enum, new elements can be added to the enum if new errors need to be supported. |
| 50 | +SFP_STATUS_ERR_ENUM = Enum('SFP_STATUS_ERR_ENUM', ['SFP_STATUS_ERR_I2C_STUCK', 'SFP_STATUS_ERR_BAD_EEPROM', |
| 51 | + 'SFP_STATUS_ERR_UNSUPPORTED_CABLE', 'SFP_STATUS_ERR_HIGH_TEMP', |
| 52 | + 'SFP_STATUS_ERR_BAD_CABLE'], start=2) |
| 53 | + |
| 54 | +# Convert the error code to string and store them in a set for convenience |
| 55 | +errors_block_eeprom_reading = set(str(error_code.value) for error_code in SFP_STATUS_ERR_ENUM) |
63 | 56 |
|
64 | 57 | EVENT_ON_ALL_SFP = '-1'
|
65 | 58 | # events definition
|
|
0 commit comments