From 0b7c335be0314b94d4cee97f8fcc5a26967767d0 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 8 Apr 2024 12:58:02 +0200 Subject: [PATCH] tests/psoc6/hw_ext/i2s.py: WIP i2S tests. Signed-off-by: enriquezgarc --- tests/psoc6/hw_ext/multi_blocking/i2s_rx.py | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/psoc6/hw_ext/multi_blocking/i2s_rx.py b/tests/psoc6/hw_ext/multi_blocking/i2s_rx.py index 554617a1f8c09..75c40a5a6fed0 100644 --- a/tests/psoc6/hw_ext/multi_blocking/i2s_rx.py +++ b/tests/psoc6/hw_ext/multi_blocking/i2s_rx.py @@ -104,7 +104,30 @@ def print_i2s_format(raw_buf, bits): print(s_tuple) -print_i2s_format(rx_buf, 16) +# print_i2s_format(rx_buf, 16) + + +def make_expected_sequence(): + len = 0xFF + expected_frame = bytearray(len) + for i in range(len): + expected_frame[i] = i + + return expected_frame + + +def find_sublist_in_list(full_list, sublist): + for i in range(len(full_list) - len(sublist) - 1): + if full_list[i : i + len(sublist)] == sublist: + return True + + return False + + +exp_seq = make_expected_sequence() + +print("Frame sequence detected : ", find_sublist_in_list(rx_buf, exp_seq)) + # rx_ascii = binascii.hexlify(rx_buf) # print(f'rx_buf = {rx_ascii}')