Example #1
0
 def _connect(self) -> None:
     # TODO: condition for the abscence of optional configs
     self.llrpFactory = LLRPClientFactory(
         report_every_n_tags=self._config.report_every_n_tags,
         tx_power=self._config.tx_power,
         session=self._config.session,
         start_inventory=self._config.start_inventory,
         mode_identifier=self._config.mode_indentifier,
         tag_population=self._config.tag_population,
         tag_content_selector={
             'EnableROSpecID': self._config.EnableROSpecID,
             'EnableSpecIndex': self._config.EnableSpecIndex,
             'EnableInventoryParameterSpecID': self._config.EnableInventoryParameterSpecID,
             'EnableAntennaID': self._config.EnableAntennaID,
             'EnableChannelIndex': self._config.EnableChannelIndex,
             'EnablePeakRSSI': self._config.EnablePeakRSSI_General,
             'EnableFirstSeenTimestamp': self._config.EnableFirstSeenTimestamp,
             'EnableLastSeenTimestamp': self._config.EnableLastSeenTimestamp,
             'EnableTagSeenCount': self._config.EnableTagSeenCount,
             'EnableAccessSpecID': self._config.EnableAccessSpecID
         },
         impinj_tag_content_selector={
             'EnablePeakRSSI': self._config.EnablePeakRSSI_Impinj,
             'EnableRFPhaseAngle': self._config.EnableRFPhaseAngle,
             'EnableRFDopplerFrequency': self._config.EnableRFDopplerFrequency
         })
     reactor.connectTCP(self._config.ipAddress, self._config.port, self.llrpFactory, timeout=5)
Example #2
0
def main(host, port):
    if not host:
        logger.info('No readers specified.')
        return 0

    factory = LLRPClientFactory(reset_on_connect=False,
                                start_inventory=False)
    factory.addStateCallback(LLRPClient.STATE_CONNECTED, shutdown)

    for host in host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        reactor.connectTCP(host, port, factory, timeout=3)

    reactor.run()
Example #3
0
def main(host, port):
    if not host:
        logger.info('No readers specified.')
        return 0

    onFinish = defer.Deferred()
    onFinish.addCallback(finish)

    factory = LLRPClientFactory(reset_on_connect=False,
                                start_inventory=False,
                                onFinish=onFinish)
    factory.addStateCallback(LLRPClient.STATE_CONNECTED, shutdown)

    for host in host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        reactor.connectTCP(host, port, factory, timeout=3)

    reactor.run()
Example #4
0
def main(args):
    global start_time

    if not args.host:
        logger.info('No readers specified.')
        return 0

    # special case default Tari values
    tari = args.tari
    if args.modulation in Modulation_DefaultTari:
        t_suggested = Modulation_DefaultTari[args.modulation]
        if args.tari:
            logger.warn('recommended Tari for %s is %d', args.modulation,
                        t_suggested)
        else:
            tari = t_suggested
            logger.info('selected recommended Tari of %d for %s', args.tari,
                        args.modulation)

    enabled_antennas = [int(x.strip()) for x in args.antennas.split(',')]
    antmap = {
        host: {
            str(ant): 'Antenna {}'.format(ant) for ant in enabled_antennas
        } for host in args.host
    }
    logger.info('Antenna map: %s', antmap)

    # d.callback will be called when all connections have terminated normally.
    # use d.addCallback(<callable>) to define end-of-program behavior.
    d = defer.Deferred()
    d.addCallback(finish)

    factory_args = dict(
        onFinish=d,
        duration=args.time,
        report_every_n_tags=args.every_n,
        antenna_dict=antmap,
        tx_power=args.tx_power,
        modulation=args.modulation,
        tari=tari,
        session=args.session,
        mode_identifier=args.mode_identifier,
        tag_population=args.population,
        start_inventory=True,
        disconnect_when_done=args.time and args.time > 0,
        reconnect=args.reconnect,
        tag_content_selector={
            'EnableROSpecID': False,
            'EnableSpecIndex': False,
            'EnableInventoryParameterSpecID': False,
            'EnableAntennaID': False,
            'EnableChannelIndex': True,
            'EnablePeakRSSI': False,
            'EnableFirstSeenTimestamp': False,
            'EnableLastSeenTimestamp': True,
            'EnableTagSeenCount': True,
            'EnableAccessSpecID': False
        },
        impinj_search_mode=args.impinj_search_mode,
        impinj_tag_content_selector=None,
    )
    if args.impinj_reports:
        factory_args['impinj_tag_content_selector'] = {
            'EnableRFPhaseAngle': True,
            'EnablePeakRSSI': False,
            'EnableRFDopplerFrequency': False
        }

    fac = LLRPClientFactory(**factory_args)

    # tag_report_cb will be called every time the reader sends a TagReport
    # message (i.e., when it has "seen" tags).
    fac.addTagReportCallback(tag_report_cb)

    for host in args.host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        else:
            port = args.port
        reactor.connectTCP(host, port, fac, timeout=3)

    # catch ctrl-C and stop inventory before disconnecting
    reactor.addSystemEventTrigger('before', 'shutdown', shutdown, fac)

    # start runtime measurement to determine rates
    start_time = monotonic()

    reactor.run()
