forked from PAWPAW-Mirror/lib_xua
Fix TX test
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
#ifndef MIDIOUTPARSE_XH
|
||||
#define MIDIOUTPARSE_XH
|
||||
|
||||
#warning MAYBE A SYSEX START AND FINISH IS SAFEST FOR NULL?
|
||||
#define MIDI_OUT_NULL_MESSAGE 0x00000000 // midi_out_parse will return a size of 0 for this invalid message/event
|
||||
// If for any reason we pop a message when not needed (should never happen) this will cause midiparse out to send a size of 0 (drops packet)
|
||||
#define MIDI_OUT_NULL_MESSAGE 0x00000000
|
||||
|
||||
#ifdef __XC__
|
||||
// Takes a MIDI packet and decomoses it into up to 3 data bytes followed by a byte count.
|
||||
{unsigned, unsigned, unsigned, unsigned} midi_out_parse(unsigned event);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -134,7 +134,9 @@ void test(chanend c_midi){
|
||||
} else {
|
||||
unsigned midi_data[3] = {0};
|
||||
unsigned byte_count = 0;
|
||||
// Even though this is an Rx from MIDI we use midi_out_parse so we can decode the packet
|
||||
{midi_data[0], midi_data[1], midi_data[2], byte_count} = midi_out_parse(byterev(rx_packet));
|
||||
dprintf("Got packet from MIDI: 0x%8x\n", rx_packet);
|
||||
// Note this needs to always print for capfd in pytest to pick it up
|
||||
printf("dut_midi_rx: %u %u %u\n", midi_data[0], midi_data[1], midi_data[2]);
|
||||
rx_cmd_count++;
|
||||
@@ -144,9 +146,10 @@ 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]};
|
||||
// Even though this is a Tx to MIDI we use midi_in_parse_helper to form the packet from bytes
|
||||
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]);
|
||||
dprintf("Sent packet to midi: %u %u %u (0x%8x)\n", commands[tx_cmd_count][0], commands[tx_cmd_count][1], commands[tx_cmd_count][2], tx_packet);
|
||||
t_tx += tx_interval;
|
||||
tx_end += max_tx_time;
|
||||
break;
|
||||
|
||||
@@ -27,9 +27,8 @@ def test_tx(capfd, config, build_midi):
|
||||
[0x90, 60, 81], # Note on
|
||||
[0x80, 60, 81]] # Note off
|
||||
|
||||
# midi_command_expected = midi_commands[1:] # should skip invalid first message
|
||||
# Make a 1D list from the 2D list
|
||||
midi_command_expected = [[item for row in midi_commands for item in row]]
|
||||
# Make a 1D list from the 2D list [1:] because first is invalid and we expect to skip it
|
||||
midi_command_expected = [[item for row in midi_commands[1:] for item in row]]
|
||||
|
||||
create_midi_tx_file(midi_commands)
|
||||
create_midi_rx_file()
|
||||
@@ -42,14 +41,14 @@ def test_tx(capfd, config, build_midi):
|
||||
bpb = 8
|
||||
parity = 0
|
||||
stop = 1
|
||||
length_of_test = sum(len(cmd) for cmd in midi_commands)
|
||||
length_of_test = sum(len(cmd) for cmd in midi_command_expected)
|
||||
|
||||
simthreads = [
|
||||
UARTTxChecker(tx_port, parity, baud, length_of_test, stop, bpb, debug=False)
|
||||
]
|
||||
|
||||
|
||||
simargs = ["--max-cycles", str(MAX_CYCLES), "-o", "trace.txt"]
|
||||
simargs = ["--max-cycles", str(MAX_CYCLES), "--trace-to", "trace.txt"]
|
||||
#This is just for local debug so we can capture the traces if needed. It slows xsim down so not needed
|
||||
# simargs.extend(["--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"])
|
||||
|
||||
@@ -60,6 +59,7 @@ def test_tx(capfd, config, build_midi):
|
||||
timeout=120,
|
||||
simargs=simargs,
|
||||
)
|
||||
|
||||
capture = capfd.readouterr().out
|
||||
result = tester.run(capture.split("\n"))
|
||||
|
||||
|
||||
@@ -94,7 +94,9 @@ class UARTTxChecker(px.SimThread):
|
||||
if self.debug: print("tx starts high: %s" % ("True" if initial_port_val else "False"))
|
||||
|
||||
for x in range(length):
|
||||
packet.append(chr(self.read_byte(xsi, parity)))
|
||||
byte = self.read_byte(xsi, parity)
|
||||
if self.debug: print(f"Checker got byte: {byte}")
|
||||
packet.append(chr(byte))
|
||||
return packet
|
||||
|
||||
def read_byte(self, xsi, parity):
|
||||
|
||||
Reference in New Issue
Block a user