Add sysex to loopback

This commit is contained in:
Ed
2024-04-26 11:28:33 +01:00
parent 6562a35b73
commit 92fd8aa11b
2 changed files with 14 additions and 9 deletions

View File

@@ -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;

View File

@@ -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