@@ -23,6 +23,8 @@ class CmisApi(XcvrApi):
23
23
24
24
def __init__ (self , xcvr_eeprom ):
25
25
super (CmisApi , self ).__init__ (xcvr_eeprom )
26
+ self .vdm = CmisVdmApi (xcvr_eeprom )
27
+ self .cdb = CmisCdbApi (xcvr_eeprom )
26
28
27
29
def get_model (self ):
28
30
'''
@@ -684,13 +686,9 @@ def get_active_apsel_hostlane(self):
684
686
'''
685
687
This function returns the application select code that each host lane has
686
688
'''
687
- apsel_dict = {}
688
- if self .is_flat_memory ():
689
- for lane in range (1 , self .NUM_CHANNELS + 1 ):
690
- apsel_dict ["%s%d" % (consts .ACTIVE_APSEL_HOSTLANE , lane )] = 'N/A'
691
- else :
692
- apsel_dict = self .xcvr_eeprom .read (consts .ACTIVE_APSEL_CODE )
693
- return apsel_dict
689
+ if (self .is_flat_memory ()):
690
+ return {'{}{}' .format (consts .ACTIVE_APSEL_HOSTLANE , i ) : 'N/A' for i in range (1 , self .NUM_CHANNELS + 1 )}
691
+ return self .xcvr_eeprom .read (consts .ACTIVE_APSEL_CODE )
694
692
695
693
def get_tx_config_power (self ):
696
694
'''
@@ -960,23 +958,10 @@ def set_loopback_mode(self, loopback_mode):
960
958
else :
961
959
return 'N/A'
962
960
963
-
964
- def get_cdb_api (self ):
965
- self .cdb = CmisCdbApi (self .xcvr_eeprom )
966
- return self .cdb
967
-
968
- def get_vdm_api (self ):
969
- self .vdm = CmisVdmApi (self .xcvr_eeprom )
970
- return self .vdm
971
-
972
961
def get_vdm (self ):
973
962
'''
974
963
This function returns all the VDM items, including real time monitor value, threholds and flags
975
964
'''
976
- try :
977
- self .vdm
978
- except AttributeError :
979
- self .get_vdm_api ()
980
965
vdm = self .vdm .get_vdm_allpage () if not self .is_flat_memory () else {}
981
966
return vdm
982
967
@@ -1070,17 +1055,13 @@ def get_module_level_flag(self):
1070
1055
'custom_mon_flags' : custom_mon_flags }
1071
1056
return module_flag
1072
1057
1073
- def get_module_fw_upgrade_feature (self , verbose = False ):
1058
+ def get_module_fw_mgmt_feature (self , verbose = False ):
1074
1059
"""
1075
1060
This function obtains CDB features supported by the module from CDB command 0041h,
1076
1061
such as start header size, maximum block size, whether extended payload messaging
1077
1062
(page 0xA0 - 0xAF) or only local payload is supported. These features are important because
1078
1063
the following upgrade with depend on these parameters.
1079
1064
"""
1080
- try :
1081
- self .cdb
1082
- except AttributeError :
1083
- self .get_cdb_api ()
1084
1065
txt = ''
1085
1066
# get fw upgrade features (CMD 0041h)
1086
1067
starttime = time .time ()
@@ -1121,7 +1102,7 @@ def get_module_fw_upgrade_feature(self, verbose = False):
1121
1102
elapsedtime = time .time ()- starttime
1122
1103
logger .info ('Get module FW upgrade features time: %.2f s\n ' % elapsedtime )
1123
1104
logger .info (txt )
1124
- return {'status' : True , 'info' : txt , 'result ' : (startLPLsize , maxblocksize , lplonly_flag , autopaging_flag , writelength )}
1105
+ return {'status' : True , 'info' : txt , 'feature ' : (startLPLsize , maxblocksize , lplonly_flag , autopaging_flag , writelength )}
1125
1106
1126
1107
def get_module_fw_info (self ):
1127
1108
"""
@@ -1131,14 +1112,8 @@ def get_module_fw_info(self):
1131
1112
Administrative Status: 1=committed, 0=uncommitted
1132
1113
Validity Status: 1 = invalid, 0 = valid
1133
1114
"""
1134
- try :
1135
- self .cdb
1136
- except AttributeError :
1137
- self .get_cdb_api ()
1138
1115
txt = ''
1139
1116
# get fw info (CMD 0100h)
1140
- starttime = time .time ()
1141
- txt += 'Get module FW info\n '
1142
1117
rpllen , rpl_chkcode , rpl = self .cdb .get_fw_info ()
1143
1118
# password issue
1144
1119
if self .cdb .cdb_chkcode (rpl ) != rpl_chkcode :
@@ -1172,6 +1147,10 @@ def get_module_fw_info(self):
1172
1147
ImageB = "N/A"
1173
1148
txt += 'Image B Version: %s\n ' % ImageB
1174
1149
1150
+ if rpllen > 77 :
1151
+ factory_image = '%d.%d.%d' % (rpl [74 ], rpl [75 ], ((rpl [76 ] << 8 ) | rpl [77 ]))
1152
+ txt += 'Factory Image Version: %s\n ' % factory_image
1153
+
1175
1154
if ImageARunning == 1 :
1176
1155
RunningImage = 'A'
1177
1156
elif ImageBRunning == 1 :
@@ -1184,15 +1163,22 @@ def get_module_fw_info(self):
1184
1163
CommittedImage = 'B'
1185
1164
else :
1186
1165
CommittedImage = 'N/A'
1187
- txt += 'Running Image: %s; Committed Image: %s\n ' % (RunningImage , CommittedImage )
1166
+ txt += 'Running Image: %s\n ' % (RunningImage )
1167
+ txt += 'Committed Image: %s\n ' % (CommittedImage )
1168
+ txt += 'Active Firmware: {}\n ' .format (self .get_module_active_firmware ())
1169
+ txt += 'Inactive Firmware: {}\n ' .format (self .get_module_inactive_firmware ())
1188
1170
else :
1189
1171
txt += 'Reply payload check code error\n '
1190
1172
return {'status' : False , 'info' : txt , 'result' : None }
1191
- elapsedtime = time .time ()- starttime
1192
- logger .info ('Get module FW info time: %.2f s\n ' % elapsedtime )
1193
- logger .info (txt )
1194
1173
return {'status' : True , 'info' : txt , 'result' : (ImageA , ImageARunning , ImageACommitted , ImageAValid , ImageB , ImageBRunning , ImageBCommitted , ImageBValid )}
1195
1174
1175
+ def cdb_run_firmware (self , mode = 0x01 ):
1176
+ # run module FW (CMD 0109h)
1177
+ return self .cdb .run_fw_image (mode )
1178
+
1179
+ def cdb_commit_firmware (self ):
1180
+ return self .cdb .commit_fw_image ()
1181
+
1196
1182
def module_fw_run (self , mode = 0x01 ):
1197
1183
"""
1198
1184
This command is used to start and run a selected image.
@@ -1209,10 +1195,6 @@ def module_fw_run(self, mode = 0x01):
1209
1195
This function returns True if firmware run successfully completes.
1210
1196
Otherwise it will return False.
1211
1197
"""
1212
- try :
1213
- self .cdb
1214
- except AttributeError :
1215
- self .get_cdb_api ()
1216
1198
# run module FW (CMD 0109h)
1217
1199
txt = ''
1218
1200
starttime = time .time ()
@@ -1244,10 +1226,6 @@ def module_fw_commit(self):
1244
1226
This function returns True if firmware commit successfully completes.
1245
1227
Otherwise it will return False.
1246
1228
"""
1247
- try :
1248
- self .cdb
1249
- except AttributeError :
1250
- self .get_cdb_api ()
1251
1229
txt = ''
1252
1230
# commit module FW (CMD 010Ah)
1253
1231
starttime = time .time ()
@@ -1271,6 +1249,22 @@ def module_fw_commit(self):
1271
1249
logger .info (txt )
1272
1250
return True , txt
1273
1251
1252
+ def cdb_firmware_download_complete (self ):
1253
+ # complete FW download (CMD 0107h)
1254
+ return self .cdb .validate_fw_image ()
1255
+
1256
+ def cdb_start_firmware_download (self , startLPLsize , startdata , imagesize ):
1257
+ return self .cdb .start_fw_download (startLPLsize , bytearray (startdata ), imagesize )
1258
+
1259
+ def cdb_lpl_block_write (self , address , data ):
1260
+ return self .cdb .block_write_lpl (address , data )
1261
+
1262
+ def cdb_epl_block_write (self , address , data , autopaging_flag , writelength ):
1263
+ return self .cdb .block_write_epl (address , data , autopaging_flag , writelength )
1264
+
1265
+ def cdb_enter_host_password (self , password ):
1266
+ return self .cdb .module_enter_password (password )
1267
+
1274
1268
def module_fw_download (self , startLPLsize , maxblocksize , lplonly_flag , autopaging_flag , writelength , imagepath ):
1275
1269
"""
1276
1270
This function performs the download of a firmware image to module eeprom
@@ -1289,10 +1283,6 @@ def module_fw_download(self, startLPLsize, maxblocksize, lplonly_flag, autopagin
1289
1283
1290
1284
This function returns True if download successfully completes. Otherwise it will return False where it fails.
1291
1285
"""
1292
- try :
1293
- self .cdb
1294
- except AttributeError :
1295
- self .get_cdb_api ()
1296
1286
txt = ''
1297
1287
# start fw download (CMD 0101h)
1298
1288
starttime = time .time ()
@@ -1399,7 +1389,7 @@ def module_fw_upgrade(self, imagepath):
1399
1389
_ , _ , _ , _ , _ , _ , _ , _ = result ['result' ]
1400
1390
except (ValueError , TypeError ):
1401
1391
return result ['status' ], result ['info' ]
1402
- result = self .get_module_fw_upgrade_feature ()
1392
+ result = self .get_module_fw_mgmt_feature ()
1403
1393
try :
1404
1394
startLPLsize , maxblocksize , lplonly_flag , autopaging_flag , writelength = result ['result' ]
1405
1395
except (ValueError , TypeError ):
0 commit comments