diff --git a/print_COM_as_bin_and_txt.py b/print_COM_as_bin_and_txt.py index 8787636..5c222b3 100644 --- a/print_COM_as_bin_and_txt.py +++ b/print_COM_as_bin_and_txt.py @@ -2,16 +2,16 @@ import os import serial import time -ser = serial.Serial('COM3', 115200) # change port to input port from arduino -filename = 'baud115200_0_2_TEST' +ser = serial.Serial('/dev/ttyACM0', 115200) # change port to input port from arduino +filename = 'BSI_Testdaten' start_time = time.time() # start time of read with open(filename + '.bin', 'wb') as file: - while os.path.getsize(filename + '.bin') < 2500: # change to the desired file size in bits/8 (1,000,000 Bits = 125000) + while os.path.getsize(filename + '.bin') < 128000000: # change to the desired file size in bits/8 (1,000,000 Bits = 125000) if ser.in_waiting > 0: data = ser.read(ser.in_waiting) # reading the data input from COM port - print(data) + #print(data) file.write(data) file.flush() # flush data to write @@ -34,10 +34,11 @@ with open(new_filename, 'rb') as f: hex_str = content.hex() # Convert the bytes to a string of binary digits -binary_str = ''.join(format(byte, '08b') for byte in content) +#binary_str = ''.join(format(byte, '08b') for byte in content) # Write the binary string back to the file -with open(new_filename.split('.')[0] + '_asTXT.txt', 'w') as f: - f.write(binary_str) +#with open(new_filename.split('.')[0] + '_asTXT.txt', 'w') as f: + #f.write(binary_str) print(f"time needed in seconds: {elapsed_time:.2f}. New filename: {new_filename}.") # console write +