 
 		@wire = wire  if debug.mode
 
+
 	mode: (port, mode, callback) ->
 		unless modes[port]? is mode
 			modes[port] = mode
 			@send CMD.mode, port, [mode, 0], -> callback()
+
 
 	send: ( cmd, port, args... ) ->
 		writeArgs = [cmd]


		wire[writeCmd] writeArgs...

	sendWithMode: (cmd, port) ->
		args = arguments
		@mode port, MODES.output, => @send args...

	receiveWithMode: (port) ->
		args = arguments
		@mode port, MODES.input, => @send args...



	receive: ( port, args... ) ->


		wire[readCmd] readArgs...



	sendWithMode: (cmd, port) ->
		args = arguments
		@mode port, MODES.output, => @send args...


	receiveWithMode: (port) ->
		args = arguments
		@mode port, MODES.input, => @send args...


	write: ( type, port, data, callback ) ->
		@sendWithMode CMD[type + '_write'], port, data, callback


	read: ( type, args... ) ->
		@sendWithMode CMD[type + '_read'], args...


	ranger: ( port, callback ) ->
		@sendWithMode CMD.ranger, port, [0,0], =>
			@receiveWithMode 3, (data) ->
				callback data[2] + data[1]

