Commit 67c2fd8d authored by Jean-Marie Favreau's avatar Jean-Marie Favreau
Browse files

Add ms to the timestamp considering acquisition is processed with a frequency of 84Hz

parent e85c0468
......@@ -12,6 +12,7 @@ parser = argparse.ArgumentParser(description="Convert RM42 (UKK) binary log file
parser.add_argument('input', metavar="INPUT", type=str, help='Input file (.dat format)')
parser.add_argument('output', metavar="OUTPUT", type=str, help='Output file (.csv format)')
parser.add_argument('-n', help="Store timestamp with a number", action='store_true')
parser.add_argument('--ms-84', help="Add milliseconds to each timestamp assuming that the data follows a frequency of 84Hz", action='store_true')
args = parser.parse_args()
......@@ -28,6 +29,7 @@ print("Output:", output_file)
number = args.n
ms84 = args.ms_84
encoding = Int16sl
......@@ -43,6 +45,10 @@ d_1sec = Struct(
"entries" / Array(84, Array(3, encoding)))
step_ms = int(1000. / 84)
step_us = step_ms * 1000
with open(input_file, 'rb') as f_input:
with open(output_file, 'w') as f_output:
print("timestamp;X_ax;Y_ax;Z_ax", file=f_output)
......@@ -57,13 +63,16 @@ with open(input_file, 'rb') as f_input:
seconds = binToHexUKK(result.seconds)
if (year != 2000 or month != 0 or day != 0 or hour != 0 or minutes != 0 or seconds != 0) and month <= 12 and month >= 1:
for entry in result.entries:
for i, entry in enumerate(result.entries):
entry_csv = ';'.join([str(e) for e in entry])
if number:
nb = datetime(year, month, day, hour, minutes, seconds, 0).timestamp()
nb = datetime(year, month, day, hour, minutes, seconds, i * step_us if ms84 else 0).timestamp()
print('{:f};{:s}'.format(nb, entry_csv), file=f_output)
else:
print('{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d};{:s}'.format(day, month, year, hour, minutes, seconds, entry_csv), file=f_output)
if ms84:
print('{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d}.{:03d};{:s}'.format(day, month, year, hour, minutes, seconds, i * step_ms, entry_csv), file=f_output)
else:
print('{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d};{:s}'.format(day, month, year, hour, minutes, seconds, entry_csv), file=f_output)
else:
print("skip wrong entry")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment