parent
6d1400545a
commit
22cf5083c2
|
@ -2,16 +2,16 @@ import os
|
||||||
import serial
|
import serial
|
||||||
import time
|
import time
|
||||||
|
|
||||||
ser = serial.Serial('COM3', 115200) # change port to input port from arduino
|
ser = serial.Serial('/dev/ttyACM0', 115200) # change port to input port from arduino
|
||||||
filename = 'baud115200_0_2_TEST'
|
filename = 'BSI_Testdaten'
|
||||||
|
|
||||||
start_time = time.time() # start time of read
|
start_time = time.time() # start time of read
|
||||||
|
|
||||||
with open(filename + '.bin', 'wb') as file:
|
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:
|
if ser.in_waiting > 0:
|
||||||
data = ser.read(ser.in_waiting) # reading the data input from COM port
|
data = ser.read(ser.in_waiting) # reading the data input from COM port
|
||||||
print(data)
|
#print(data)
|
||||||
file.write(data)
|
file.write(data)
|
||||||
file.flush() # flush data to write
|
file.flush() # flush data to write
|
||||||
|
|
||||||
|
@ -34,10 +34,11 @@ with open(new_filename, 'rb') as f:
|
||||||
hex_str = content.hex()
|
hex_str = content.hex()
|
||||||
|
|
||||||
# Convert the bytes to a string of binary digits
|
# 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
|
# Write the binary string back to the file
|
||||||
with open(new_filename.split('.')[0] + '_asTXT.txt', 'w') as f:
|
#with open(new_filename.split('.')[0] + '_asTXT.txt', 'w') as f:
|
||||||
f.write(binary_str)
|
#f.write(binary_str)
|
||||||
|
|
||||||
print(f"time needed in seconds: {elapsed_time:.2f}. New filename: {new_filename}.") # console write
|
print(f"time needed in seconds: {elapsed_time:.2f}. New filename: {new_filename}.") # console write
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue