forked from PAWPAW-Mirror/lib_xua
Add sysex to loopback
This commit is contained in:
@@ -41,9 +41,7 @@ void board_setup();
|
|||||||
#define CABLE_NUM 0
|
#define CABLE_NUM 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned midi_in_parse_helper(unsigned midi[3]){
|
unsigned midi_in_parse_helper(unsigned midi[3], struct midi_in_parse_state &m_state){
|
||||||
struct midi_in_parse_state m_state;
|
|
||||||
reset_midi_state(m_state);
|
|
||||||
|
|
||||||
unsigned valid = 0;
|
unsigned valid = 0;
|
||||||
unsigned packed = 0;
|
unsigned packed = 0;
|
||||||
@@ -108,6 +106,10 @@ void test(chanend c_midi){
|
|||||||
int is_ack;
|
int is_ack;
|
||||||
unsigned rx_packet;
|
unsigned rx_packet;
|
||||||
|
|
||||||
|
// Midi in parse state
|
||||||
|
struct midi_in_parse_state m_state;
|
||||||
|
reset_midi_state(m_state);
|
||||||
|
|
||||||
// Counters for Rx and Tx
|
// Counters for Rx and Tx
|
||||||
unsigned tx_cmd_count = 0;
|
unsigned tx_cmd_count = 0;
|
||||||
unsigned rx_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 _:
|
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 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));
|
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]);
|
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;
|
t_tx += tx_interval;
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ def test_midi_loopback(capfd, build_midi):
|
|||||||
[0xe0, 0, 96], #pitch bend
|
[0xe0, 0, 96], #pitch bend
|
||||||
[0xff], #MIDI reset
|
[0xff], #MIDI reset
|
||||||
[0x80, 60, 81], #note off
|
[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_rx_file(len(midi_commands))
|
||||||
create_midi_tx_file(midi_commands)
|
create_midi_tx_file(midi_commands)
|
||||||
|
|
||||||
@@ -39,22 +42,22 @@ def test_midi_loopback(capfd, build_midi):
|
|||||||
simthreads = []
|
simthreads = []
|
||||||
|
|
||||||
simargs = ["--max-cycles", str(MAX_CYCLES)]
|
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"])
|
# simargs.extend(["--trace-to", "trace.txt", "--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"])
|
||||||
|
|
||||||
Pyxsim.run_with_pyxsim(
|
Pyxsim.run_with_pyxsim(
|
||||||
xe,
|
xe,
|
||||||
simthreads=simthreads,
|
simthreads=simthreads,
|
||||||
timeout=120,
|
timeout=180,
|
||||||
simargs=simargs,
|
simargs=simargs,
|
||||||
)
|
)
|
||||||
capture = capfd.readouterr().out
|
capture = capfd.readouterr().out
|
||||||
result = tester.run(capture.split("\n"))
|
result = tester.run(capture.split("\n"))
|
||||||
|
|
||||||
# Print to console
|
# Print to console
|
||||||
# with capfd.disabled():
|
with capfd.disabled():
|
||||||
# print("++++", capture, "++++")
|
print("CAPTURE ++++", capture, "++++")
|
||||||
# print("----", expected, "----")
|
print("EXPECTED ----", expected, "----")
|
||||||
|
|
||||||
|
|
||||||
assert result
|
assert result
|
||||||
Reference in New Issue
Block a user