Example #5
0
    # Load Sllurp config
    args = parse_args()
    enabled_antennas = list(
        map(lambda x: int(x.strip()), args.antennas.split(',')))

    # Create Clients and set them to connect
    fac = LLRPClientFactory(report_every_n_tags=args.every_n,
                            antennas=enabled_antennas,
                            tx_power=args.tx_power,
                            modulation=args.modulation,
                            start_inventory=True,
                            tari=args.tari,
                            tag_content_selector={
                                'EnableROSpecID': True,
                                'EnableSpecIndex': True,
                                'EnableInventoryParameterSpecID': True,
                                'EnableAntennaID': True,
                                'EnableChannelIndex': True,
                                'EnablePeakRRSI': True,
                                'EnableFirstSeenTimestamp': True,
                                'EnableLastSeenTimestamp': True,
                                'EnableTagSeenCount': True,
                                'EnableAccessSpecID': True,
                            })
    fac.addTagReportCallback(tag_seen_callback)

    for host in args.host:
        reactor.connectTCP(host, args.port, fac, timeout=3)

    reactor.addSystemEventTrigger('before', 'shutdown', polite_shutdown, fac)
Example #6
0
def main(args):
    global start_time

    if not args.host:
        logger.info('No readers specified.')
        return 0

    # special case default Tari values
    if args.modulation in Modulation_DefaultTari:
        t_suggested = Modulation_DefaultTari[args.modulation]
        if args.tari:
            logger.warn('recommended Tari for %s is %d', args.modulation,
                        t_suggested)
        else:
            args.tari = t_suggested
            logger.info('selected recommended Tari of %d for %s', args.tari,
                        args.modulation)

    enabled_antennas = map(lambda x: int(x.strip()), args.antennas.split(','))

    # d.callback will be called when all connections have terminated normally.
    # use d.addCallback(<callable>) to define end-of-program behavior.
    d = defer.Deferred()
    d.addCallback(finish)

    fac = LLRPClientFactory(onFinish=d,
                            duration=args.time,
                            report_every_n_tags=args.every_n,
                            antennas=enabled_antennas,
                            tx_power=args.tx_power,
                            modulation=args.modulation,
                            tari=args.tari,
                            session=args.session,
                            mode_index=args.mode_index,
                            mode_identifier=args.mode_identifier,
                            tag_population=args.population,
                            start_inventory=True,
                            disconnect_when_done=(args.time > 0),
                            reconnect=args.reconnect,
                            tag_content_selector={
                                'EnableROSpecID': False,
                                'EnableSpecIndex': False,
                                'EnableInventoryParameterSpecID': False,
                                'EnableAntennaID': True,
                                'EnableChannelIndex': False,
                                'EnablePeakRRSI': True,
                                'EnableFirstSeenTimestamp': False,
                                'EnableLastSeenTimestamp': True,
                                'EnableTagSeenCount': True,
                                'EnableAccessSpecID': False
                            })

    # tag_report_cb will be called every time the reader sends a TagReport
    # message (i.e., when it has "seen" tags).
    fac.addTagReportCallback(tag_report_cb)

    for host in args.host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        else:
            port = args.port
        reactor.connectTCP(host, port, fac, timeout=3)

    # catch ctrl-C and stop inventory before disconnecting
    reactor.addSystemEventTrigger('before', 'shutdown', shutdown, fac)

    # start runtime measurement to determine rates
    start_time = time.time()

    reactor.run()
Example #7
0
    # Load Sllurp config
    args = parse_args()
    enabled_antennas = list(
        map(lambda x: int(x.strip()), args.antennas.split(',')))

    # Create Clients and set them to connect
    fac = LLRPClientFactory(report_every_n_tags=args.every_n,
                            antennas=enabled_antennas,
                            tx_power=args.tx_power,
                            modulation=args.modulation,
                            start_inventory=True,
                            tari=args.tari,
                            tag_content_selector={
                                'EnableROSpecID': True,
                                'EnableSpecIndex': True,
                                'EnableInventoryParameterSpecID': True,
                                'EnableAntennaID': True,
                                'EnableChannelIndex': True,
                                'EnablePeakRSSI': True,
                                'EnableFirstSeenTimestamp': True,
                                'EnableLastSeenTimestamp': True,
                                'EnableTagSeenCount': True,
                                'EnableAccessSpecID': True,
                            })
    fac.addTagReportCallback(tag_seen_callback)

    for host in args.host:
        reactor.connectTCP(host, args.port, fac, timeout=3)

    reactor.addSystemEventTrigger('before', 'shutdown', polite_shutdown, fac)
