本文整理匯總了Python中rtlsdr.RtlSdr.read_bytes方法的典型用法代碼示例。如果您正苦於以下問題:Python RtlSdr.read_bytes方法的具體用法?Python RtlSdr.read_bytes怎麽用?Python RtlSdr.read_bytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rtlsdr.RtlSdr
的用法示例。
在下文中一共展示了RtlSdr.read_bytes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: storing_stream_with_windows
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import read_bytes [as 別名]
def storing_stream_with_windows(l, device_number, folder, subfolders, center_frequency, samplerate, gain, nsamples, freq_correction,
user_hash):
l.acquire()
print(device_number, center_frequency, samplerate, gain, nsamples, freq_correction)
# configure device
sdr = RtlSdr(device_index=device_number)
sdr.center_freq = center_frequency
sdr.sample_rate = samplerate
if freq_correction:
sdr.freq_correction = freq_correction # PPM
sdr.gain = gain
print('hello world')
timestamp = time.mktime(time.gmtime())
samples = sdr.read_bytes(nsamples*2)
sdr.close()
l.release()
print("save")
basename = "{hash}_{freq}_{time:0.0f}".format(hash=user_hash, freq=center_frequency, time=timestamp)
filename = path.join(folder, subfolders[0], "tmp_" + basename)
# np.savez_compressed(filename, samples) # storing by numpy and copressing it
'''np.save(filename, samples)
os.rename(filename + ".npy",
path.join(folder, subfolders[0], basename + ".npy"))'''
f = open(filename, 'wb')
f.write(samples)
f.close()
os.rename(filename,
path.join(folder, subfolders[0], basename + ".dat"))
del samples
filename = path.join(folder, subfolders[1], basename + ".npy")
sdrmeta(filename, device_number, folder, subfolders, center_frequency,
samplerate, gain, nsamples, freq_correction, user_hash)
return filename