Ankündigung

Einklappen
Keine Ankündigung bisher.

Switch light on when UDP command received from PC

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

    #31
    I don't have an Eibpc to test, but i've seen that there is a txt file "tmpAddr.txt" containing all imported adresses from ETS with all types specified.
    You can read this file and store data types of each GA on the sender PC.
    Then you can send to the EIBPC the GA, Value and Type, so you can put a simple if..then in the Eibpc and filter by the type you passed in.

    Kommentar


      #32
      Getting closer, but still no cigar:

      Code:
      IP=0u32
      Port=0u16
      Rx=$$ // Received Command, for example 0/0/1=1
      telegram=event(readudp(Port, IP, Rx));
      GA_Nr=convert(split(Rx,0u16,find(Rx,$=$,0u16)-1u16), 0u16);
      temp=size(Rx)
      if temp < 9u16 then {
          Value=convert(split(Rx,find(Rx,$=$,0u16)+1u16,1399u16),0b01)
      }endif
      if temp > 8u16 then {
          Value=convert(split(Rx,find(Rx,$=$,0u16)+1u16,1399u16),0u08)
      }endif
           
      if telegram then {
          write(address(GA_Nr),Value)
      }endif
      Result:
      Runtime error:
      ! variable not defined: >Value< !
      ID:11
      EibParser ended with an error

      I do not understand why there is an error because of Variable Value in this case, whereas there was no issue in the previous case. Does the extra 'if condition' statement have anything to do with that?

      Kommentar


        #33
        you have to split the two variables... try this...


        [highlight=epc]
        Value=0u08
        Value1=0b01
        IP=0u32
        Port=0u16
        temp=size(Rx)
        Rx=$$ // Received Command, for example 0/0/1=1

        telegram=event(readudp(Port, IP, Rx));
        GA_Nr=convert(split(Rx,0u16,find(Rx,$=$,0u16)-1u16), 0u16);

        if telegram and temp < 9u16 then {
        Value1=convert(split(Rx,find(Rx,$=$,0u16)+1u16,139 9u16),0b01);
        write(address(GA_Nr),Value1)
        }endif

        if telegram and temp > 8u16 then {
        Value=convert(split(Rx,find(Rx,$=$,0u16)+1u16,1399 u16),0u08);
        write(address(GA_Nr),Value)
        }endif
        [/highlight]
        Die Selbsthilfegruppe "UTF-8-Probleme" trifft sich diesmal abweichend im groüen Saal.

        Kommentar


          #34
          Thanks Martin!!!!

          This works great for switching ON/OFF and setting percentages of dimmer lights and the code looks so much more elegant too.

          I have learned a lot about data types and UDP, so this should keep me quiet (at least for a little while)..

          Regards,
          Perry

          Kommentar


            #35
            Just a small modification, should anybody else be interested in the same approach: it turns out that the number of digits in the Group Address number can vary and therefore the code was not reliable.

            The modified code makes a calculation of size of the number on the right side of the equal sign. Although I have tested it and it works, I do not understand why, if I enter a value of 1 in the UDP code the size is actually 3 and when I enter a two digit value (e.g. 60 to dim a light directly to, say 60) the size is 4.
            Maybe I will find out later why this is. For now the modified code:

            Code:
            Value=0u08
            Value1=0b01
            IP=0u32
            Port=0u16
            Rx=$$ // Received Command, for example 0/0/1=1
            
            telegram=event(readudp(Port, IP, Rx));
            GA_Nr=convert(split(Rx,0u16,find(Rx,$=$,0u16)-1u16), 0u16);
            temp=size(split(Rx,find(Rx,$=$,0u16)+1u16,1399u16))
            
            if telegram and temp == 3u16 then {   
            Value1=convert(split(Rx,find(Rx,$=$,0u16)+1u16,1399u16),0b01);
            write(address(GA_Nr),Value1)
            }endif
            
            if telegram and temp == 4u16 then {
            Value=convert(split(Rx,find(Rx,$=$,0u16)+1u16,1399u16),0u08);
            write(address(GA_Nr),Value)
            }endif

            Kommentar

            Lädt...
            X