Menu

logging of unknown objects

Klaus
2011-12-19
2012-12-14
  • Klaus

    Klaus - 2011-12-19

    first of all my sincere thanks to you for creating and maintaining this great tool. Many things wouldn't be doable without it!

    Is there a way of configuring linknx in such way, that it write a log entry for each message on the bus which does not correspond with any given object in the linknx config? This would ease troubleshooting, since it is still very cumbersome to keep ETS3 config in sync with linknx and the visu.

    Cheers,

    Klaus

     
  • netsrac69

    netsrac69 - 2012-01-02

    Klaus,

    you can use other tools like vbusmonitor1 which comes with the eibd package to monitor the bus.

    Netsrac

     
  • Klaus

    Klaus - 2012-05-12

    dear all,

    I found a simple way to add the wanted functionality. Just a few lines of code added to objectcontroller. forces the objectcontroller to write a debug message that he could not find the destination group address being used by the recent telegram (see the attached patch for details).

    Please respond back to Jean-François if you find this useful - may be he adds it to the next version ;-)

    Have a great weekend,

    Klaus

    diff --git a/src/objectcontroller.cpp b/src/objectcontroller.cpp
    index 27e28be..1e62089 100644
    --- a/src/objectcontroller.cpp
    +++ b/src/objectcontroller.cpp
    @@ -22,6 +22,8 @@
     #include "services.h"
     #include <cmath>
     #include <cassert>
    +#include <iostream>
    +#include <iomanip>
    
     ObjectController* ObjectController::instance_m;
    
    @@ -836,7 +838,8 @@ std::string TimeObjectValue::toString()
         if (hour_m == -1)
             return "now";
         std::ostringstream out;
    -    out << hour_m << ":" << min_m << ":" << sec_m;
    +    out << std::setfill(' ') << std::setw(2) << hour_m << ":" 
    +       << std::setfill('0') << std::setw(2) << min_m << ":" << std::setw(2) << sec_m;
         return out.str();
     }
    
    @@ -2616,6 +2619,8 @@ void String14AsciiObject::setStringValue(const std::string& value)
     ObjectController::ObjectController()
     {}
    
    +Logger& ObjectController::logger_m(Logger::getInstance("ObjectControler"));
    +
     ObjectController::~ObjectController()
     {
         ObjectIdMap_t::iterator it;
    @@ -2635,8 +2640,16 @@ void ObjectController::onWrite(eibaddr_t src, eibaddr_t dest, const uint8_t* buf
         std::pair<ObjectMap_t::iterator, ObjectMap_t::iterator> range;
         range = objectMap_m.equal_range(dest);
         ObjectMap_t::iterator it;
    -    for (it = range.first; it != range.second; it++)
    -        (*it).second->onWrite(buf, len, src);
    +    bool found = false;
    +   // find all objects with matching dest group address
    +    for (it = range.first; it != range.second; it++) { 
    +        (*it).second->onWrite(buf, len, src);      // hand over data to object
    +        found = true;
    +    }
    +   if (found)
    +       logger_m.debugStream() << "onWrite - dest eibaddr not found: "
    +           << Object::WriteGroupAddr(dest)
    +           << " sender=" << Object::WriteAddr( src ) << endlog;  
     }
    
     void ObjectController::onRead(eibaddr_t src, eibaddr_t dest, const uint8_t* buf, int len)
    @@ -2644,8 +2657,15 @@ void ObjectController::onRead(eibaddr_t src, eibaddr_t dest, const uint8_t* buf,
         std::pair<ObjectMap_t::iterator, ObjectMap_t::iterator> range;
         range = objectMap_m.equal_range(dest);
         ObjectMap_t::iterator it;
    -    for (it = range.first; it != range.second; it++)
    +    bool found = false;
    +    for (it = range.first; it != range.second; it++) {
             (*it).second->onRead(buf, len, src);
    +        found = true;
    +    }
    +   if (found)
    +       logger_m.debugStream() << "onRead - dest eibaddr not found: " 
    +           << Object::WriteGroupAddr(dest)
    +           << " sender=" << Object::WriteAddr( src ) << endlog;  
     }
    
     void ObjectController::onResponse(eibaddr_t src, eibaddr_t dest, const uint8_t* buf, int len)
    @@ -2653,8 +2673,15 @@ void ObjectController::onResponse(eibaddr_t src, eibaddr_t dest, const uint8_t*
         std::pair<ObjectMap_t::iterator, ObjectMap_t::iterator> range;
         range = objectMap_m.equal_range(dest);
         ObjectMap_t::iterator it;
    -    for (it = range.first; it != range.second; it++)
    +    bool found = false;
    +    for (it = range.first; it != range.second; it++) {
             (*it).second->onResponse(buf, len, src);
    +        found = true;
    +    }
    +   if (found)
    +       logger_m.debugStream() << "onResponse - dest eibaddr not found: " 
    +           << Object::WriteGroupAddr(dest)
    +           << " sender=" << Object::WriteAddr( src ) << endlog;  
     }
    
     Object* ObjectController::getObject(const std::string& id)
    diff --git a/src/objectcontroller.h b/src/objectcontroller.h
    index 5862280..2c7aa7e 100644
    --- a/src/objectcontroller.h
    +++ b/src/objectcontroller.h
    @@ -967,6 +967,9 @@ private:
         ObjectMap_t objectMap_m;
         ObjectIdMap_t objectIdMap_m;
         static ObjectController* instance_m;
    +    
    +    static Logger& logger_m;
    +
     };
    
     #endif
    
     
  • Klaus

    Klaus - 2012-05-12

    hi again,

    sorry wrong patch file.

    if (found)
    

    should read

    if (!found)
    

    Cheers,

    Klaus

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.