本文整理匯總了Python中rtlsdr.RtlSdr.kill方法的典型用法代碼示例。如果您正苦於以下問題:Python RtlSdr.kill方法的具體用法?Python RtlSdr.kill怎麽用?Python RtlSdr.kill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rtlsdr.RtlSdr
的用法示例。
在下文中一共展示了RtlSdr.kill方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import kill [as 別名]
#.........這裏部分代碼省略.........
if time.mktime(time.gmtime()) > recording_start - calibration_start and calibration_finished == 0:
sdr = RtlSdr(device_index=device_number)
sdr.center_freq = center_frequency
sdr.sample_rate = samplerate
# sdr.freq_correction = 1 # PPM
# calibrating the dongle
if gain_start >= gain_end or gain_start >= 49.0:
print("fixed gain")
if gain_start==0 or gain_start > 49.0:
print("autogain")
gain = 'auto'
else:
gain = gain_start
else:
print("calibrated gain")
gain = calibrating_gain_with_windows(sdr, samplerate, gain_step, gain_start,
gain_end, signal_threshold)
print("used gain", gain)
sdr.gain = gain
sdr.close()
calibration_finished = 1
utctime = time.mktime(time.gmtime())
if utctime >= recording_start and utctime <= recording_stop:
print("recording starts now...")
for recs in range(2):
p = Process(target=storing_stream_with_windows, args=(lock, device_number, folder, subfolders,
center_frequency, samplerate, gain, nsamples,
freq_correction, user_hash))
jobs.append(p)
p.start()
print("end")
while time.mktime(time.gmtime()) <= recording_stop:
time.sleep(2)
for n, p in enumerate(jobs):
if not p.is_alive() and time.mktime(time.gmtime()) <= recording_stop:
jobs.pop(n)
recs += 1
p = Process(target=storing_stream_with_windows, args=(lock, device_number, folder,
subfolders, center_frequency,
samplerate, gain, nsamples,
freq_correction, user_hash))
jobs.append(p)
p.start()
print("rec number", recs, 'added')
for job in jobs:
job.join()
elif platform.system() == "Linux" or platform.system() == "Linux2":
print("detecting a linux")
# getNumber_of_rtlsdrs_with_linux()
gain = 0
calibration_finished = 0
while time.mktime(time.gmtime()) <= recording_start or calibration_finished == 0:
# waiting for the time to be right :)
time.sleep(10)
print("still to wait", recording_start - time.mktime(time.gmtime()), "to record and",
recording_start - time.mktime(time.gmtime())- calibration_start, "to calibration")
if time.mktime(time.gmtime()) > recording_start - calibration_start and calibration_finished == 0:
if gain_start >= gain_end or gain_start >= 49.0:
print("fixed gain")
if gain_start==0 or gain_start > 49.0:
print("autogain")
gain = 0
else:
gain = gain_start
else:
print("calibrated gain")
gain = calibrating_gain_with_linux(device_number, center_frequency, samplerate, gain_step,
gain_start, gain_end, signal_threshold)
print("used gain", gain)
calibration_finished = 1
utctime = time.mktime(time.gmtime())
if utctime >= recording_start and utctime <= recording_stop:
print("recording starts now...")
rtl_sdr_exe = "rtl_sdr"
sdr = Popen([rtl_sdr_exe, "-d", str(device_number), "-f", str(center_frequency), "-s", str(samplerate),
"-g", str(gain), "-p", str(freq_correction), "-"],
stdout=PIPE, stderr=None)
while time.mktime(time.gmtime()) <= recording_stop:
stream_data = sdr.stdout.read(nsamples*2)
storing_stream_with_linux(stream_data, device_number, folder, subfolders, center_frequency, samplerate,
gain, nsamples, freq_correction, user_hash)
sdr.kill()
print("it's done. thank you, please come back again!")