Ankündigung

Einklappen
Keine Ankündigung bisher.

knx.read and knxEvents

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    knx.read and knxEvents

    Hi, it's me again...

    I'm looking to generate an action when I send an "on-off" via the bus. But nothing appen. The only example I found it's the "UFI_KNX_communication_test.ino"

    but I'm not able to get the information and the next step it's to retrieve the value send on 1byte like percentage.

    Can you kindly help me?

    BR,

    Ivan

    #2
    "incoming" group telegrams receive via

    Code:
    void knxEvents(byte index) {
    ...
    }
    Then you need to check the com-object with the given given for changes / it's new value.

    Outgoing KNX events are sent through changes on a comm-object, like

    Code:
    Knx.write(comObjId, value);


    Both works only, if the com-object has been assigned with an group-adress through the suite.

    Kommentar


      #3
      Code:
      void knxEvents(byte KNX_Obj) { //KNX_Obj = Suite ComObj_Nummer+1)
         if (KNX_Obj == 1){
              percentage1 = (byte)Knx.read(1);
         }
         if (KNX_Obj == 2){
              percentage2 = (byte)Knx.read(2);
         }
      }
      Zuletzt geändert von Eugenius; 29.08.2016, 16:13.

      Kommentar


        #4
        I understand what you mean but with the code above I cannot turn on a simple light!

        And the BckLightPin variable is working because I can use it when I setup the program and there I can turn on and off changing in the Suite (it Rocks!!!)

        Something like that?

        Code:
        void knxEvents(byte index) {
            // nothing to do in this sketch
        
            bool BckLight = (bool)Tools.getUINT8Param(2);  //
            byte BckLightPin = (byte)Tools.getUINT8Param(3);
            bool BckLightExt = (bool)Tools.getUINT8Param(4);
            #ifdef DEBUG  
                DEBUG.println(BckLight);
                DEBUG.println(BckLightPin);
                DEBUG.println(BckLightExt);
                DEBUG.println(index);
            #endif
            switch (index){
            case 2 : // object index 1 has been updaed
        
              if (Knx.read(2)) { 
                      digitalWrite(BckLightPin, HIGH); 
                      #ifdef DEBUG  
                                DEBUG.println("Toggle LED: on");
                      #endif
                    } 
                    else { 
                      digitalWrite(BckLightPin, LOW); 
                      #ifdef DEBUG  
                                DEBUG.println("Toggle LED: off");
                      #endif
                    }
              break;
              default: 
              break;      
          }
        };

        Kommentar


          #5
          this only for setup function (one time on device start):
          Code:
          bool BckLight = (bool)Tools.getUINT8Param(2);  //
              byte BckLightPin = (byte)Tools.getUINT8Param(3);
              bool BckLightExt = (bool)Tools.getUINT8Param(4);
              #ifdef DEBUG  
                  DEBUG.println(BckLight);
                  DEBUG.println(BckLightPin);
                  DEBUG.println(BckLightExt);
                  DEBUG.println(index);
              #endif
          knxEvents function:
          Code:
          void knxEvents(byte index) {
          
              switch (index){
              case 2 : // object index 2 has been updated
          
                if (Knx.read(2)) {
                        digitalWrite(BckLightPin, HIGH);
                        #ifdef DEBUG  
                                  DEBUG.println("Toggle LED: on");
                        #endif
                      }
                      else {
                        digitalWrite(BckLightPin, LOW);
                        #ifdef DEBUG  
                                  DEBUG.println("Toggle LED: off");
                        #endif
                      }
                break;
                default:
                break;      
            }
          };

          Kommentar


            #6
            Zitat von Eugenius Beitrag anzeigen
            this only for setup function (one time on device start):
            Maybe it's wise to give a reason for that:

            knxEvents() is - the name already explains it - an event method. It is triggered directly after a mathcing telegram has received. The execution of this method has to be as short as possible, otherwise it may block reading further telegrams. Reading on every event the parameters from eeprom eats unnecessary cpu cycles. So it's a good idea to read-in parameters in setup() and keep them in memory for fast access.

            Kommentar


              #7
              I understand, thanks for your advice.

              it wont do what I want and I cannot fast debug (hardware issues) and now I have to wait to resolve that before continue with the software part.

              I put the project if you want to have a look.
              Angehängte Dateien

              Kommentar


                #8
                i see the first error in your sketch:
                you will receive a value to turn on or off a backlight. you have to define it as an input object:
                Code:
                KnxComObject KnxDevice::_comObjectsList[] = {
                /* don't change this */ Tools.createProgComObject(),
                
                // Currently, Sketch Index and Suite Index differ for ComObjects :-(
                
                /* Sketch-Index 1, Suite-Index 0 : */ KnxComObject(KNX_DPT_16_001, COM_OBJ_SENSOR), //code
                /* Sketch-Index 2, Suite-Index 1 : */ KnxComObject(KNX_DPT_1_001, [B]COM_OBJ_LOGIC_IN[/B]), //light
                /* Sketch-Index 3, Suite-Index 2 : */ KnxComObject(KNX_DPT_1_001, COM_OBJ_SENSOR), //relay
                };
                here you can find discription for it (C/R/W/T/U/I indicators like in ETS):

                https://github.com/KONNEKTING/Konnek...omObject.h#L58
                Zuletzt geändert von Eugenius; 30.08.2016, 14:58.

                Kommentar

                Lädt...
                X