(subparsers)
return p
Parser for sdr command
Parser for sdr command
Parser for sdr command
def subparser(subparsers):
    """Parser for sdr command"""
    p = subparsers.add_parser('sdr',
                              description="Launch SDR receiver",
                              help='Launch SDR receiver',
                              formatter_class=ArgumentDefaultsHelpFormatter)

    # Monitoring options
    monitoring.add_to_parser(p)

    rtl_p = p.add_argument_group('rtl_sdr options')
    rtl_p.add_argument('--sps',
                       default=2.0,
                       type=float,
                       help='Samples per symbol, or, equivalently, the '
                       'target oversampling ratio')
    rtl_p.add_argument('--rtl-idx',
                       default=0,
                       type=int,
                       help='RTL-SDR device index')
    rtl_p.add_argument('-g',
                       '--gain',
                       default=40,
                       type=float,
                       help='RTL-SDR Rx gain')
    rtl_p.add_argument('-f',
                       '--iq-file',
                       default=None,
                       help='File to read IQ samples from instead of reading '
                       'from the RTL-SDR in real-time')

    ldvb_p = p.add_argument_group('leandvb options')
    ldvb_p.add_argument(
        '-n',
        '--n-helpers',
        default=6,
        type=int,
        help='Number of instances of the external LDPC decoder \
                        to spawn as child processes')
    ldvb_p.add_argument(
        '-d',
        '--debug-dvbs2',
        action='count',
        default=0,
        help="Debug leandvb's DVB-S2 decoding. Use it multiple "
        "times to increase the debugging level")
    ldvb_p.add_argument('-v',
                        '--verbose',
                        default=False,
                        action='store_true',
                        help='leandvb in verbose mode')
    ldvb_p.add_argument('--gui',
                        default=False,
                        action='store_true',
                        help='GUI mode')
    ldvb_p.add_argument('--derotate',
                        default=0,
                        type=float,
                        help='Frequency offset correction to apply in kHz')
    ldvb_p.add_argument('--fastlock',
                        default=False,
                        action='store_true',
                        help='leandvb fast lock mode')
    ldvb_p.add_argument('--rrc-rej',
                        default=30,
                        type=int,
                        help='leandvb RRC rej parameter')
    ldvb_p.add_argument('-m',
                        '--modcod',
                        choices=defs.modcods.keys(),
                        default='qpsk3/5',
                        metavar='',
                        help="DVB-S2 modulation and coding (MODCOD) scheme. "
                        "Choose from: " + ", ".join(defs.modcods.keys()))
    ldvb_p.add_argument('--ldpc-dec',
                        default="ext",
                        choices=["int", "ext"],
                        help="LDPC decoder to use (internal or external)")
    ldvb_p.add_argument('--ldpc-bf',
                        default=100,
                        help='Max number of iterations used by the internal \
                        LDPC decoder when not using an external LDPC tool')
    ldvb_p.add_argument('--ldpc-iterations',
                        default=25,
                        help='Max number of iterations used by the external \
                        LDPC decoder when using an external LDPC tool')
    ldvb_p.add_argument('--framesizes',
                        type=int,
                        default=1,
                        choices=[0, 1, 2, 3],
                        help="Bitmask of desired frame sizes (1=normal, \
                        2=short)")
    ldvb_p.add_argument('--no-tsp',
                        default=False,
                        action='store_true',
                        help='Feed leandvb output to stdout instead of tsp')
    ldvb_p.add_argument('--pipe-size',
                        default=32,
                        type=int,
                        help='Size in Mbytes of the input pipe file read by \
                        leandvb')

    # TSDuck Options
    tsp.add_to_parser(p)

    p.set_defaults(func=run, record=False)

    subsubparsers = p.add_subparsers(title='subcommands',
                                     help='Target sub-command')
    # IQ recording
    p2 = subsubparsers.add_parser(
        'rec',
        description="Record IQ samples instead of "
        "feeding them into leandvb",
        help='Record IQ samples',
        formatter_class=ArgumentDefaultsHelpFormatter)
    p2.add_argument('-f',
                    '--iq-file',
                    default="blocksat.iq",
                    help='File on which to save IQ samples received with '
                    'the RTL-SDR.')
    p2.set_defaults(record=True)

    return p
