本文整理汇总了Python中scanner.Scanner.get_debugfs_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.get_debugfs_dir方法的具体用法?Python Scanner.get_debugfs_dir怎么用?Python Scanner.get_debugfs_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.get_debugfs_dir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import get_debugfs_dir [as 别名]
def __init__(self, ifaces):
self.color_map = self.gen_pallete()
self.scanners = []
idx = 0
for iface in ifaces:
scanner = Scanner(iface, idx=idx)
scanner.mode_chanscan()
fn = '%s/spectral_scan0' % scanner.get_debugfs_dir()
reader = SpectrumFileReader(fn)
scanner.file_reader = reader
self.scanners.append(scanner)
idx += 1
self.dev_idx = 0 # id of currently selected device
if not os.path.exists("./spectral_data"):
os.mkdir("./spectral_data")
self.dump_to_file = False
self.dump_file = None
self.ui_update = True
self.bg_sample_count = 0
self.bg_sample_count_limit = 500
示例2: AthBenchmark
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import get_debugfs_dir [as 别名]
class AthBenchmark(object):
def __init__(self, iface):
self.scanner = Scanner(iface)
fn = '%s/spectral_scan0' % self.scanner.get_debugfs_dir()
self.file_reader = SpectrumFileReader(fn)
self.interface = iface
def get_samples(self, duration):
sps = 0
end = datetime.now() + timedelta(seconds=duration)
while datetime.now() < end:
try:
ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
except Queue.Empty:
continue
sps += len(samples) / (17 + 56) # (header + payload in HT20)
print "total: %d sps" % sps
sps /= float(duration)
return sps
# count samples in chanscan
def benchmark_chanscan(self, duration=5, samplecount=8):
print "\nrun benchmark chanscan with samplecount=%d, duration=%d " % (samplecount, duration)
self.scanner.cmd_set_samplecount(samplecount)
self.scanner.mode_chanscan()
self.scanner.start()
sps = self.get_samples(duration=duration)
self.scanner.stop()
self.file_reader.flush()
print "%.2f sps, chanscan" % sps
return sps
# count samples in bg mode (w/o) load
def benchmark_background(self, duration=5):
print "\nrun benchmark background with duration=%d " % duration
self.scanner.mode_noninvasive_background()
self.scanner.dev_add_monitor()
self.scanner.start()
sps = self.get_samples(duration=duration)
self.scanner.stop()
self.file_reader.flush()
print "%.2f sps, background scan " % sps
return sps
def benchmark_manual(self, samplecount=127):
print "\nrun benchmark manual with samplecount=%d " % samplecount
self.scanner.mode_manual()
self.scanner.cmd_manual()
self.scanner.cmd_set_samplecount(samplecount)
self.scanner.dev_add_monitor()
self.scanner.cmd_trigger()
sps = 0
reread = 3
while reread:
try:
ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
sps += len(samples) / (17 + 56) # (header + payload in HT20)
except Queue.Empty:
pass
reread -= 1
self.scanner.stop()
self.file_reader.flush()
print "got %d samples in manual mode" % sps
return sps
def main(self):
samplecount = [1, 10, 50, 100, 150, 200, 255]
for sc in samplecount:
sps = self.benchmark_chanscan( duration=5, samplecount=sc)
print "sps / samplecount: %.2f" % (sps / sc)
time.sleep(0.2)
self.benchmark_background(duration=5)
time.sleep(0.2)
self.benchmark_manual(samplecount=127)
time.sleep(0.2)
self.cleanup()
def cleanup(self):
# self.scanner.stop()
self.file_reader.stop()
示例3: Speccy
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import get_debugfs_dir [as 别名]
class Speccy(object):
heatmap = {}
max_per_freq = {}
freq_min = 2402.0
freq_max = 2472.0
power_min = -110.0
power_max = -20.0
last_x = freq_max
mpf_gen = 0
mpf_gen_tbl = {}
hmp_gen = 0
hmp_gen_tbl = {}
show_envelope = True
show_heatmap = True
lastframe = 0
redraws = 0
color_map = None
sf = None
def __init__(self, iface):
self.color_map = self.gen_pallete()
self.scanner = Scanner(iface)
fn = '%s/spectral_scan0' % self.scanner.get_debugfs_dir()
self.sf = spectrum_file.open(fn)
def quit(self, *args):
Gtk.main_quit()
def cleanup(self, *args):
self.scanner.stop()
def on_key_press(self, w, event):
key = Gdk.keyval_name(event.keyval)
if key == 's':
self.show_heatmap = not self.show_heatmap
elif key == 'l':
self.show_envelope = not self.show_envelope
elif key == 'q':
self.quit()
def gen_pallete(self):
# create a 256-color gradient from blue->green->white
start_col = (0.1, 0.1, 1.0)
mid_col = (0.1, 1.0, 0.1)
end_col = (1.0, 1.0, 1.0)
colors = [0] * 256
for i in range(0, 256):
if i < 128:
sf = (128.0 - i) / 128.0
sf2 = i / 128.0
colors[i] = (start_col[0] * sf + mid_col[0] * sf2,
start_col[1] * sf + mid_col[1] * sf2,
start_col[2] * sf + mid_col[2] * sf2)
else:
sf = (256.0 - i) / 128.0
sf2 = (i - 128.0) / 128.0
colors[i] = (mid_col[0] * sf + end_col[0] * sf2,
mid_col[1] * sf + end_col[1] * sf2,
mid_col[2] * sf + end_col[2] * sf2)
return colors
def sample_to_viewport(self, freq, power, wx, wy):
# normalize both frequency and power to [0,1] interval, and
# then scale by window size
freq_normalized = (freq - self.freq_min) / (self.freq_max - self.freq_min)
freq_scaled = freq_normalized * wx
power_normalized = (power - self.power_min) / (self.power_max - self.power_min)
power_scaled = power_normalized * wy
# flip origin to bottom left for y-axis
power_scaled = wy - power_scaled
return (freq_scaled, power_scaled)
def draw_centered_text(self, cr, text, x, y):
x_bearing, y_bearing, width, height = cr.text_extents(text)[:4]
cr.move_to(x - width / 2 - x_bearing, y - height / 2 - y_bearing)
cr.show_text(text)
def draw_grid(self, cr, wx, wy):
# clear the viewport with a black rectangle
cr.rectangle(0, 0, wx, wy)
cr.set_source_rgb(0, 0, 0)
cr.fill()
cr.set_source_rgb(1, 1, 1)
cr.set_line_width(0.5)
cr.set_dash([2.0, 2.0])
for freq in range(int(self.freq_min), int(self.freq_max), 5):
sx, sy = self.sample_to_viewport(freq, self.power_min, wx, wy)
ex, ey = self.sample_to_viewport(freq, self.power_max, wx, wy)
cr.move_to(sx, sy)
cr.line_to(ex, ey)
cr.stroke()
#.........这里部分代码省略.........