Skip to content

Commit ca36cf0

Browse files
committed
fix decoder
1 parent 3d6a3cf commit ca36cf0

File tree

6 files changed

+8
-96
lines changed

6 files changed

+8
-96
lines changed

1.fsdaq

14.2 MB
Binary file not shown.

2.fsdaq

10.7 MB
Binary file not shown.

3.fsdaq

22.3 MB
Binary file not shown.

Telemetry-Main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ int row_idx = 0;
120120
void update_sd() {
121121
if (row_idx == ROWS) {
122122
write_fsdaq_batch(&vals, sd_fp);
123+
row_idx = 0;
123124
} else {
124125
vals.setRow(current_row, row_idx);
125-
126126
row_idx++;
127127
}
128128
}

Telemetry-SD-Card/decoder.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
"f5": np.float32,
2424
"f6": np.float64,
2525
"b0": bool
26-
}
26+
}
2727

28-
with open (args.input_file, "rb" ) as f:
29-
# f = open("test.fsdaq", "rb")
30-
df = pl.DataFrame()
28+
with open(args.input_file, "rb" ) as f:
3129
batchlen = 0
3230
data = f.read()
33-
# print(ascii(data))
3431
header = ascii(data[:8])
3532
m = np.frombuffer(data[8:12], dtype=np.uint32, count=1)[0]
3633
n = np.frombuffer(data[12:16], dtype=np.uint32, count=1)[0]
@@ -48,13 +45,13 @@
4845
colType = data[pos:pos+2].decode('ascii')
4946
colTypes.append((types_dict[colType], int((2**int(colType[1]))/8*n)))
5047
pos += 2
51-
# print(colTypes)
5248
data_left = len(data[pos:])
5349
len_of_frame = sum([x[1] for x in colTypes])
5450
chunks = np.floor(data_left / len_of_frame)
5551
misc_bytes = (data_left % len_of_frame) - 8
5652
print(f"chunks left: {chunks}")
5753
print(f"misc bytes left: {misc_bytes}")
54+
frames = []
5855
for i in range(int(chunks)):
5956
frame_pieces = []
6057
for i in range(m):
@@ -79,12 +76,8 @@
7976
frame_piece_series = pl.Series(colTitles[i], col_bit)
8077
frame_pieces.append(frame_piece_series)
8178
pos += col_byte_len
82-
frame_piece = pl.DataFrame(frame_pieces)
83-
# print(frame_pieces)
84-
if df.is_empty():
85-
df = frame_piece
86-
else:
87-
df = df.vstack(frame_piece)
88-
# print(df)
79+
frames.append(pl.DataFrame(frame_pieces))
80+
df = pl.concat(frames, how="vertical")
81+
# print(df)
8982
print(f"Stuff Left: {ascii(data[pos:])}")
90-
df.write_csv(args.output_file)
83+
df.write_csv(args.output_file)

0 commit comments

Comments
 (0)