Changeset 6590

Show
Ignore:
Timestamp:
10/04/07 18:20:23
Author:
eb
Message:

documented standard command line options and conventions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/README.hacking

    r6044 r6590  
    11# -*- Outline -*- 
    22# 
    3 # Copyright 2004 Free Software Foundation, Inc. 
     3# Copyright 2004,2007 Free Software Foundation, Inc. 
    44#  
    55# This file is part of GNU Radio 
     
    202202 
    203203Be sure to create links for gcc and g++ 
     204 
     205 
     206* Standard command line options 
     207 
     208When writing programs that are executable from the command line, 
     209please follow these guidelines for command line argument names (short 
     210and long) and types of the arguments.  We list them below using the 
     211Python optparse syntax.  In general, the default value should be coded 
     212into the help string using the "... [default=%default]" syntax. 
     213 
     214** Mandatory options by gr_block 
     215 
     216*** USRP source 
     217 
     218Any program using a USRP source (usrp.source_*) shall include: 
     219 
     220  add_option("", "--which-usrp", type="intx", default=0, 
     221             help="select which USRP to use [default=%default]") 
     222 
     223  add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), 
     224             help="select USRP Rx side A or B [default=A]") 
     225 
     226You are free to change the default if it makes sense in your application. 
     227 
     228 
     229*** USRP sink 
     230 
     231Any program using a USRP sink (usrp.sink_*) shall include: 
     232 
     233  add_option("", "--which-usrp", type="intx", default=0, 
     234             help="select which USRP to use [default=%default]") 
     235 
     236  add_option("-T", "--tx-subdev-spec", type="subdev", default=(0, 0), 
     237             help="select USRP Tx side A or B [default=A]") 
     238 
     239You are free to change the default if it makes sense in your application. 
     240 
     241 
     242*** Audio source 
     243 
     244Any program using an audio source shall include: 
     245 
     246  add_option("-I", "--audio-input", type="string", default="", 
     247             help="pcm input device name.  E.g., hw:0,0 or /dev/dsp") 
     248 
     249The default must be "".  This allows an audio module-dependent default 
     250to be specified in the user preferences file. 
     251 
     252 
     253*** Audio sink 
     254 
     255  add_option("-O", "--audio-output", type="string", default="", 
     256             help="pcm output device name.  E.g., hw:0,0 or /dev/dsp") 
     257 
     258The default must be "".  This allows an audio module-dependent default 
     259to be specified in the user preferences file. 
     260 
     261 
     262** Standard options names by parameter 
     263 
     264Whenever you want an integer, use the "intx" type.  This allows the 
     265user to input decimal, hex or octal numbers.  E.g., 10, 012, 0xa. 
     266 
     267Whenever you want a float, use the "eng_float" type.  This allows the 
     268user to input numbers with SI suffixes.  E.g, 10000, 10k, 10M, 10m, 92.1M 
     269 
     270If your program allows the user to specify values for any of the 
     271following parameters, please use these options to specify them: 
     272 
     273 
     274To specify a frequency (typically an RF center frequency) use: 
     275 
     276  add_option("-f", "--freq", type="eng_float", default=<your-default-here>, 
     277             help="set frequency to FREQ [default=%default]") 
     278 
     279 
     280To specify a decimation factor use: 
     281 
     282  add_option("-d", "--decim", type="intx", default=<your-default-here>, 
     283             help="set decimation rate to DECIM [default=%default]") 
     284 
     285 
     286To specify an interpolation factor use: 
     287 
     288  add_option("-i", "--interp", type="intx", default=<your-default-here>, 
     289             help="set interpolation rate to INTERP [default=%default]") 
     290 
     291 
     292To specify a gain setting use: 
     293 
     294  add_option("-g", "--gain", type="eng_float", default=<your-default-here>, 
     295             help="set gain in dB [default=%default]") 
     296 
     297 
     298If your application specifies both a tx and an rx gain, use: 
     299 
     300  add_option("", "--rx-gain", type="eng_float", default=<your-default-here>, 
     301             help="set receive gain in dB [default=%default]") 
     302 
     303  add_option("", "--tx-gain", type="eng_float", default=<your-default-here>, 
     304             help="set transmit gain in dB [default=%default]") 
     305 
     306 
     307To specify the number of channels of something use: 
     308 
     309  add_option("-n", "--nchannels", type="intx", default=1, 
     310             help="specify number of channels [default=%default]") 
     311 
     312 
     313To specify an output filename use: 
     314 
     315  add_option("-o", "--output-filename", type="string", default=<your-default-here>, 
     316             help="specify output-filename [default=%default]") 
     317 
     318 
     319To specify a rate use: 
     320 
     321  add_option("-r", "--bit-rate", type="eng_float", default=<your-default-here>, 
     322             help="specify bit-rate [default=%default]") 
     323     or 
     324 
     325  add_option("-r", "--sample-rate", type="eng_float", default=<your-default-here>, 
     326             help="specify sample-rate [default=%default]") 
     327   
     328 
     329If your application has a verbose option, use: 
     330 
     331  add_option('-v', '--verbose', action="store_true", default=False, 
     332             help="verbose output") 
     333 
     334 
     335If your application allows the user to specify the "fast USB" options, use:  
     336 
     337  add_option("", "--fusb-block-size", type="intx", default=0, 
     338             help="specify fast usb block size [default=%default]") 
     339 
     340  add_option("", "--fusb-nblocks", type="intx", default=0, 
     341             help="specify number of fast usb blocks [default=%default]")