ifdefs for debug output. Fix host.rb
authorJohn Anderson <ardour@semiosix.com>
Wed, 4 Jul 2007 21:18:20 +0000 (21:18 +0000)
committerJohn Anderson <ardour@semiosix.com>
Wed, 4 Jul 2007 21:18:20 +0000 (21:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2105 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/scripts/host.rb
libs/surfaces/mackie/surface_port.cc
libs/surfaces/mackie/types.h

index 8972cba137869bc2ab2c5e9f585777e43973a123..4f3e4ec6055c4899286001309a878e1bc17a88f6 100755 (executable)
 require 'controls.rb'
 require 'mackie.rb'
 
+if ARGV.size != 2
+  puts "#$0 /dev/snd/midiXXXX control-file.csv"
+  exit 1
+end
+
 while !File.exist? ARGV[0]
   sleep 0.010
 end
@@ -30,46 +35,14 @@ puts ""
 file = File.open ARGV[0], 'r+'
 mck = Mackie.new( file )
 
-# send device query
-response = mck.sysex( "\x00" )
-puts "response: #{response.to_hex}"
-
-# decode host connection query
-status = response[0]
-if status != 1
-  puts "expected 01, got " + response.to_hex.inspect
-  exit(1)
-end
-serial = response[1..7]
-challenge = response[8..11]
-puts <<EOF
-serial: #{serial.to_hex.inspect}
-challenge: #{challenge.to_hex.inspect}
-EOF
-
-# send host connection reply
-response = mck.sysex( "\x02" + serial.pack('C*') + challenge.pack('C*') )
-
-# decode host connection confirmation
-status = response[0]
-if status != 3
-  puts "expected 03, got " + response.to_hex.inspect
-  exit(1)
-end
-
-serial = response[1..7]
-puts <<EOF
-serial: #{serial.to_hex.inspect}
-EOF
-
 # faders to minimum. bcf2000 doesn't respond
-#file.write( hdr + "\x61\xf7" )
+mck.write_sysex "\x61"
 
 # all leds off. bcf2000 doesn't respond
-#file.write( hdr + "\x62\xf7" )
+mck.write_sysex "\x62"
 
 # get version. comes back as ASCII bytes
-version = mck.sysex( "\x13\x00" )
+version = mck.sysex "\x13\x00"
 puts "version: #{version.map{|x| x.chr}}"
 
 # write a welcome message. bcf2000 responds with exact
index f0cdbdbe98a7b1619d46773a0f7bee2cb6b85cfb..e74ae93841491cf79b69f51ed9f37ae8181b7670 100644 (file)
@@ -71,7 +71,7 @@ MidiByteArray SurfacePort::read()
                
        if ( !lock.locked() )
        {
-               //cout << "SurfacePort::read not locked" << endl;
+               cout << "SurfacePort::read not locked" << endl;
                return retval;
        }
        
@@ -101,13 +101,18 @@ MidiByteArray SurfacePort::read()
                        throw MackieControlException( os.str() );
                }
        }
+#ifdef DEBUG
+       cout << "SurfacePort::read: " << retval << endl;
+#endif
        return retval;
 }
 
 void SurfacePort::write( const MidiByteArray & mba )
 {
+#ifdef DEBUG
        //if ( mba[0] == 0xf0 ) cout << "SurfacePort::write: " << mba << endl;
-       //cout << "SurfacePort::write: " << mba << endl;
+       cout << "SurfacePort::write: " << mba << endl;
+#endif
        
        // check active before and after lock - to make sure
        // that the destructor doesn't destroy the mutex while
@@ -130,7 +135,9 @@ void SurfacePort::write( const MidiByteArray & mba )
                        throw MackieControlException( os.str() );
                }
        }
-       //if ( mba[0] == 0xf0 ) cout << "SurfacePort::write " << count << endl;
+#ifdef DEBUG
+       if ( mba[0] == 0xf0 ) cout << "SurfacePort::write " << count << endl;
+#endif
 }
 
 void SurfacePort::write_sysex( const MidiByteArray & mba )
index 2b47e156408bfb7e2d1e1cf9f5f4d52e73a79aa7..ce15d6f6a96f6525eacbf9b2a5cf95364a2e9e1a 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef mackie_types_h
 #define mackie_types_h
 
+#define DEBUG 1
+
 namespace Mackie
 {