@@ -242,6 +242,9 @@ def __call__(self, string):
242
242
help = "local path to store the file contents in" )
243
243
parser_read_file .add_argument (
244
244
"--file-id" , type = auto_int , default = - 1 , help = "if filename not available you can read a file by its id" )
245
+ parser_read_file .add_argument (
246
+ "--inactive" , action = "store_true" ,
247
+ help = "read from inactive FAT copy" )
245
248
246
249
parser_write_flash = subparsers .add_parser (
247
250
"write_flash" , help = "Write a Gang image on the flash" )
@@ -290,6 +293,9 @@ def __call__(self, string):
290
293
parser_read_all_files .add_argument (
291
294
"--all-by-file-id" , action = "store_true" ,
292
295
help = "Read all filenames by its id" )
296
+ parser_read_all_files .add_argument (
297
+ "--inactive" , action = "store_true" ,
298
+ help = "read from inactive FAT copy" )
293
299
294
300
parser_write_all_files = subparsers .add_parser (
295
301
"write_all_files" ,
@@ -894,7 +900,7 @@ def _raw_read(self, offset, size, storage_id=STORAGE_ID_SRAM, sinfo=None):
894
900
def _exec_from_ram (self ):
895
901
self ._send_packet (OPCODE_EXEC_FROM_RAM )
896
902
897
- def _get_file_info (self , filename , file_id = - 1 ):
903
+ def _get_file_info (self , filename , file_id = - 1 , inactive = False ):
898
904
if not self .port is None and file_id == - 1 :
899
905
command = OPCODE_GET_FILE_INFO \
900
906
+ struct .pack (">I" , len (filename )) \
@@ -905,7 +911,7 @@ def _get_file_info(self, filename, file_id=-1):
905
911
raise CC3200Error ()
906
912
return CC3x00FileInfo .from_packet (finfo )
907
913
908
- fat_info = self .get_fat_info (inactive = False )
914
+ fat_info = self .get_fat_info (inactive = inactive )
909
915
finfo = CC3x00FileInfo (exists = False , size = 0 )
910
916
for file in fat_info .files :
911
917
if file_id == - 1 :
@@ -1154,8 +1160,8 @@ def _write_file_api(self, local_file, cc_filename, sign_data, fs_flags, size, fi
1154
1160
log .debug ("Closing file ..." )
1155
1161
return self ._close_file (sign_data )
1156
1162
1157
- def read_file (self , cc_fname , local_file , file_id = - 1 ):
1158
- finfo = self ._get_file_info (cc_fname , file_id )
1163
+ def read_file (self , cc_fname , local_file , file_id = - 1 , inactive = False ):
1164
+ finfo = self ._get_file_info (cc_fname , file_id , inactive )
1159
1165
if not finfo .exists :
1160
1166
raise CC3200Error (f"{ cc_fname } does not exist on target" )
1161
1167
@@ -1179,7 +1185,7 @@ def read_file(self, cc_fname, local_file, file_id=-1):
1179
1185
self ._close_file ()
1180
1186
return
1181
1187
1182
- fat_info = self .get_fat_info (inactive = False , extended = True )
1188
+ fat_info = self .get_fat_info (inactive = inactive , extended = True )
1183
1189
filefinfo = None
1184
1190
for file in fat_info .files :
1185
1191
if file_id == - 1 :
@@ -1284,8 +1290,8 @@ def list_filesystem(self, json_output=False, inactive=False, extended=False):
1284
1290
if json_output :
1285
1291
fat_info .print_sffs_info_json ()
1286
1292
1287
- def read_all_files (self , local_dir , by_file_id = False , all_by_file_id = False ):
1288
- fat_info = self .get_fat_info (inactive = False )
1293
+ def read_all_files (self , local_dir , by_file_id = False , all_by_file_id = False , inactive = False ):
1294
+ fat_info = self .get_fat_info (inactive = inactive )
1289
1295
fat_info .print_sffs_info ()
1290
1296
for f in fat_info .files :
1291
1297
ccname = f .fname
@@ -1304,9 +1310,9 @@ def read_all_files(self, local_dir, by_file_id=False, all_by_file_id=False):
1304
1310
1305
1311
try :
1306
1312
if all_by_file_id or ( by_file_id and f .fname == '' ):
1307
- self .read_file (ccname , open (target_file , 'wb' , - 1 ), f .index )
1313
+ self .read_file (ccname , open (target_file , 'wb' , - 1 ), f .index , inactive = inactive )
1308
1314
else :
1309
- self .read_file (f .fname , open (target_file , 'wb' , - 1 ))
1315
+ self .read_file (f .fname , open (target_file , 'wb' , - 1 ), inactive = inactive )
1310
1316
except Exception as ex :
1311
1317
log .error ("File %s could not be read, %s" % (f .fname , str (ex )))
1312
1318
@@ -1414,7 +1420,7 @@ def main():
1414
1420
check_fat = True
1415
1421
1416
1422
if command .cmd == "read_file" :
1417
- cc .read_file (command .cc_filename , command .local_file , command .file_id )
1423
+ cc .read_file (command .cc_filename , command .local_file , command .file_id , command . inactive )
1418
1424
1419
1425
if command .cmd == "erase_file" :
1420
1426
log .info ("Erasing file %s" , command .filename )
@@ -1430,7 +1436,7 @@ def main():
1430
1436
cc .list_filesystem (command .json_output , command .inactive , command .extended )
1431
1437
1432
1438
if command .cmd == "read_all_files" :
1433
- cc .read_all_files (command .local_dir , command .by_file_id , command .all_by_file_id )
1439
+ cc .read_all_files (command .local_dir , command .by_file_id , command .all_by_file_id , command . inactive )
1434
1440
1435
1441
if command .cmd == "write_all_files" :
1436
1442
use_api = True
0 commit comments