Skip to content

Commit

Permalink
Added sysex.py as test for split SysEx messages including an interlea…
Browse files Browse the repository at this point in the history
…ved TimingClock command

Extra debug log line for partial SysEx messages
  • Loading branch information
ravelox committed May 4, 2020
1 parent 06e7a0f commit 80d40a7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
51 changes: 51 additions & 0 deletions python/sysex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/python

import sys
import socket
import struct
import time

local_port = 5006

if len(sys.argv) == 1:
family = socket.AF_INET
connect_tuple = ( 'localhost', local_port )
else:
details = socket.getaddrinfo( sys.argv[1], local_port, socket.AF_UNSPEC, socket.SOCK_DGRAM)
family = details[0][0]
if family == socket.AF_INET6:
connect_tuple = ( sys.argv[1], local_port, 0, 0)
else:
connect_tuple = ( sys.argv[1], local_port)

s = socket.socket( family, socket.SOCK_DGRAM )
s.connect( connect_tuple )

# Complete SysEx
bytes = struct.pack( "BBBBBB", 0xf0, 0x1, 0x2, 0x3, 0x04, 0xf7 )
s.send( bytes )


# Partial SysEx start
bytes = struct.pack( "BBBBBB", 0xf0, 0x1, 0x2, 0x3, 0x04, 0xf0 )
s.send( bytes )

# Partial SysEx middle
bytes = struct.pack( "BBBBBB", 0xf7, 0x1, 0x2, 0x3, 0x04, 0xf0 )
s.send( bytes )

# Partial SysEx middle
bytes = struct.pack( "BBBBBB", 0xf7, 0x1, 0x2, 0x3, 0x04, 0xf0 )
s.send( bytes )

# Partial SysEx end
bytes = struct.pack( "BBBBBB", 0xf7, 0x1, 0x2, 0x3, 0x04, 0xf7 )
s.send( bytes )


# Complete SysEx with interleaved TimingClock
bytes = struct.pack( "BBBBBBB", 0xf0, 0x1, 0x2, 0xf8, 0x3, 0x04, 0xf7 )
s.send( bytes )


s.close()
4 changes: 4 additions & 0 deletions raveloxmidi/src/midi_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ void midi_state_to_commands( midi_state_t *state , data_table_t **command_table,
{
logging_printf( LOGGING_DEBUG, "midi_state_to_commands: SYSEX 0xF0 read: Expected 0xF7\n");
}
if( state->partial_sysex == 1 )
{
logging_printf( LOGGING_DEBUG, "midi_state_to_commands: partial SysEx\n");
}
state->status = MIDI_STATE_WAIT_END_SYSEX;
state->running_status = 0;
// RFC6295 - p 19 - Unpaired 0xF7 cancels running status
Expand Down

0 comments on commit 80d40a7

Please sign in to comment.