gotthardp / python-mercuryapi

Python wrapper for the ThingMagic Mercury API
MIT License
122 stars 63 forks source link

added support for TMR_statsListener #95

Closed HanYangZhao closed 4 years ago

HanYangZhao commented 4 years ago

I've added a partial support for the statsListener.

I've added a function called reader.start_stats(callback), which enables the statsListener. It must be called before reader.start_reading() or otherwise it doesn't seem to work. The code in the callback can for example :

def callback(stats):
    print({"temp" : stats.temperature})
    print({"antenna" : stats.antenna})
    print({"protocol" : stats.protocol})
    print({"frequency" : stats.frequency})
The callback object has 4 attribute : temperature, antenna, protocol and frequency. There are a few more attribute in the stats that is supported by the C API, but i haven't added them
gotthardp commented 4 years ago

Cool, thanks!

gotthardp commented 4 years ago

Hello, for consistency with the API and clarity I renamed your "start_stats" to "enable_stats". It doesn't start anything-- it really just enables it. https://github.com/gotthardp/python-mercuryapi/commit/03f95e617b8e9cb46c9f2084c437afaee8f8125e