def subparser ( subparsers ) : p = subparsers . add_parser ( 'sdr' , description = "Launch SDR receiver" , help = 'Launch SDR receiver' , formatter_class = ArgumentDefaultsHelpFormatter ) # Monitoring options monitoring . add_to_parser ( p ) rtl_p = p . add_argument_group ( 'rtl_sdr options' ) rtl_p . add_argument ( '--sps' , default = 2.0 , type = float , help = 'Samples per symbol, or, equivalently, the ' 'target oversampling ratio' ) rtl_p . add_argument ( '--rtl-idx' , default = 0 , type = int , help = 'RTL-SDR device index' ) rtl_p . add_argument ( '-g' , '--gain' , default = 40 , type = float , help = 'RTL-SDR Rx gain' ) rtl_p . add_argument ( '-f' , '--iq-file' , default = None , help = 'File to read IQ samples from instead of reading ' 'from the RTL-SDR in real-time' ) ldvb_p = p . add_argument_group ( 'leandvb options' ) ldvb_p . add_argument ( '-n' , '--n-helpers' , default = 6 , type = int , help = 'Number of instances of the external LDPC decoder \
                        to spawn as child processes' ) ldvb_p . add_argument ( '-d' , '--debug-dvbs2' , action = 'count' , default = 0 , help = "Debug leandvb's DVB-S2 decoding. Use it multiple " "times to increase the debugging level" ) ldvb_p . add_argument ( '-v' , '--verbose' , default = False , action = 'store_true' , help = 'leandvb in verbose mode' ) ldvb_p . add_argument ( '--gui' , default = False , action = 'store_true' , help = 'GUI mode' ) ldvb_p . add_argument ( '--derotate' , default = 0 , type = float , help = 'Frequency offset correction to apply in kHz' ) ldvb_p . add_argument ( '--fastlock' , default = False , action = 'store_true' , help = 'leandvb fast lock mode' ) ldvb_p . add_argument ( '--rrc-rej' , default = 30 , type = int , help = 'leandvb RRC rej parameter' ) ldvb_p . add_argument ( '-m' , '--modcod' , choices = defs . modcods . keys ( ) , default = 'qpsk3/5' , metavar = '' , help = "DVB-S2 modulation and coding (MODCOD) scheme. " "Choose from: " + ", " . join ( defs . modcods . keys ( ) ) ) ldvb_p . add_argument ( '--ldpc-dec' , default = "ext" , choices = [ "int" , "ext" ] , help = "LDPC decoder to use (internal or external)" ) ldvb_p . add_argument ( '--ldpc-bf' , default = 100 , help = 'Max number of iterations used by the internal \
                        LDPC decoder when not using an external LDPC tool' ) ldvb_p . add_argument ( '--ldpc-iterations' , default = 25 , help = 'Max number of iterations used by the external \
                        LDPC decoder when using an external LDPC tool' ) ldvb_p . add_argument ( '--framesizes' , type = int , default = 1 , choices = [ 0 , 1 , 2 , 3 ] , help = "Bitmask of desired frame sizes (1=normal, \
                        2=short)" ) ldvb_p . add_argument ( '--no-tsp' , default = False , action = 'store_true' , help = 'Feed leandvb output to stdout instead of tsp' ) ldvb_p . add_argument ( '--pipe-size' , default = 32 , type = int , help = 'Size in Mbytes of the input pipe file read by \
                        leandvb' ) # TSDuck Options tsp . add_to_parser ( p ) p . set_defaults ( func = run , record = False ) subsubparsers = p . add_subparsers ( title = 'subcommands' , help = 'Target sub-command' ) # IQ recording p2 = subsubparsers . add_parser ( 'rec' , description = "Record IQ samples instead of " "feeding them into leandvb" , help = 'Record IQ samples' , formatter_class = ArgumentDefaultsHelpFormatter ) p2 . add_argument ( '-f' , '--iq-file' , default = "blocksat.iq" , help = 'File on which to save IQ samples received with ' 'the RTL-SDR.' ) p2 . set_defaults ( record = True ) return p