Example #8
0
def main(args):
    global start_time

    if not args.host:
        logger.info('No readers specified.')
        return 0

    # special case default Tari values
    tari = args.tari
    if args.modulation in Modulation_DefaultTari:
        t_suggested = Modulation_DefaultTari[args.modulation]
        if args.tari:
            logger.warn('recommended Tari for %s is %d', args.modulation,
                        t_suggested)
        else:
            tari = t_suggested
            logger.info('selected recommended Tari of %d for %s', args.tari,
                        args.modulation)

    enabled_antennas = [int(x.strip()) for x in args.antennas.split(',')]
    antmap = {
        host: {
            str(ant): 'Antenna {}'.format(ant) for ant in enabled_antennas
        } for host in args.host
    }
    logger.info('Antenna map: %s', antmap)

    # d.callback will be called when all connections have terminated normally.
    # use d.addCallback(<callable>) to define end-of-program behavior.
    d = defer.Deferred()
    d.addCallback(finish)

    factory_args = dict(
        onFinish=d,
        duration=args.time,
        report_every_n_tags=args.every_n,
        antenna_dict=antmap,
        tx_power=args.tx_power,
        modulation=args.modulation,
        tari=tari,
        session=args.session,
        mode_identifier=args.mode_identifier,
        tag_population=args.population,
        start_inventory=True,
        disconnect_when_done=args.time and args.time > 0,
        reconnect=args.reconnect,
        tag_content_selector={
            'EnableROSpecID': True,
            'EnableSpecIndex': False,
            'EnableInventoryParameterSpecID': False,
            'EnableAntennaID': True,
            'EnableChannelIndex': False,
            'EnablePeakRRSI': True,
            'EnableFirstSeenTimestamp': False,
            'EnableLastSeenTimestamp': True,
            'EnableTagSeenCount': True,
            'EnableAccessSpecID': False
        },
        impinj_search_mode=args.impinj_search_mode,
    )
    fac = LLRPClientFactory(**factory_args)

    # tag_report_cb will be called every time the reader sends a TagReport
    # message (i.e., when it has "seen" tags).
    fac.addTagReportCallback(tag_report_cb)

    for host in args.host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        else:
            port = args.port
        reactor.connectTCP(host, port, fac, timeout=3)

    # catch ctrl-C and stop inventory before disconnecting
    reactor.addSystemEventTrigger('before', 'shutdown', shutdown, fac)

    # start runtime measurement to determine rates
    start_time = time.monotonic()

    reactor.run()
Example #9
0
def main(args):
    global start_time

    if not args.host:
        logger.info('No readers specified.')
        return 0

    enabled_antennas = [int(x.strip()) for x in args.antennas.split(',')]
    antmap = {
        host: {
            str(ant): 'Antenna {}'.format(ant) for ant in enabled_antennas
        } for host in args.host
    }
    logger.info('Antenna map: %s', antmap)

    # d.callback will be called when all connections have terminated normally.
    # use d.addCallback(<callable>) to define end-of-program behavior.
    d = defer.Deferred()
    d.addCallback(finish)

    factory_args = dict(
        onFinish=d,
        duration=args.time,
        report_every_n_tags=args.every_n,
        antenna_dict=antmap,
        tx_power=args.tx_power,
        tari=args.tari,
        session=args.session,
        mode_identifier=args.mode_identifier,
        tag_population=args.population,
        start_inventory=True,
        disconnect_when_done=args.time and args.time > 0,
        reconnect=args.reconnect,
        tag_filter_mask=args.tag_filter_mask,
        tag_content_selector={
            'EnableROSpecID': False,
            'EnableSpecIndex': False,
            'EnableInventoryParameterSpecID': False,
            'EnableAntennaID': False,
            'EnableChannelIndex': True,
            'EnablePeakRSSI': False,
            'EnableFirstSeenTimestamp': False,
            'EnableLastSeenTimestamp': True,
            'EnableTagSeenCount': True,
            'EnableAccessSpecID': False
        },
        impinj_extended_configuration=args.impinj_extended_configuration,
        impinj_search_mode=args.impinj_search_mode,
        impinj_tag_content_selector=None,
    )
    if args.impinj_reports:
        factory_args['impinj_tag_content_selector'] = {
            'EnableRFPhaseAngle': True,
            'EnablePeakRSSI': False,
            'EnableRFDopplerFrequency': False
        }
    if args.impinj_fixed_freq:
        factory_args['impinj_fixed_frequency_param'] = {
            'FixedFrequencyMode': 2,
            'ChannelListIndex': [1]
        }

    fac = LLRPClientFactory(**factory_args)

    # tag_report_cb will be called every time the reader sends a TagReport
    # message (i.e., when it has "seen" tags).
    fac.addTagReportCallback(tag_report_cb)

    for host in args.host:
        if ':' in host:
            host, port = host.split(':', 1)
            port = int(port)
        else:
            port = args.port
        reactor.connectTCP(host, port, fac, timeout=3)

    # catch ctrl-C and stop inventory before disconnecting
    reactor.addSystemEventTrigger('before', 'shutdown', shutdown, fac)

    # start runtime measurement to determine rates
    start_time = monotonic()

    reactor.run()