diff --git a/pi_numbers_separated_I2C_function.py b/pi_numbers_separated_I2C_function.py index 9e468c6..70821d9 100644 --- a/pi_numbers_separated_I2C_function.py +++ b/pi_numbers_separated_I2C_function.py @@ -115,30 +115,24 @@ def analyze_data(num_numbers, bits_per_number, startup=False): os.unlink(binary_filename) else: - filename = read_data(num_numbers, bits_per_number) - binary_filename = convert_to_binary(filename, num_numbers, bits_per_number) - hex_filename = convert_to_hex(binary_filename, num_numbers, bits_per_number) + filename = read_data(10, 20000) + binary_filename = convert_to_binary(filename, 10, 20000) result = perform_tot_online_tests(binary_filename) - with open(hex_filename, 'rb') as f: + os.unlink(filename) + os.unlink(binary_filename) + if result: + filename = read_data(num_numbers, bits_per_number) + binary_filename = convert_to_binary(filename, num_numbers, bits_per_number) + hex_filename = convert_to_hex(binary_filename, num_numbers, bits_per_number) + with open(hex_filename, 'rb') as f: # Read the contents of the file as bytes - hex_return = f.read() - print(hex_return) - os.unlink(filename) - os.unlink(hex_filename) - os.unlink(binary_filename) - if result: - return hex_return - else: - filename = read_data(10, 80000) - binary_filename = convert_to_binary(filename, 10, 80000) - SUTres = perform_startup_tests(binary_filename) - TOTres = perform_tot_online_tests(binary_filename) - if SUTres and TOTres: - os.unlink(filename) - os.unlink(binary_filename) - return hex_return - else: - return False + hex_return = f.read() + os.unlink(filename) + os.unlink(binary_filename) + os.unlink(hex_filename) + return hex_return + else: + return False # Teste den Code result = analyze_data(50, 2560, startup=False)