# File lib/commands/ultrasonic_sensor.rb, line 50
  def distance
    @nxt.ls_write(NXTComm.const_get("SENSOR_#{@port}"), [0x02, 0x01, 0x02, 0x42])
    
    # Keep checking until we have data to read
    while @nxt.ls_get_status(NXTComm.const_get("SENSOR_#{@port}")) < 1
      sleep(0.1)
      # TODO: implement timeout so we don't get stuck if the expected data never comes
    end
    
    distance = @nxt.ls_read(NXTComm.const_get("SENSOR_#{@port}"))[:data][0]
                
                if @mode == :centimeters
                  distance.inspect
          else
            (distance * 0.3937008).to_i
    end
  end