2

I have been working around with a XBEE S2B Pro and a ConnectPort X4 and I have some questions about the drives xbee_sensor.py that can be found in folder C:\Program Files\Digi\python\DevTools-2.1\Dia\Dia_2.1.0\src\devices\xbee\xbee_devices\xbee_sensor.py

I have inserted some Traces in the drives to understand how it works.

In one of my traces, I could see that inside the def sample_indication(self, buf, addr): the snippet

if self.__tracer.info():
    msg = []
    TRACER.critical('msg = [] %s', self.__tracer.info())
else:
    msg = None
    TRACER.critical('msg = None %s', self.__tracer.info())

returns msg = None False

As the subsequent code depends on the content of the msg

if msg is not None:
    msg.append("%d %s" % (temperature, scale))

the temperature is not appended in msg buffer, which leads to msg buffer is not filled with any data.

My question is: why is the test self.__tracer.info() done?

Reinout van Rees
  • 13,486
  • 2
  • 36
  • 68
Antonio Leite
  • 460
  • 3
  • 7

1 Answers1

3

Antonio, there is some undocumented behavior going on...

Looking at src/core/tracing.py on line 921, we have

def info(self, msg=None, *args):
    '''
    Send a message at the warning level.
    '''
    return self.log(LEVELS['INFO'], msg, *args)

and

def log(self, level, msg, *args):
    '''
    All other exposed Tracer methods call this method with their
    respective numerical values as the level argument.

    '''
    # basic cut-off
    if self.level > level:
        return False

    if msg == None:
        True
    ...

on line 866.

So

self.__tracer.info()

returns True if info level messages will be logged.

sralmai
  • 197
  • 1
  • 5