欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    gunradio软件无线电发送接收字符程序.docx

    • 资源ID:14692487       资源大小:19.19KB        全文页数:14页
    • 资源格式: DOCX        下载积分:1金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要1金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    gunradio软件无线电发送接收字符程序.docx

    1、gunradio软件无线电发送接收字符程序GNU RADIO软件无线电benchmark程序发送接收文件测试笔记 在GNU RADIO软件无线电程序中,benchmark程序能够发射900MHZ,接收900MHZ的无线电信号。具体做法是,把两台装有Basic子板的USRP1母板别离连上两台电脑的USB端口上,接通电源,在ubuntu操作系统下,在其中一台电脑的终端提示符下键入:“ cd /usr/local/share/gnuradio/example/digital/进入benchmark程序的目录, 再键入:“./ -f 900M这时候,和这台电脑USB端口连接的USRP母板上的LFTX子

    2、板通过电线就会发送一个900MHZ的无线电信号,电脑显示器显示:.表示正在发射无线电信号。这时,在另外的一台电脑上的终端提示符下键入:“ cd /usr/locaul/share/gnuradio/example/digital/进入benchmark程序的目录, 再键入:“./ -f 900M这时候,和这台电脑USB端口连接的USRP母板上的LFTX子板通过电线就会收到一个900MHZ的无线电信号,电脑显示器显示:ok=True pktno=1202 n_rcvd=1 n_right=0表明接收信号正常。 现在的问题是要从这个电脑发送一个文件到另外一个电脑,我查找了相关资料发现,benchm

    3、ark具有发送文件的功能,但是开源程序里没有这项功能,需要用户依照自己的需要修改程序来达到发送接收文件的功能。我通过研究发觉,修改程序后,能够把这台电脑的文件的“hello“字符发送到另外一台 电脑的文件中。具体做法是,在发送端电脑的/usr/local/share/gnuradio/example/digital目录下新建,两个文本文件,在中输入hello并保留,然后在终端下输入:“vi 在vi编辑器下打开程序,在第124行 () # start flow graph,后输入 “f=open(/usr/local/share/gnuradio/examples/digital/,r)” “l

    4、ines=()”两行新程序,第一行程序是以只读方式打开文件,第二行程序的作用是以每行阅读的方式读出中的文本内容,然后再赋值给lines数组,接着把第140行程序payload = (!H, pktno & 0xffff) + data 改为 payload = str ) + str(lines) 这步的作用是,去掉了打包发送pkno函数的功能,而加入发送lines函数和函数的功能。 此刻说一下函数是从哪来的。第一把程序的第95行至第100行,改成 (-E,-discontinuous, action=store_true, default=False, help=enable discont

    5、inous transmission (bursts of 5 packets) (-W,-from_file,dest=from_file, default=None, help=use intput file for packet contents) (-T,-to_file,dest=to_file, default=None, help=Output file for modulated samples) (-n,-num,type=int,dest=num,default=1000, help=send message) (-e, -file,dest=filename, help=

    6、write report to FILE,metavar=FILE) (-p, -pdbk, action=store_true, dest=pdcl, default=False, help=write pdbk data to oracle db) (-z, -zdbk, action=store_true, dest=zdcl, default=False, help=write zdbk data to oracle db) 简单说一下,在终端输入“benchmark_tx -f 900M -n 1500”时,程序以900MHZ的频率发送数组中的数字1500和lines数组,因为(-n

    7、,-num,type=int,dest=num,default=1000, help=send message)定义了一个属性是num的函数通过提示符-n xxx来返回一个值给数组, 上面其他程序的作用是定义了在终端提示符下发送文件-W,接收文件-T,写入给数据库-p,读取数据库-z, 其他功能这里暂时不讨论。修改完成后保存文件,退出vi编辑器。 下来在接收端的电脑上的/usr/local/share/gnuradio/example/digital/narrowband目录下新建,两个空白文本文件,然后在终端下输入:“vi 在vi编辑器下打开程序,把第79行到第98行的内容改为global

    8、n_rcvd, n_rightglobal n_datadef main(): global n_rcvd, n_right global n_data n_rcvd = 0 n_right = 0 n_data = str() def rx_callback(ok, payload): global n_rcvd, n_right global n_data (pktno,) = (!H, payload0:2) n_data = payload0:4096 f=open(/usr/local/share/gnuradio/examples/digital/,w) (payload) n_r

    9、cvd += 1 if ok: n_right += 1 print ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d n_data = %5s % ( ok, pktno, n_rcvd, n_right, n_data)其中,n_data = payload0:4096定义变量n_data用来显示接收的数组和lines数组。 还有上述 f=open(/usr/local/share/gnuradio/examples/digital/narrowband/,w) (payload)两行程序实现了以写入方式打开文本文件,然后把接收的payload

    10、数组写入中。保存修改退出vi编辑器后,在发送端的电脑/usr/local/share/gnuradio/example/digital的目录下键入./ -f 900M -n 1900后,电脑显示.表示发送正常,然后在接收端电脑/usr/local/share/gnuradio/example/digital的目录下键入./ -f 900M 电脑显示ok = True pktno = 12598 n_rcvd = 458 n_right = 458 n_data = 1900hellon表示接收正常。用“ctrl+c”键停止接收,打开接收端电脑/usr/local/share/gnuradio/

    11、example/digital/的目录下的文件,发觉原先是空文件的,显现hellon显示,表示发送接收正常.说明发送端电脑上的文件中的“hello”字符已经传送到接收端电脑的文件中。 给发送端电脑的文件中添加字符,如把“hello”改成“hello python”,接收端点脑上的文件中显示“hello pythonn,说明同意正常,当中字符的长度超过3571个字节时,接收端就会显示乱码,因为每次程序只能发送低于3571字节的 文本,一旦文本超过了3571字节,发送的信息量太大就会使程序读入数据犯错,接收端就会收到乱码,要传送更多字节的文本就要修改程序,那个问题还在研究,此刻不做讨论。 下面测试

    12、一下能不能用其他子板正常发送接收文本。把上面的两个Basic子板换成两个WBX子板,WBX子板上都连有天线。测试后发觉接收端的就会显示乱码和误码。例如 原先发送文本中的hello,接收到的文本却是为welp&*%。造成那个结果的缘故是WBX子板靠天线发送 信号,而LFRX子板是通过屏蔽线传输信号。WBX子板发送无线电后,由于空间中的干扰,无线电信号在传输中会产生衰减和转变,另外的WBX子板接收到的 无线电信号就会和发送的无线电信号不同。要想传输的内容不发生转变,就要修改程序,使每次只发送一个数据,如此接收就不容易产生误码和乱码。修改程序后,把中的payload = data + str(lin

    13、es) + chr & 0xff) 改为 payload = str(lines) “作用是只把 lines的值赋给发送函数paload,相当于只发送了lines数组。同时把发送端电脑的文件里的“hello”改成“h”,只发送一个字符h,减少了传送的数据量,现在运行接收./ -f 900M 和发送./ -f 900M发觉接收端电脑的文本显示h;说明接收成功附件:源码#!/usr/bin/python#!/usr/bin/env python# Copyright 2020,2020,2021 Free Software Foundation, Inc.# # This file is part

    14、 of GNU Radio# # GNU Radio is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 3, or (at your option)# any later version.# # GNU Radio is distributed in the hope that it will be us

    15、eful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# # You should have received a copy of the GNU General Public License# along with GNU Radio; see the file COPYING. If not,

    16、write to# the Free Software Foundation, Inc., 51 Franklin Street,# Boston, MA 02110-1301, USA.# from gnuradio import gr, grufrom gnuradio import blocksfrom gnuradio import eng_notationfrom import eng_optionfrom optparse import OptionParser# From gr-digitalfrom gnuradio import digital# from current d

    17、irfrom receive_path import receive_pathfrom uhd_interface import uhd_receiverimport structimport sys#import os#print ()#raw_input(Attach and press enter: )class my_top_block: def _init_(self, demodulator, rx_callback, options): if is not None): # Work-around to get the modulations bits_per_symbol ar

    18、gs = (options) symbol_rate = / demodulator(*args).bits_per_symbol() = uhd_receiver, symbol_rate, , , , , , , , = elif is not None): Reading samples from %s.nn % ) = , else: No source defined, pulling samples from null source.nn) = # Set up receive path # do this after for any adjustments to the opti

    19、ons that may # occur in the sinks (specifically the UHD sink) = receive_path(demodulator, rx_callback, options) , # oin(),) (,-from-file, default=None, help=input file of samples to demod) (parser, expert_grp) (parser) for mod in (): (expert_grp) (options, args) = () if len(args) != 0: (1) if is Non

    20、e: if is None: You must specify -f FREQ or -freq FREQn) (1) # build the graph tb = my_top_block(demods, rx_callback, options) r = () if r != : print Warning: Failed to enable realtime scheduling. () # start flow graph () # wait for it to finishif _name_ = _main_: try: main() except KeyboardInterrupt

    21、: pass源码#!/usr/bin/python#!/usr/bin/env python# Copyright 2020,2020,2021 Free Software Foundation, Inc.# # This file is part of GNU Radio# # GNU Radio is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foun

    22、dation; either version 3, or (at your option)# any later version.# # GNU Radio is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details

    23、.# # You should have received a copy of the GNU General Public License# along with GNU Radio; see the file COPYING. If not, write to# the Free Software Foundation, Inc., 51 Franklin Street,# Boston, MA 02110-1301, USA.# from gnuradio import grfrom gnuradio import blocksfrom gnuradio import eng_notat

    24、ionfrom import eng_optionfrom optparse import OptionParser#diaoyong minglinghang chuli canshu# From gr-digitalfrom gnuradio import digital# from current dirfrom transmit_path import transmit_pathfrom uhd_interface import uhd_transmitterimport time, struct, sys#import os #print ()#raw_input(Attach an

    25、d press enter)class my_top_block: def _init_(self, modulator, options): if is not None): # Work-around to get the modulations bits_per_symbol args = (options) symbol_rate = / modulator(*args).bits_per_symbol() = uhd_transmitter, symbol_rate, , , , , , , , = elif is not None): Saving samples to %s.nn

    26、 % ) = , else: No sink defined, dumping samples to null sink.nn) = # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) = transmit_path(modulator, options) , # oin(),) (-s, -size, type=eng_float, default=1500, help=set packet size default=%defa

    27、ult) (-M, -megabytes, type=eng_float, default=, help=set megabytes to transmit default=%default) (-E,-discontinuous, action=store_true, default=False, help=enable discontinous transmission (bursts of 5 packets) (-W,-from_file,dest=from_file, default=None, help=use intput file for packet contents) (-

    28、T,-to_file,dest=to_file, default=None, help=Output file for modulated samples) (-n,-num,type=int,dest=num,default=1000, help=send message) (-p, -pdbk, action=store_true, dest=pdcl, default=False, help=write pdbk data to oracle db) (-z, -zdbk, action=store_true, dest=zdcl, default=False, help=write zdbk data to oracle db) (parser, expert_grp) (parser) for mod in (): (expert_grp) (options, args) = () # if =True: # print pdcl is true # if =True: # print zdcl is true if len(args) != 0: () (1


    注意事项

    本文(gunradio软件无线电发送接收字符程序.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开