From 92fd8aa11b03f3b37f0b6cfe0ce5535f0805e50d Mon Sep 17 00:00:00 2001 From: Ed Date: Fri, 26 Apr 2024 11:28:33 +0100 Subject: [PATCH] Add sysex to loopback --- tests/test_midi/src/app_midi_simple.xc | 10 ++++++---- tests/test_midi_loopback.py | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_midi/src/app_midi_simple.xc b/tests/test_midi/src/app_midi_simple.xc index d56067e5..064dcb89 100644 --- a/tests/test_midi/src/app_midi_simple.xc +++ b/tests/test_midi/src/app_midi_simple.xc @@ -41,9 +41,7 @@ void board_setup(); #define CABLE_NUM 0 #endif -unsigned midi_in_parse_helper(unsigned midi[3]){ - struct midi_in_parse_state m_state; - reset_midi_state(m_state); +unsigned midi_in_parse_helper(unsigned midi[3], struct midi_in_parse_state &m_state){ unsigned valid = 0; unsigned packed = 0; @@ -108,6 +106,10 @@ void test(chanend c_midi){ int is_ack; unsigned rx_packet; + // Midi in parse state + struct midi_in_parse_state m_state; + reset_midi_state(m_state); + // Counters for Rx and Tx unsigned tx_cmd_count = 0; unsigned rx_cmd_count = 0; @@ -142,7 +144,7 @@ void test(chanend c_midi){ case tx_cmd_count < num_to_tx => tmr when timerafter(t_tx) :> int _: unsigned midi[] = {commands[tx_cmd_count][0], commands[tx_cmd_count][1], commands[tx_cmd_count][2]}; - unsigned tx_packet = midi_in_parse_helper(midi); + unsigned tx_packet = midi_in_parse_helper(midi, m_state); outuint(c_midi, byterev(tx_packet)); dprintf("Sent packet to midi: %u %u %u\n", commands[tx_cmd_count][0], commands[tx_cmd_count][1], commands[tx_cmd_count][2]); t_tx += tx_interval; diff --git a/tests/test_midi_loopback.py b/tests/test_midi_loopback.py index 4a21a753..6ccece37 100644 --- a/tests/test_midi_loopback.py +++ b/tests/test_midi_loopback.py @@ -29,7 +29,10 @@ def test_midi_loopback(capfd, build_midi): [0xe0, 0, 96], #pitch bend [0xff], #MIDI reset [0x80, 60, 81], #note off + [0xf0, 0x00, 0x21], [0x1D, 0x0b, 0x33], [0x3f, 0x1e, 0xf7], # Sysex, Ableton, 0b33f1e, terminator + [0xc0, 17], #instr select ] + create_midi_rx_file(len(midi_commands)) create_midi_tx_file(midi_commands) @@ -39,22 +42,22 @@ def test_midi_loopback(capfd, build_midi): simthreads = [] simargs = ["--max-cycles", str(MAX_CYCLES)] - #This is just for local debug so we can capture the traces if needed. It slows xsim down so not needed + #This is just for local debug so we can capture the traces if needed. It slows xsim down a lot # simargs.extend(["--trace-to", "trace.txt", "--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"]) Pyxsim.run_with_pyxsim( xe, simthreads=simthreads, - timeout=120, + timeout=180, simargs=simargs, ) capture = capfd.readouterr().out result = tester.run(capture.split("\n")) # Print to console - # with capfd.disabled(): - # print("++++", capture, "++++") - # print("----", expected, "----") + with capfd.disabled(): + print("CAPTURE ++++", capture, "++++") + print("EXPECTED ----", expected, "----") assert result \ No newline at end of file