From e31ccb181386da0a42024fc7ec3485c49838daf6 Mon Sep 17 00:00:00 2001 From: Fisch Date: Tue, 16 Jul 2024 22:36:28 +0200 Subject: [PATCH] add name main check --- logdata_visualization/copyLogsFromBobbycar.py | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/logdata_visualization/copyLogsFromBobbycar.py b/logdata_visualization/copyLogsFromBobbycar.py index 813ca99..b7022c3 100644 --- a/logdata_visualization/copyLogsFromBobbycar.py +++ b/logdata_visualization/copyLogsFromBobbycar.py @@ -148,51 +148,50 @@ def delete_file(filename): exit() -if serialport.isOpen(): - - establish_connection() - - - #Get File List - filenames=get_filenames() - - - #Copy all Files - failed=0 - - for filename in filenames: - print("Reading file "+filename) - expectedsize=get_filesize(filename) - print("Expecting "+str(expectedsize)+" Byte") - - writefilename='sdcard/'+filename - receivedsize=copy_file(filename,writefilename,expectedsize) +if __name__ == "__main__": + if serialport.isOpen(): + + establish_connection() - if (expectedsize!=receivedsize): - print("Warning: Filesize does not match!") - failed+=1 - - print("") - - print(str(len(filenames))+" Files copied with "+str(failed)+" failed") - - - - #Delete all files - ''' - log_off() - for filename in filenames: - delete_file(filename) - ''' - - -serialport.write("echo on\n".encode()) + #Get File List + filenames=get_filenames() - + #Copy all Files + + failed=0 + + for filename in filenames: + print("Reading file "+filename) + expectedsize=get_filesize(filename) + print("Expecting "+str(expectedsize)+" Byte") -serialport.close() + writefilename='sdcard/'+filename + receivedsize=copy_file(filename,writefilename,expectedsize) + + if (expectedsize!=receivedsize): + print("Warning: Filesize does not match!") + failed+=1 + + print("") + + print(str(len(filenames))+" Files copied with "+str(failed)+" failed") + + + + #Delete all files + + ''' + log_off() + for filename in filenames: + delete_file(filename) + ''' + + + serialport.write("echo on\n".encode()) + + serialport.close()