Funk wetterstations Analyse Programm: Unterschied zwischen den Versionen

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche
(überarbeitung, verbessrung,....)
Zeile 9: Zeile 9:
 
<br>
 
<br>
 
<source lang="c">
 
<source lang="c">
dnl ################################################################################
+
// ################################################################################
dnl #                                                                              #
+
// #                                                                              #
dnl # Daten Analyse und Programm Erstellung:                                      #
+
// # Daten Analyse und Programm Erstellung:                                      #
dnl #  Copyright (c) 08/2009 - Michael Schultz <ethersex@keyb.de>                 #
+
// #  Copyright (c) 2009-2010 - Michael Schultz <ethersex@keyb.de>               #
dnl #      Mit viel unterstuetzung/Geduld von: stesie, veyron und DanielW          #
+
// #      Mit viel unterstuetzung/Geduld von: stesie, veyron und DanielW          #
dnl #                                                                              #
+
// #                                                                              #
dnl # This program is free software; you can redistribute it and/or modify it      #
+
// # This program is free software; you can redistribute it and/or modify it      #
dnl # under the terms of the GNU General Public License (either version 2 or      #
+
// # under the terms of the GNU General Public License (either version 2 or      #
dnl # version 3) as published by the Free Software Foundation.                    #
+
// # version 3) as published by the Free Software Foundation.                    #
dnl #                                                                              #
+
// #                                                                              #
dnl # This program is distributed in the hope that it will be useful,              #
+
// # This program is distributed in the hope that it will be useful,              #
dnl # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+
// # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
dnl # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
+
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
dnl # GNU General Public License for more details.                                #
+
// # GNU General Public License for more details.                                #
dnl #                                                                              #
+
// #                                                                              #
dnl # You should have received a copy of the GNU General Public License            #
+
// # You should have received a copy of the GNU General Public License            #
dnl # along with this program; if not, write to the Free Software                  #
+
// # along with this program; if not, write to the Free Software                  #
dnl # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                    #
+
// # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                    #
dnl #                                                                              #
+
// #                                                                              #
dnl # For more information on the GPL, please go to:                              #
+
// # For more information on the GPL, please go to:                              #
dnl # http://www.gnu.org/copyleft/gpl.html                                        #
+
// # http://www.gnu.org/copyleft/gpl.html                                        #
dnl #                                                                              #
+
// #                                                                              #
dnl #                                                                              #
+
// #                                                                              #
dnl # Wetter-Funk-Daten Analyse Programm für Wetter Station der Firma              #
+
// # Wetter-Funk-Daten Analyse Programm für Wetter Station der Firma              #
dnl #    Krippl Watches GmbH  --  http://www.produktservice.info                #
+
// #    Krippl Watches GmbH  --  http://www.produktservice.info                #
dnl # Protokoll analyse siehe:                                                    #
+
// # Protokoll analyse siehe:                                                    #
dnl #    http://www.ethersex.de/index.php/Funk-wetterstations-protokoll          #
+
// #    http://www.ethersex.de/index.php/Funk-wetterstations-protokoll          #
dnl #                                                                              #
+
// #                                                                              #
dnl ################################################################################
+
// ################################################################################
+
 
+
// Logging Destination Host: 10.0.0.77 on Port 95
dnl Logging Destination Host: 10.0.0.77 on Port 95
 
  
 
#define PRESCALER 1024
 
#define PRESCALER 1024
Zeile 46: Zeile 45:
 
#define US_TO_TICKS(n)  ((n) * 1000UL / NS_PER_TICK)
 
#define US_TO_TICKS(n)  ((n) * 1000UL / NS_PER_TICK)
  
#define WEATHERVERBOSE 1
+
// debug ausgabe 0 = keine debug meldungen, 1 = ein bischen merh, und 2 für komplette bit analyse
 +
#define WEATHERVERBOSE 0
  
 
uint8_t data[310];
 
uint8_t data[310];
 
uint16_t counter;
 
uint16_t counter;
+
                                        // Timing          @16mhz: Timer Count    Timer C. Hex    Decode
+
uint8_t Time0 = US_TO_TICKS(1920);     // L      space 1920 bis 1999us            30-31,2        0x1E    0x1F    0
                                              dnl                    Timing          @16mhz: Timer Count    Timer C. Hex    Decode
+
uint8_t Time1 = US_TO_TICKS(3990);     // H      space 3990 bis 4049us            62,3-63,2      0x3E    0x3F    1
uint8_t Time0 = US_TO_TICKS(1920);             dnl    L      space 1920 bis 1999us            30-31,2        0x1E    0x1F    0
+
uint8_t Time2 = US_TO_TICKS(2060);     // End-l  space 2060 bis 2089us            32,1-32,6      0x20    0x21    2
uint8_t Time1 = US_TO_TICKS(3990);             dnl    H      space 3990 bis 4049us            62,3-63,2      0x3E    0x3F    1
+
uint8_t Time3 = US_TO_TICKS(4130);     // End-h  space 4130 bis 4169us            64,5-65,1      0x40    0x41    3
uint8_t Time2 = US_TO_TICKS(2060);             dnl    End-l  space 2060 bis 2089us            32,1-32,6      0x20    0x21    2
+
uint8_t Time4 = US_TO_TICKS(8890);     // Start  space 8890 bis 8939us            138,9-139,6    0x8A    0x8B    4
uint8_t Time3 = US_TO_TICKS(4130);             dnl    End-h  space 4130 bis 4169us            64,5-65,1      0x40    0x41    3
+
uint8_t Time5 = US_TO_TICKS(360);       // End-    pulse  360 bis 369us            5,6-5,7        0x05            5
uint8_t Time4 = US_TO_TICKS(8890);             dnl    Start  space 8890 bis 8939us            138,9-139,6    0x8A    0x8B    4
+
uint8_t Time6 = US_TO_TICKS(440);       // _      pulse  440 bis 519us            6,8-8,1        0x06    0x08    6
uint8_t Time5 = US_TO_TICKS(360);             dnl    End-    pulse  360 bis 369us            5,6-5,7        0x05            5
+
                                        // Pause
uint8_t Time6 = US_TO_TICKS(440);             dnl    _      pulse  440 bis 519us            6,8-8,1        0x06    0x08    6
+
                                        //
                                              dnl    Pause
+
uint8_t BitPos = 0;                     // Bit Position innerhalb eines 36 bit worts (1 bis 37)
                                              dnl
+
uint8_t WordCound = 0;                 // Daten Wort Count (1 bis 9)
uint8_t BitPos = 0;                           dnl    Bit Position innerhalb eines 36 bit worts (1 bis 37)
+
uint8_t WordData[45];                   // 1 Data Word = 5 Byte    /      Max 8 Data Words
uint8_t WordCound = 0;                         dnl    Daten Wort Count (1 bis 9)
+
uint8_t WordPos = 0;                   // Byte Pos in WordData
uint8_t WordData[45];                         dnl      1 Data Word = 5 Byte    /      Max 8 Data Words
+
uint8_t MatchPos = 0;                  // meist vorkommene datenwort position im telegram
uint8_t WordPos = 0;                           dnl    Byte Pos in WordData
+
uint8_t MatchCount = 0;                // wie viel treffer hatte dieses meist vorkommende telegram
                                              dnl
+
                                        //
uint16_t Temp = 0;                             dnl    Temperatur Wert (-)76,8 bis (+)127,9 °C, Vorzeichen wird erst bei der ausgabe gesetzt.
+
uint16_t Temp = 0;                     // Temperatur Wert (-)76,8 bis (+)127,9 °C, Vorzeichen wird erst bei der ausgabe gesetzt.
uint16_t Feuchte = 0;                         dnl    Luftfeuchte Wert 20-99 %
+
uint16_t Feuchte = 0;                   // Luftfeuchte Wert 20-99 %
uint8_t timer_0 = 0;                           dnl    Timer Wert für zeitbestimming zwichen 2 Pegel änderungen (Interrupts)
+
uint8_t timer_0 = 0;                   // Timer Wert für zeitbestimming zwichen 2 Pegel änderungen (Interrupts)
uint8_t Temp1 = 0;                             dnl    Temperatur wert, einer stelle --> 0,n °C
+
uint8_t Temp1 = 0;                     // Temperatur wert, einer stelle --> 0,n °C
uint8_t Temp10 = 0;                           dnl    Temperatur wert, zener stelle --> n,0 °C
+
uint8_t Temp10 = 0;                     // Temperatur wert, zener stelle --> n,0 °C
                                              dnl
+
                                        //
uint8_t Analysis[10] ;                         dnl    Daten Analyse array
+
uint8_t Analysis[10] ;                 // Daten Analyse array
                                              dnl    Analysis[0 bis 7]              Treffer der Daten Packets Übereinstimmung.
+
                                        // Analysis[0 bis 7]              Treffer der Daten Packets Übereinstimmung.
                                              dnl    Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
+
                                        // Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
                                              dnl    Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
+
                                        // Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
                                              dnl    Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
+
                                        // Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
                                              dnl    Analysis[9]                    Array Positions Counter fuer analyse
+
                                        // Analysis[9]                    Array Positions Counter fuer analyse
+
 
 
 
 
CONTROL_START
 
CONTROL_START
  ON STARTUP DO
+
        ON STARTUP DO
     _TCCR0_PRESCALE |=  _BV(CS02);             dnl    TCCR0B(CS02)=1
+
                Analysis[8]     |= (1 << 2);            //      nach start einmal ausgabe, um zu schauen wann das ding gebootet ist...
    _TCCR0_PRESCALE &= ~_BV(CS01);             dnl    TCCR0B(CS01)=0
+
                _TCCR0_PRESCALE |=  _BV(CS02);         //      TCCR0B(CS02)=1
    _TCCR0_PRESCALE |=  _BV(CS00);             dnl    TCCR0B(CS00)=1
+
                _TCCR0_PRESCALE &= ~_BV(CS01);         //      TCCR0B(CS01)=0
    _EIMSK          |=  _BV(INT0);             dnl    EIMSK(INT0) = 1
+
                _TCCR0_PRESCALE |=  _BV(CS00);         //      TCCR0B(CS00)=1
    _EICRA          &= ~_BV(ISC01);           dnl    EICRA(ISC01) = 0
+
                _EIMSK          |=  _BV(INT0);         //      EIMSK(INT0) = 1         Interrupt, Input Data on INT0 / PD2
    _EICRA          |=  _BV(ISC00);           dnl    EICRA(ISC00) = 1
+
                _EICRA          &= ~_BV(ISC01);         //      EICRA(ISC01) = 0       interrupt on any edge, asyncronously
    _TIMSK_TIMER0  |=  _BV(TOIE0);           dnl    TIMSK0(TOIE0) = 1      Interrupt on Timer Overflow aktivieren
+
                _EICRA          |=  _BV(ISC00);         //      EICRA(ISC00) = 1       interrupt on any edge, asyncronously
    TCP_CONNECT(10.0.0.77, 95, message_handler);
+
                _TIMSK_TIMER0  |=  _BV(TOIE0);         //      TIMSK0(TOIE0) = 1      Interrupt on Timer Overflow aktivieren
  END
+
                TCP_CONNECT(10.0.0.77, 95, message_handler);
  TCP_HANDLER_PERSIST(message_handler)
+
        END
    for (;;)
+
 
    {
+
        TCP_HANDLER_PERSIST(message_handler)
      WordData[40] = WordData[0] ;
+
        for (;;)
      WordData[41] = WordData[1] ;
+
        {
      WordData[42] = WordData[2] ;
+
 
      WordData[43] = WordData[3] ;
+
                // Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
      WordData[44] = WordData[4] ;
+
                if ( Analysis[8] & ( 1 << 2 ) )
+
                {
dnl  for( uint8_t i=0, uint8_t j = 8 ; i < j ; i++, j+=2)
+
                        // Lösche ale Analysis Counter
dnl  if ( WordData[Analysis[9]] == WordData[Analysis[9] + 5] ) {
+
                        for (int Count1 = 0; Count1 < 8; Count1 ++) Analysis[ (Count1) ] = 0 ;
dnl  for{ init; match; do } {anweisung;}
 
dnl  for( zahl = 0 ; zahl < 20 ; zahl += 5 )
 
dnl      Array[zahl] = 1;
 
dnl  for (int i=0;i<5;i++) Arrayzahl[i*5]=1;
 
 
 
dnl  Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
 
      if ( Analysis[8] & ( 1 << 2 ) )
 
      {
 
        Temp = 0 ;
 
        if ( WordData[41] & ( 1 << 3 ) ) { Temp = Temp + 1    ; }
 
        if ( WordData[41] & ( 1 << 2 ) ) { Temp = Temp + 2    ; }
 
        if ( WordData[41] & ( 1 << 1 ) ) { Temp = Temp + 4    ; }
 
        if ( WordData[41] & ( 1 << 0 ) ) { Temp = Temp + 8    ; }
 
        if ( WordData[42] & ( 1 << 7 ) ) { Temp = Temp + 16  ; }
 
        if ( WordData[42] & ( 1 << 6 ) ) { Temp = Temp + 32  ; }
 
        if ( WordData[42] & ( 1 << 5 ) ) { Temp = Temp + 64  ; }
 
        if ( WordData[42] & ( 1 << 4 ) ) { Temp = Temp + 128  ; }
 
        if ( WordData[42] & ( 1 << 3 ) ) { Temp = Temp + 256  ; }
 
        if ( WordData[42] & ( 1 << 2 ) ) { Temp = Temp + 512  ; }
 
        if ( WordData[42] & ( 1 << 1 ) ) { Temp = Temp + 1024 ; }
 
        Temp10=( Temp / 10 );
 
        Temp1=( Temp - ( ( Temp / 10 ) * 10 ) );
 
        Feuchte = 0 ;
 
        if ( WordData[43] & ( 1 << 7 ) ) { Feuchte = Feuchte + 1  ; }
 
        if ( WordData[43] & ( 1 << 6 ) ) { Feuchte = Feuchte + 2  ; }
 
        if ( WordData[43] & ( 1 << 5 ) ) { Feuchte = Feuchte + 4  ; }
 
        if ( WordData[43] & ( 1 << 4 ) ) { Feuchte = Feuchte + 8 ; }
 
        if ( WordData[43] & ( 1 << 3 ) ) { Feuchte = Feuchte + 10 ; }
 
        if ( WordData[43] & ( 1 << 2 ) ) { Feuchte = Feuchte + 20 ; }
 
        if ( WordData[43] & ( 1 << 1 ) ) { Feuchte = Feuchte + 40 ; }
 
        if ( WordData[43] & ( 1 << 0 ) ) { Feuchte = Feuchte + 80 ; }
 
 
        TCP_SEND("<27>");
 
        if ( CLOCK_MONTH() == 8 ) { TCP_SEND("Aug  "); }
 
        TCP_SEND("%d %02d:%02d:%02d %s ethersex: Sender=", CLOCK_DAY(), CLOCK_HOUR(), CLOCK_MIN(), CLOCK_SEC(), CONF_HOSTNAME);
 
 
dnl    TCP_SEND("%d %02d:%02d:%02d %s -- Sender=", CLOCK_DAY(), CLOCK_HOUR(), CLOCK_MIN(), CLOCK_SEC(), CONF_HOSTNAME);
 
        if ( WordData[40] & ( 1 << 3 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[40] & ( 1 << 2 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 
        if ( WordData[40] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[40] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[40] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[40] & ( 1 << 4 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 
        if ( WordData[40] & ( 1 << 1 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[40] & ( 1 << 0 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 
        if ( WordData[41] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[41] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        if ( WordData[41] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        TCP_SEND(" Temp=");
 
        if ( WordData[42] & ( 1 << 0 ) ) { TCP_SEND("-");  } else { TCP_SEND("+");  }
 
        TCP_SEND("%d.%d Feuchte=%d%% SonderSendung=", Temp10, Temp1, Feuchte);
 
        if ( WordData[41] & ( 1 << 4 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 
        TCP_SEND("  (%02x%02x%02x%02x%02x)\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
 
#if WEATHERVERBOSE == 1
 
        TCP_SEND("00  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[0],  WordData[1],  WordData[2],  WordData[3],  WordData[4],  Analysis[0]);
 
        TCP_SEND("01  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[5],  WordData[6],  WordData[7],  WordData[8],  WordData[9],  Analysis[1]);
 
        TCP_SEND("02  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[10],  WordData[11],  WordData[12],  WordData[13],  WordData[14], Analysis[2]);
 
        TCP_SEND("03  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[15],  WordData[16],  WordData[17],  WordData[18],  WordData[19], Analysis[3]);
 
        TCP_SEND("04  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[20],  WordData[21],  WordData[22],  WordData[23],  WordData[24], Analysis[4]);
 
        TCP_SEND("05  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[25],  WordData[26],  WordData[27],  WordData[28],  WordData[29], Analysis[5]);
 
        TCP_SEND("06  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[30],  WordData[31],  WordData[32],  WordData[33],  WordData[34], Analysis[6]);
 
        TCP_SEND("07  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[35],  WordData[36],  WordData[37],  WordData[38],  WordData[39], Analysis[7]);
 
        TCP_SEND("Out --> %02x%02x%02x%02x%02x\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
 
        TCP_SEND(" \n");
 
        TCP_SEND(" \n");
 
#endif
 
#if WEATHERVERBOSE > 1
 
 
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[0],  data[1],  data[2],  data[3],  data[4],  data[5],  data[6],  data[7],  data[8],  data[9], data[10],  data[11],  data[12],  data[13],  data[14],  data[15],  data[16],  data[17],  data[18],  data[19],  data[20],  data[21],  data[22],  data[23],  data[24],  data[25],  data[26],  data[27],  data[28],  data[29],  data[30], data[31],  data[32],  data[33],  data[34],  data[35],  data[36],  data[37],  data[38],  data[39]);
 
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[40], data[41], data[42],  data[43],  data[44],  data[45],  data[46],  data[47],  data[48],  data[49], data[50],  data[51],  data[52],  data[53],  data[54],  data[55],  data[56],  data[57],  data[58],  data[59],  data[60],  data[61],  data[62],  data[63],  data[64],  data[65],  data[66],  data[67],  data[68],  data[69],  data[70], data[71],  data[72],  data[73],  data[74],  data[75],  data[76],  data[77],  data[78],  data[79]);
+
                        // wie oft matcht welsches telegram mit allen anderen 8 telegrammen
 +
                        for (int Count1 = 0; Count1 < 8; Count1 ++)
 +
                                for (int Count2 = 0; Count2 < 8; Count2 ++)
 +
                                        if (memcmp(&WordData[ (Count1) * 5 ], &WordData[ ( Count2 + 1 ) * 5], 5) == 0)
 +
                                                { Analysis[ (Count1) ] ++ ; }
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[80],  data[81],  data[82],  data[83],  data[84],  data[85],  data[86],  data[87],  data[88],  data[89], data[100], data[101], data[102], data[103], data[104], data[105], data[106], data[107], data[108], data[109], data[110], data[111], data[112], data[113], data[114], data[115], data[116], data[117], data[118], data[119], data[120], data[121], data[122], data[123], data[124], data[125], data[126], data[127], data[128], data[129]);
+
                        // nim nur das telegram mit der größten anzahl an treffer
 +
                        for (int Count1 = 8; Count1 > 1; Count1 --)
 +
                                for (int Count2 = 0; Count2 < 8; Count2 ++)
 +
                                        if ( Analysis[ (Count2) ] == Count1 )
 +
                                        {
 +
                                                MatchPos = Count2 ;
 +
                                                MatchCount = Count1 ;
 +
                                                WordData[40] = WordData[ ( MatchPos * 5 )    ] ;
 +
                                                WordData[41] = WordData[ ( MatchPos * 5 ) + 1 ] ;
 +
                                                WordData[42] = WordData[ ( MatchPos * 5 ) + 2 ] ;
 +
                                                WordData[43] = WordData[ ( MatchPos * 5 ) + 3 ] ;
 +
                                                WordData[44] = WordData[ ( MatchPos * 5 ) + 4 ] ;
 +
                                        }
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[130], data[131], data[132], data[133], data[134], data[135], data[136], data[137], data[138], data[139], data[140], data[141], data[142], data[143], data[144], data[145], data[146], data[147], data[148], data[149], data[150], data[151], data[152], data[153], data[154], data[155], data[156], data[157], data[158], data[159], data[160], data[161], data[162], data[163], data[164], data[165], data[166], data[167], data[168], data[169]);
+
                        // binär analyse der temperatur
 +
                        Temp = 0 ;
 +
                        if ( WordData[41] & ( 1 << 3 ) ) { Temp = Temp + 1    ; }
 +
                        if ( WordData[41] & ( 1 << 2 ) ) { Temp = Temp + 2    ; }
 +
                        if ( WordData[41] & ( 1 << 1 ) ) { Temp = Temp + 4    ; }
 +
                        if ( WordData[41] & ( 1 << 0 ) ) { Temp = Temp + 8    ; }
 +
                        if ( WordData[42] & ( 1 << 7 ) ) { Temp = Temp + 16  ; }
 +
                        if ( WordData[42] & ( 1 << 6 ) ) { Temp = Temp + 32  ; }
 +
                        if ( WordData[42] & ( 1 << 5 ) ) { Temp = Temp + 64  ; }
 +
                        if ( WordData[42] & ( 1 << 4 ) ) { Temp = Temp + 128  ; }
 +
                        if ( WordData[42] & ( 1 << 3 ) ) { Temp = Temp + 256  ; }
 +
                        if ( WordData[42] & ( 1 << 2 ) ) { Temp = Temp + 512  ; }
 +
                        if ( WordData[42] & ( 1 << 1 ) ) { Temp = Temp + 1024 ; }
 +
                        Temp10=( Temp / 10 );
 +
                        Temp1=( Temp - ( ( Temp / 10 ) * 10 ) );
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[170], data[171], data[172], data[173], data[174], data[175], data[176], data[177], data[178], data[179], data[180], data[181], data[182], data[183], data[184], data[185], data[186], data[187], data[188], data[189], data[190], data[191], data[192], data[193], data[194], data[195], data[196], data[197], data[198], data[199], data[200], data[201], data[202], data[203], data[204], data[205], data[206], data[207], data[208], data[209]);
+
                        // binär analyse der luftfeuchtigkeit
 +
                        Feuchte = 0 ;
 +
                        if ( WordData[43] & ( 1 << 7 ) ) { Feuchte = Feuchte + 1  ; }
 +
                        if ( WordData[43] & ( 1 << 6 ) ) { Feuchte = Feuchte + 2  ; }
 +
                        if ( WordData[43] & ( 1 << 5 ) ) { Feuchte = Feuchte + 4  ; }
 +
                        if ( WordData[43] & ( 1 << 4 ) ) { Feuchte = Feuchte + 8  ; }
 +
                        if ( WordData[43] & ( 1 << 3 ) ) { Feuchte = Feuchte + 10 ; }
 +
                        if ( WordData[43] & ( 1 << 2 ) ) { Feuchte = Feuchte + 20 ; }
 +
                        if ( WordData[43] & ( 1 << 1 ) ) { Feuchte = Feuchte + 40 ; }
 +
                        if ( WordData[43] & ( 1 << 0 ) ) { Feuchte = Feuchte + 80 ; }
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[210], data[211], data[212], data[213], data[214], data[215], data[216], data[217], data[218], data[219], data[220], data[221], data[222], data[223], data[224], data[225], data[226], data[227], data[228], data[229], data[230], data[231], data[232], data[233], data[234], data[235], data[236], data[237], data[238], data[239], data[240], data[241], data[242], data[243], data[244], data[245], data[246], data[247], data[248], data[249]);
+
                        // syslog format, initial priority / facility
 +
                        TCP_SEND("<27>");
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[250], data[251], data[252], data[253], data[254], data[255], data[256], data[257], data[258], data[259], data[260], data[261], data[262], data[263], data[264], data[265], data[266], data[267], data[268], data[269], data[270], data[271], data[272], data[273], data[274], data[275], data[276], data[277], data[278], data[279], data[280], data[281], data[282], data[283], data[284], data[285], data[286], data[287], data[288], data[289]);
+
                        // na welschen monat haben wir den, syslog benötigt diesen ausgeschrieben
 +
                        if ( CLOCK_MONTH() == 1 )  { TCP_SEND("Jan "); }
 +
                        if ( CLOCK_MONTH() == 2 )  { TCP_SEND("Feb "); }
 +
                        if ( CLOCK_MONTH() == 3 )  { TCP_SEND("Mar "); }
 +
                        if ( CLOCK_MONTH() == 4 )  { TCP_SEND("Apr "); }
 +
                        if ( CLOCK_MONTH() == 5 )  { TCP_SEND("May "); }
 +
                        if ( CLOCK_MONTH() == 6 )  { TCP_SEND("Jun "); }
 +
                        if ( CLOCK_MONTH() == 7 )  { TCP_SEND("Jul "); }
 +
                        if ( CLOCK_MONTH() == 8 )  { TCP_SEND("Aug "); }
 +
                        if ( CLOCK_MONTH() == 9 )  { TCP_SEND("Sep "); }
 +
                        if ( CLOCK_MONTH() == 10 ) { TCP_SEND("Oct "); }
 +
                        if ( CLOCK_MONTH() == 11 ) { TCP_SEND("Nov "); }
 +
                        if ( CLOCK_MONTH() == 12 ) { TCP_SEND("Dec "); }
 +
                        TCP_SEND("%02d %02d:%02d:%02d %s wheather: code:", CLOCK_DAY(), CLOCK_HOUR(), CLOCK_MIN(), CLOCK_SEC(), CONF_HOSTNAME);
 +
                        if ( WordData[40] & ( 1 << 3 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[40] & ( 1 << 2 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 +
                        if ( WordData[40] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[40] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[40] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[40] & ( 1 << 4 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 +
                        if ( WordData[40] & ( 1 << 1 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[40] & ( 1 << 0 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
 +
                        if ( WordData[41] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[41] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        if ( WordData[41] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        TCP_SEND(" temp:");
 +
                        if ( WordData[42] & ( 1 << 0 ) ) { TCP_SEND("-");  } else { TCP_SEND("+");  }
 +
                        TCP_SEND("%d.%d hum:%d%% manu:", Temp10, Temp1, Feuchte);
 +
                        if ( WordData[41] & ( 1 << 4 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
 +
                        TCP_SEND(" Match:%d/%d", MatchPos, MatchCount);
 +
                        TCP_SEND(" data:%02x%02x%02x%02x%02x\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
 +
                        #if WEATHERVERBOSE == 1
 +
                                TCP_SEND("00  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[0],  WordData[1],  WordData[2],  WordData[3],  WordData[4],  Analysis[0]);
 +
                                TCP_SEND("01  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[5],  WordData[6],  WordData[7],  WordData[8],  WordData[9],  Analysis[1]);
 +
                                TCP_SEND("02  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[10],  WordData[11],  WordData[12],  WordData[13],  WordData[14], Analysis[2]);
 +
                                TCP_SEND("03  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[15],  WordData[16],  WordData[17],  WordData[18],  WordData[19], Analysis[3]);
 +
                                TCP_SEND("04  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[20],  WordData[21],  WordData[22],  WordData[23],  WordData[24], Analysis[4]);
 +
                                TCP_SEND("05  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[25],  WordData[26],  WordData[27],  WordData[28],  WordData[29], Analysis[5]);
 +
                                TCP_SEND("06  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[30],  WordData[31],  WordData[32],  WordData[33],  WordData[34], Analysis[6]);
 +
                                TCP_SEND("07  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[35],  WordData[36],  WordData[37],  WordData[38],  WordData[39], Analysis[7]);
 +
                                TCP_SEND("Out --> %02x%02x%02x%02x%02x\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
 +
                                TCP_SEND(" \n");
 +
                                TCP_SEND(" \n");
 +
                        #endif
 +
                        #if WEATHERVERBOSE > 1
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[0],  data[1],  data[2],  data[3],  data[4],  data[5],  data[6],  data[7],  data[8],  data[9], data[10],  data[11],  data[12],  data[13],  data[14],  data[15],  data[16],  data[17],  data[18],  data[19],  data[20],  data[21],  data[22],  data[23],  data[24],  data[25],  data[26],  data[27],  data[28],  data[29],  data[30], data[31],  data[32],  data[33],  data[34],  data[35],  data[36],  data[37],  data[38],  data[39]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[40],  data[41],  data[42],  data[43],  data[44],  data[45],  data[46],  data[47],  data[48],  data[49], data[50],  data[51],  data[52],  data[53],  data[54],  data[55],  data[56],  data[57],  data[58],  data[59],  data[60],  data[61],  data[62],  data[63],  data[64],  data[65],  data[66],  data[67],  data[68],  data[69],  data[70], data[71],  data[72],  data[73],  data[74],  data[75],  data[76],  data[77],  data[78],  data[79]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[80],  data[81],  data[82],  data[83],  data[84],  data[85],  data[86],  data[87],  data[88],  data[89], data[100], data[101], data[102], data[103], data[104], data[105], data[106], data[107], data[108], data[109], data[110], data[111], data[112], data[113], data[114], data[115], data[116], data[117], data[118], data[119], data[120], data[121], data[122], data[123], data[124], data[125], data[126], data[127], data[128], data[129]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[130], data[131], data[132], data[133], data[134], data[135], data[136], data[137], data[138], data[139], data[140], data[141], data[142], data[143], data[144], data[145], data[146], data[147], data[148], data[149], data[150], data[151], data[152], data[153], data[154], data[155], data[156], data[157], data[158], data[159], data[160], data[161], data[162], data[163], data[164], data[165], data[166], data[167], data[168], data[169]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[170], data[171], data[172], data[173], data[174], data[175], data[176], data[177], data[178], data[179], data[180], data[181], data[182], data[183], data[184], data[185], data[186], data[187], data[188], data[189], data[190], data[191], data[192], data[193], data[194], data[195], data[196], data[197], data[198], data[199], data[200], data[201], data[202], data[203], data[204], data[205], data[206], data[207], data[208], data[209]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[210], data[211], data[212], data[213], data[214], data[215], data[216], data[217], data[218], data[219], data[220], data[221], data[222], data[223], data[224], data[225], data[226], data[227], data[228], data[229], data[230], data[231], data[232], data[233], data[234], data[235], data[236], data[237], data[238], data[239], data[240], data[241], data[242], data[243], data[244], data[245], data[246], data[247], data[248], data[249]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[250], data[251], data[252], data[253], data[254], data[255], data[256], data[257], data[258], data[259], data[260], data[261], data[262], data[263], data[264], data[265], data[266], data[267], data[268], data[269], data[270], data[271], data[272], data[273], data[274], data[275], data[276], data[277], data[278], data[279], data[280], data[281], data[282], data[283], data[284], data[285], data[286], data[287], data[288], data[289]);
 +
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309], data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309]);
 +
                                TCP_SEND(" \n");
 +
                                TCP_SEND(" \n");
 +
                        #endif
 +
                        Analysis[8] &= ~(1 << 2);      //    deaktivieren der Daten sendung
 +
                }
 +
                Analysis[9] = 0;
 +
                PT_YIELD(pt);
  
        TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309], data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309]);
+
//  Analysis[0 bis 7]               Treffer der Daten Packets Übereinstimmung.
 +
//  Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
 +
//  Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
 +
//  Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
 +
        }
 +
        TCP_HANDLER_END();
  
        TCP_SEND(" \n");
 
        TCP_SEND(" \n");
 
#endif
 
        Analysis[8] &= ~(1 << 2);      dnl    deaktivieren der Daten sendung
 
      }
 
      Analysis[9] = 0;
 
      PT_YIELD(pt);
 
 
dnl  Analysis[0 bis 7]              Treffer der Daten Packets Übereinstimmung.
 
dnl  Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
 
dnl  Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
 
dnl  Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
 
    }
 
  TCP_HANDLER_END();
 
 
CONTROL_END
 
CONTROL_END
+
// ###############################################################################################################################
 
ISR(INT0_vect)
 
ISR(INT0_vect)
 
{
 
{
  timer_0 = TCNT0;
+
        timer_0 = TCNT0;
  counter ++;
+
        counter ++;
  if ( counter >= 310 )
+
        if ( counter >= 310 )
  {
+
        {
    counter = 1 ;
+
                counter = 1 ;
  }
+
        }
  WordPos=(( BitPos / 8 ) + ( WordCound * 5 ));
+
        WordPos=(( BitPos / 8 ) + ( WordCound * 5 ));
 
+
 
  if ( WordPos >= 40 )
+
        if ( WordPos >= 40 )
  {
+
        {
    BitPos = 0 ;
+
                BitPos = 0 ;
    WordCound = 0 ;
+
                WordCound = 0 ;
  }
+
        }
 
+
 
  if ( timer_0 >= Time6 && timer_0 <= ( Time6 + 2 ) )
+
        if ( timer_0 >= Time6 && timer_0 <= ( Time6 + 2 ) )
  {
+
        {
    counter -- ;
+
                counter -- ;
  } else if ( timer_0 == Time0 || timer_0 == ( Time0 + 1 ) )  
+
        } else if ( timer_0 == Time0 || timer_0 == ( Time0 + 1 ) )
  {
+
        {                                                               // L      0      (L - Bit - Normal)
dnl L      0      (L - Bit - Normal)
+
                data[counter] = 0;
    data[counter] = 0;
+
                WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));         // WordData[n] = 0;
    WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));               dnl WordData[n] = 0;
+
                BitPos ++ ;
    BitPos ++ ;
+
        } else if ( timer_0 == Time1 || timer_0 == ( Time1 + 1 ) )
  } else if ( timer_0 == Time1 || timer_0 == ( Time1 + 1 ) )
+
        {                                                               // H      1      (H - Bit - Normal)
  {
+
                data[counter] = 1;
dnl H      1      (H - Bit - Normal)
+
                WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          // WordData[n] = 1;
    data[counter] = 1;
+
                BitPos ++ ;
    WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          dnl WordData[n] = 1;
+
        } else if ( timer_0 == Time2 || timer_0 == ( Time2 + 1 ) )
    BitPos ++ ;
+
        {                                                               // End-l  2      (Ende Datenwort L)
  } else if ( timer_0 == Time2 || timer_0 == ( Time2 + 1 ) )
+
                data[counter] = 2;
  {
+
                WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));       // WordData[n] = 0;
dnl End-l  2      (Ende Datenwort L)
+
                BitPos ++ ;
    data[counter] = 2;
+
        } else if ( timer_0 == Time3 || timer_0 == ( Time3 + 1 ) )
    WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));               dnl WordData[n] = 0;
+
        {                                                               // End-h  3      (Ende Datenwort H)
    BitPos ++ ;
+
                data[counter] = 3;
  } else if ( timer_0 == Time3 || timer_0 == ( Time3 + 1 ) )  
+
                WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          // WordData[n] = 1;
  {
+
                BitPos ++ ;
dnl End-h  3      (Ende Datenwort H)
+
        } else if ( timer_0 >= ( Time4 -2 ) && timer_0 <= ( Time4 + 3 ) )
    data[counter] = 3;
+
        {                                                               // Start  4     (Start Datenwort)
    WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          dnl WordData[n] = 1;
+
                data[counter] = 4;
    BitPos ++ ;
+
                if ( BitPos != 1 )
  } else if ( timer_0 >= ( Time4 -2 ) && timer_0 <= ( Time4 + 3 ) )
+
                {
  {
+
                        WordCound ++ ;
dnl Start  4       (Start Datenwort)
+
                        WordData[ WordPos ] = 0 ;
    data[counter] = 4;
+
                        WordData[ WordPos + 1 ] = 0 ;
    if ( BitPos != 1 )
+
                        WordData[ WordPos + 2 ] = 0 ;
    {
+
                        WordData[ WordPos + 3 ] = 0 ;
      WordCound ++ ;
+
                        WordData[ WordPos + 4 ] = 0 ;
      WordData[ WordPos ] = 0 ;
+
                }
      WordData[ WordPos + 1 ] = 0 ;
+
                BitPos = 0;
      WordData[ WordPos + 2 ] = 0 ;
+
        } else if ( timer_0 == Time5 || timer_0 == ( Time5 + 1 ) )
      WordData[ WordPos + 3 ] = 0 ;
+
        {                                                               // End-    5      (Daten Sendung Ende)
      WordData[ WordPos + 4 ] = 0 ;
+
                data[counter] = 5;
    }
+
        } else
    BitPos = 0;
+
        {                                                               // ?      8      (Nicht Erkanntes Timing)
  } else if ( timer_0 == Time5 || timer_0 == ( Time5 + 1 ) )  
+
                data[counter] = 8;
  {
+
                BitPos ++ ;
dnl End-    5      (Daten Sendung Ende)
+
        }
    data[counter] = 5;
+
        TCNT0 = 0;
  } else
+
 
  {
+
//
dnl ?      8      (Nicht Erkanntes Timing)
+
//    L      0      (L - Bit)                      30
    data[counter] = 8;
+
//    H      1      (H - Bit)                      62
    BitPos ++ ;
+
//    End-l  2      (Ende Datenwort L)              32
   }
+
//    End-h   3      (Ende Datenwort H)              64
   TCNT0 = 0;
+
//    Start  4      (Start Datenwort)              138
 +
//    End-    5      (Daten Sendung Ende)            5
 +
//    _      6      (puls)                          6
 +
//    Pause   7      (Timer Overflow)
 +
//    ?      8      (Nicht Erkanntes Timing)
 +
//
 +
//    uint8_t BitPos = 0;            //    Bit Position innerhalb eines 36 bit worts (0 bis 36)
 +
//    uint8_t WordCound = 0;         //    Daten Wort Count (0 bis 7)
 +
//    uint8_t WordData[40];          //    1 Data Word = 5 Byte    /      Max 8 Data Words
 +
//
 +
 
 +
//    WordData[0]    WordData[1]    WordData[2]    WordData[3]    WordData[4]
 +
//
 +
//    0    0          1    1          2    2          3    3          4    4
 +
//    5    D          0    0          4    8          E    4          7    0
 +
//    0101 1101      0000 0000      0100 1000      1110 0100      0111 0000
 +
//    RRRR CCBB      ???S TTTT      TTTT TTTT      LLLL LLLL      cccc ----
 +
//
  
dnl
 
dnl    L      0      (L - Bit)                      30
 
dnl    H      1      (H - Bit)                      62
 
dnl    End-l  2      (Ende Datenwort L)              32
 
dnl    End-h  3      (Ende Datenwort H)              64
 
dnl    Start  4      (Start Datenwort)              138
 
dnl    End-    5      (Daten Sendung Ende)            5
 
dnl    _      6      (puls)                          6
 
dnl    Pause  7      (Timer Overflow)
 
dnl    ?      8      (Nicht Erkanntes Timing)
 
dnl
 
dnl    uint8_t BitPos = 0;            dnl    Bit Position innerhalb eines 36 bit worts (0 bis 36)
 
dnl    uint8_t WordCound = 0;          dnl    Daten Wort Count (0 bis 7)
 
dnl    uint8_t WordData[40];          dnl    1 Data Word = 5 Byte    /      Max 8 Data Words
 
dnl
 
 
dnl    WordData[0]    WordData[1]    WordData[2]    WordData[3]    WordData[4]
 
dnl
 
dnl    0    0          1    1          2    2          3    3          4    4
 
dnl    5    D          0    0          4    8          E    4          7    0
 
dnl    0101 1101      0000 0000      0100 1000      1110 0100      0111 0000
 
dnl    RRRR CCBB      ???S TTTT      TTTT TTTT      LLLL LLLL      cccc ----
 
dnl
 
 
 
}
 
}
+
// ###############################################################################################################################
 
ISR(TIMER0_OVF_vect)
 
ISR(TIMER0_OVF_vect)
{  
+
{
  if ( WordCound >= 3 )
+
        if ( WordCound >= 3 )
  {
+
        {
    Analysis[8] |= (1 << 2);
+
                Analysis[8] |= (1 << 2);
  }
+
        }
  counter = 0;
+
        counter = 0;
  data[counter] = 7;
+
        data[counter] = 7;
  TIFR0  &= ~_BV(TOV0);          dnl     TIFR0(TOV0) = 0
+
        TIFR0  &= ~_BV(TOV0);          //     TIFR0(TOV0) = 0
  BitPos = 0;
+
        BitPos = 0;
  WordCound = 0;  
+
        WordCound = 0;
 
}
 
}
+
// ###############################################################################################################################
+
 
dnl     gummi:~#
+
 
dnl     gummi:~# while true ; do socat stdio tcp4-listen:4444 ; echo "##########" ; sleep 1 ; done
+
//     gummi:~#
dnl
+
//     gummi:~# while true ; do socat stdio tcp4-listen:95 ; echo "##########" ; sleep 1 ; done
dnl     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
+
//
dnl             cd .. ; make clean ; make ; scp ethersex.bin 10.33.0.10:/srv/tftp/ACDE48D3995F ; cd control6/ ;
+
//     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
dnl             echo "bootloader" | socat stdio tcp4:10.0.0.40:2701
+
//             cd .. ; make clean ; make ; scp ethersex.bin 10.33.0.10:/srv/tftp/ACDE48D3995F ; cd control6/ ;
dnl
+
//             echo "bootloader" | socat stdio tcp4:10.0.0.40:2701
dnl     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
+
//
dnl             cat funk_temp_und_feuchte_daten.src | sed 's/dnl[\ \t]*.*//g' | sed 's/^\t\+$//'  | grep -v '^$'
+
//     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
dnl
+
//             cat funk_temp_und_feuchte_daten.src | sed 's///[\ \t]*.*//g' | sed 's/^\t\+$//'  | grep -v '^$'
dnl     gummi:~#
+
//
dnl             while true ; do socat stdio tcp4-listen:4444 | while read Line ; do
+
//     gummi:~#
dnl             if [ "$(echo $Line | grep -c '^--')" = "1" ] ; then echo ; echo ; else
+
//             while true ; do socat stdio tcp4-listen:4444 | while read Line ; do
dnl             echo -en "$Line" | sed 's/^_//' ; fi ; done | sed 's/\(8[bc]0[78]\)/\n\1/g' ;
+
//             if [ "$(echo $Line | grep -c '^--')" = "1" ] ; then echo ; echo ; else
dnl             echo "##########" ; sleep 1 ; done
+
//             echo -en "$Line" | sed 's/^_//' ; fi ; done | sed 's/\(8[bc]0[78]\)/\n\1/g' ;
dnl
+
//             echo "##########" ; sleep 1 ; done
dnl                     Timing          Timer Count    Timer C. Hex    Decode
+
//
dnl     L      space 1920 bis 1999us  30-31,2        0x1E    0x1F    0
+
//                     Timing          Timer Count    Timer C. Hex    Decode
dnl     H      space 3990 bis 4049us  62,3-63,2      0x3E    0x3F    1
+
//     L      space 1920 bis 1999us  30-31,2        0x1E    0x1F    0
dnl     End-l  space 2060 bis 2089us  32,1-32,6      0x20    0x21    2
+
//     H      space 3990 bis 4049us  62,3-63,2      0x3E    0x3F    1
dnl     End-h  space 4130 bis 4169us  64,5-65,1      0x40    0x41    3
+
//     End-l  space 2060 bis 2089us  32,1-32,6      0x20    0x21    2
dnl     Start  space 8890 bis 8939us  138,9-139,6    0x8A    0x8B    4
+
//     End-h  space 4130 bis 4169us  64,5-65,1      0x40    0x41    3
dnl     End-    pulse  360 bis 369us    5,6-5,7        0x05            5
+
//     Start  space 8890 bis 8939us  138,9-139,6    0x8A    0x8B    4
dnl     _      pulse  440 bis 519us    6,8-8,1        0x06    0x08    6
+
//     End-    pulse  360 bis 369us    5,6-5,7        0x05            5
dnl     Pause                                                          7
+
//     _      pulse  440 bis 519us    6,8-8,1        0x06    0x08    6
dnl
+
//     Pause                                                          7
dnl
+
//
dnl
 
dnl
 
 
</source>
 
</source>
 
<br>
 
<br>
Zeile 365: Zeile 374:
 
(/mnt/log/current/2009/08/03/08/wichtel/ethersex/daemon.err.log<br>
 
(/mnt/log/current/2009/08/03/08/wichtel/ethersex/daemon.err.log<br>
 
<source lang="text">
 
<source lang="text">
Aug  3 08:15:29 wichtel ethersex: Sender=01-0101-11-001 Temp=+26.4 Feuchte=32% SonderSendung=1  (5731084c00)
+
Apr 30 09:42:39 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:24% manu:0 Match:7/7 data: e721082400
Aug  3 08:15:29 wichtel ethersex: Sender=01-0101-11-001 Temp=+26.4 Feuchte=32% SonderSendung=1  (5731084c00)
+
Apr 30 09:43:09 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:25% manu:0 Match:7/7 data: e72108a400
Aug  3 08:16:21 wichtel ethersex: Sender=01-0101-11-001 Temp=+26.6 Feuchte=32% SonderSendung=1  (5735084c00)
+
Apr 30 09:43:39 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:24% manu:0 Match:7/7 data: e721082400
Aug  3 08:16:21 wichtel ethersex: Sender=01-0101-11-001 Temp=+26.6 Feuchte=32% SonderSendung=1  (5735084c00)
 
Aug  3 08:16:52 wichtel ethersex: Sender=01-0101-11-001 Temp=+26.7 Feuchte=31% SonderSendung=0  (572d088c00)
 
 
</source>
 
</source>
 
<br>
 
<br>

Version vom 30. April 2010, 09:46 Uhr










// ################################################################################
// #                                                                              #
// # Daten Analyse und Programm Erstellung:                                       #
// #   Copyright (c) 2009-2010 - Michael Schultz <ethersex@keyb.de>               #
// #      Mit viel unterstuetzung/Geduld von: stesie, veyron und DanielW          #
// #                                                                              #
// # This program is free software; you can redistribute it and/or modify it      #
// # under the terms of the GNU General Public License (either version 2 or       #
// # version 3) as published by the Free Software Foundation.                     #
// #                                                                              #
// # This program is distributed in the hope that it will be useful,              #
// # but WITHOUT ANY WARRANTY; without even the implied warranty of               #
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
// # GNU General Public License for more details.                                 #
// #                                                                              #
// # You should have received a copy of the GNU General Public License            #
// # along with this program; if not, write to the Free Software                  #
// # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                    #
// #                                                                              #
// # For more information on the GPL, please go to:                               #
// # http://www.gnu.org/copyleft/gpl.html                                         #
// #                                                                              #
// #                                                                              #
// # Wetter-Funk-Daten Analyse Programm für Wetter Station der Firma              #
// #     Krippl Watches GmbH   --   http://www.produktservice.info                #
// # Protokoll analyse siehe:                                                     #
// #     http://www.ethersex.de/index.php/Funk-wetterstations-protokoll           #
// #                                                                              #
// ################################################################################

// Logging Destination Host: 10.0.0.77 on Port 95

#define PRESCALER 1024
#define NS_PER_TICK     (PRESCALER * 1000000UL / F_CPU * 1000)
#define US_TO_TICKS(n)  ((n) * 1000UL / NS_PER_TICK)

// debug ausgabe 0 = keine debug meldungen, 1 = ein bischen merh, und 2 für komplette bit analyse
#define WEATHERVERBOSE 0

uint8_t data[310];
uint16_t counter;
                                        // Timing          @16mhz: Timer Count     Timer C. Hex    Decode
uint8_t Time0 = US_TO_TICKS(1920);      // L       space 1920 bis 1999us            30-31,2         0x1E    0x1F    0
uint8_t Time1 = US_TO_TICKS(3990);      // H       space 3990 bis 4049us            62,3-63,2       0x3E    0x3F    1
uint8_t Time2 = US_TO_TICKS(2060);      // End-l   space 2060 bis 2089us            32,1-32,6       0x20    0x21    2
uint8_t Time3 = US_TO_TICKS(4130);      // End-h   space 4130 bis 4169us            64,5-65,1       0x40    0x41    3
uint8_t Time4 = US_TO_TICKS(8890);      // Start   space 8890 bis 8939us            138,9-139,6     0x8A    0x8B    4
uint8_t Time5 = US_TO_TICKS(360);       // End-    pulse  360 bis 369us             5,6-5,7         0x05            5
uint8_t Time6 = US_TO_TICKS(440);       // _       pulse  440 bis 519us             6,8-8,1         0x06    0x08    6
                                        // Pause
                                        //
uint8_t BitPos = 0;                     // Bit Position innerhalb eines 36 bit worts (1 bis 37)
uint8_t WordCound = 0;                  // Daten Wort Count (1 bis 9)
uint8_t WordData[45];                   // 1 Data Word = 5 Byte    /       Max 8 Data Words
uint8_t WordPos = 0;                    // Byte Pos in WordData
uint8_t MatchPos = 0;                   // meist vorkommene datenwort position im telegram
uint8_t MatchCount = 0;                 // wie viel treffer hatte dieses meist vorkommende telegram
                                        //
uint16_t Temp = 0;                      // Temperatur Wert (-)76,8 bis (+)127,9 °C, Vorzeichen wird erst bei der ausgabe gesetzt.
uint16_t Feuchte = 0;                   // Luftfeuchte Wert 20-99 %
uint8_t timer_0 = 0;                    // Timer Wert für zeitbestimming zwichen 2 Pegel änderungen (Interrupts)
uint8_t Temp1 = 0;                      // Temperatur wert, einer stelle --> 0,n °C
uint8_t Temp10 = 0;                     // Temperatur wert, zener stelle --> n,0 °C
                                        //
uint8_t Analysis[10] ;                  // Daten Analyse array
                                        // Analysis[0 bis 7]               Treffer der Daten Packets Übereinstimmung.
                                        // Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
                                        // Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
                                        // Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
                                        // Analysis[9]                     Array Positions Counter fuer analyse

CONTROL_START
        ON STARTUP DO
                Analysis[8]     |= (1 << 2);            //      nach start einmal ausgabe, um zu schauen wann das ding gebootet ist...
                _TCCR0_PRESCALE |=  _BV(CS02);          //      TCCR0B(CS02)=1
                _TCCR0_PRESCALE &= ~_BV(CS01);          //      TCCR0B(CS01)=0
                _TCCR0_PRESCALE |=  _BV(CS00);          //      TCCR0B(CS00)=1
                _EIMSK          |=  _BV(INT0);          //      EIMSK(INT0) = 1         Interrupt, Input Data on INT0 / PD2
                _EICRA          &= ~_BV(ISC01);         //      EICRA(ISC01) = 0        interrupt on any edge, asyncronously
                _EICRA          |=  _BV(ISC00);         //      EICRA(ISC00) = 1        interrupt on any edge, asyncronously
                _TIMSK_TIMER0   |=  _BV(TOIE0);         //      TIMSK0(TOIE0) = 1       Interrupt on Timer Overflow aktivieren
                TCP_CONNECT(10.0.0.77, 95, message_handler);
        END

        TCP_HANDLER_PERSIST(message_handler)
        for (;;)
        {

                // Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
                if ( Analysis[8] & ( 1 << 2 ) )
                {
                        // Lösche ale Analysis Counter
                        for (int Count1 = 0; Count1 < 8; Count1 ++) Analysis[ (Count1) ] = 0 ;

                        // wie oft matcht welsches telegram mit allen anderen 8 telegrammen
                        for (int Count1 = 0; Count1 < 8; Count1 ++)
                                for (int Count2 = 0; Count2 < 8; Count2 ++)
                                        if (memcmp(&WordData[ (Count1) * 5 ], &WordData[ ( Count2 + 1 ) * 5], 5) == 0)
                                                { Analysis[ (Count1) ] ++ ; }

                        // nim nur das telegram mit der größten anzahl an treffer
                        for (int Count1 = 8; Count1 > 1; Count1 --)
                                for (int Count2 = 0; Count2 < 8; Count2 ++)
                                        if ( Analysis[ (Count2) ] == Count1 )
                                        {
                                                MatchPos = Count2 ;
                                                MatchCount = Count1 ;
                                                WordData[40] = WordData[ ( MatchPos * 5 )     ] ;
                                                WordData[41] = WordData[ ( MatchPos * 5 ) + 1 ] ;
                                                WordData[42] = WordData[ ( MatchPos * 5 ) + 2 ] ;
                                                WordData[43] = WordData[ ( MatchPos * 5 ) + 3 ] ;
                                                WordData[44] = WordData[ ( MatchPos * 5 ) + 4 ] ;
                                        }

                        // binär analyse der temperatur
                        Temp = 0 ;
                        if ( WordData[41] & ( 1 << 3 ) ) { Temp = Temp + 1    ; }
                        if ( WordData[41] & ( 1 << 2 ) ) { Temp = Temp + 2    ; }
                        if ( WordData[41] & ( 1 << 1 ) ) { Temp = Temp + 4    ; }
                        if ( WordData[41] & ( 1 << 0 ) ) { Temp = Temp + 8    ; }
                        if ( WordData[42] & ( 1 << 7 ) ) { Temp = Temp + 16   ; }
                        if ( WordData[42] & ( 1 << 6 ) ) { Temp = Temp + 32   ; }
                        if ( WordData[42] & ( 1 << 5 ) ) { Temp = Temp + 64   ; }
                        if ( WordData[42] & ( 1 << 4 ) ) { Temp = Temp + 128  ; }
                        if ( WordData[42] & ( 1 << 3 ) ) { Temp = Temp + 256  ; }
                        if ( WordData[42] & ( 1 << 2 ) ) { Temp = Temp + 512  ; }
                        if ( WordData[42] & ( 1 << 1 ) ) { Temp = Temp + 1024 ; }
                        Temp10=( Temp / 10 );
                        Temp1=( Temp - ( ( Temp / 10 ) * 10 ) );

                        // binär analyse der luftfeuchtigkeit
                        Feuchte = 0 ;
                        if ( WordData[43] & ( 1 << 7 ) ) { Feuchte = Feuchte + 1  ; }
                        if ( WordData[43] & ( 1 << 6 ) ) { Feuchte = Feuchte + 2  ; }
                        if ( WordData[43] & ( 1 << 5 ) ) { Feuchte = Feuchte + 4  ; }
                        if ( WordData[43] & ( 1 << 4 ) ) { Feuchte = Feuchte + 8  ; }
                        if ( WordData[43] & ( 1 << 3 ) ) { Feuchte = Feuchte + 10 ; }
                        if ( WordData[43] & ( 1 << 2 ) ) { Feuchte = Feuchte + 20 ; }
                        if ( WordData[43] & ( 1 << 1 ) ) { Feuchte = Feuchte + 40 ; }
                        if ( WordData[43] & ( 1 << 0 ) ) { Feuchte = Feuchte + 80 ; }

                        // syslog format, initial priority / facility
                        TCP_SEND("<27>");

                        // na welschen monat haben wir den, syslog benötigt diesen ausgeschrieben
                        if ( CLOCK_MONTH() == 1 )  { TCP_SEND("Jan "); }
                        if ( CLOCK_MONTH() == 2 )  { TCP_SEND("Feb "); }
                        if ( CLOCK_MONTH() == 3 )  { TCP_SEND("Mar "); }
                        if ( CLOCK_MONTH() == 4 )  { TCP_SEND("Apr "); }
                        if ( CLOCK_MONTH() == 5 )  { TCP_SEND("May "); }
                        if ( CLOCK_MONTH() == 6 )  { TCP_SEND("Jun "); }
                        if ( CLOCK_MONTH() == 7 )  { TCP_SEND("Jul "); }
                        if ( CLOCK_MONTH() == 8 )  { TCP_SEND("Aug "); }
                        if ( CLOCK_MONTH() == 9 )  { TCP_SEND("Sep "); }
                        if ( CLOCK_MONTH() == 10 ) { TCP_SEND("Oct "); }
                        if ( CLOCK_MONTH() == 11 ) { TCP_SEND("Nov "); }
                        if ( CLOCK_MONTH() == 12 ) { TCP_SEND("Dec "); }
                        TCP_SEND("%02d %02d:%02d:%02d %s wheather: code:", CLOCK_DAY(), CLOCK_HOUR(), CLOCK_MIN(), CLOCK_SEC(), CONF_HOSTNAME);
                        if ( WordData[40] & ( 1 << 3 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[40] & ( 1 << 2 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
                        if ( WordData[40] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[40] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[40] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[40] & ( 1 << 4 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
                        if ( WordData[40] & ( 1 << 1 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[40] & ( 1 << 0 ) ) { TCP_SEND("1-"); } else { TCP_SEND("0-"); }
                        if ( WordData[41] & ( 1 << 7 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[41] & ( 1 << 6 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        if ( WordData[41] & ( 1 << 5 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        TCP_SEND(" temp:");
                        if ( WordData[42] & ( 1 << 0 ) ) { TCP_SEND("-");  } else { TCP_SEND("+");  }
                        TCP_SEND("%d.%d hum:%d%% manu:", Temp10, Temp1, Feuchte);
                        if ( WordData[41] & ( 1 << 4 ) ) { TCP_SEND("1");  } else { TCP_SEND("0");  }
                        TCP_SEND(" Match:%d/%d", MatchPos, MatchCount);
                        TCP_SEND(" data:%02x%02x%02x%02x%02x\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
                        #if WEATHERVERBOSE == 1
                                TCP_SEND("00  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[0],   WordData[1],   WordData[2],   WordData[3],   WordData[4],  Analysis[0]);
                                TCP_SEND("01  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[5],   WordData[6],   WordData[7],   WordData[8],   WordData[9],  Analysis[1]);
                                TCP_SEND("02  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[10],  WordData[11],  WordData[12],  WordData[13],  WordData[14], Analysis[2]);
                                TCP_SEND("03  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[15],  WordData[16],  WordData[17],  WordData[18],  WordData[19], Analysis[3]);
                                TCP_SEND("04  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[20],  WordData[21],  WordData[22],  WordData[23],  WordData[24], Analysis[4]);
                                TCP_SEND("05  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[25],  WordData[26],  WordData[27],  WordData[28],  WordData[29], Analysis[5]);
                                TCP_SEND("06  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[30],  WordData[31],  WordData[32],  WordData[33],  WordData[34], Analysis[6]);
                                TCP_SEND("07  --> %02x%02x%02x%02x%02x  Match:%d\n", WordData[35],  WordData[36],  WordData[37],  WordData[38],  WordData[39], Analysis[7]);
                                TCP_SEND("Out --> %02x%02x%02x%02x%02x\n", WordData[40],  WordData[41],  WordData[42],  WordData[43],  WordData[44]);
                                TCP_SEND(" \n");
                                TCP_SEND(" \n");
                        #endif
                        #if WEATHERVERBOSE > 1
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[0],   data[1],   data[2],   data[3],   data[4],   data[5],   data[6],   data[7],   data[8],   data[9], data[10],  data[11],  data[12],  data[13],  data[14],  data[15],  data[16],  data[17],  data[18],  data[19],  data[20],  data[21],  data[22],  data[23],  data[24],  data[25],  data[26],  data[27],  data[28],  data[29],  data[30], data[31],  data[32],  data[33],  data[34],  data[35],  data[36],  data[37],  data[38],  data[39]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[40],  data[41],  data[42],  data[43],  data[44],  data[45],  data[46],  data[47],  data[48],  data[49], data[50],  data[51],  data[52],  data[53],  data[54],  data[55],  data[56],  data[57],  data[58],  data[59],  data[60],  data[61],  data[62],  data[63],  data[64],  data[65],  data[66],  data[67],  data[68],  data[69],  data[70], data[71],  data[72],  data[73],  data[74],  data[75],  data[76],  data[77],  data[78],  data[79]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[80],  data[81],  data[82],  data[83],  data[84],  data[85],  data[86],  data[87],  data[88],  data[89], data[100], data[101], data[102], data[103], data[104], data[105], data[106], data[107], data[108], data[109], data[110], data[111], data[112], data[113], data[114], data[115], data[116], data[117], data[118], data[119], data[120], data[121], data[122], data[123], data[124], data[125], data[126], data[127], data[128], data[129]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[130], data[131], data[132], data[133], data[134], data[135], data[136], data[137], data[138], data[139], data[140], data[141], data[142], data[143], data[144], data[145], data[146], data[147], data[148], data[149], data[150], data[151], data[152], data[153], data[154], data[155], data[156], data[157], data[158], data[159], data[160], data[161], data[162], data[163], data[164], data[165], data[166], data[167], data[168], data[169]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[170], data[171], data[172], data[173], data[174], data[175], data[176], data[177], data[178], data[179], data[180], data[181], data[182], data[183], data[184], data[185], data[186], data[187], data[188], data[189], data[190], data[191], data[192], data[193], data[194], data[195], data[196], data[197], data[198], data[199], data[200], data[201], data[202], data[203], data[204], data[205], data[206], data[207], data[208], data[209]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[210], data[211], data[212], data[213], data[214], data[215], data[216], data[217], data[218], data[219], data[220], data[221], data[222], data[223], data[224], data[225], data[226], data[227], data[228], data[229], data[230], data[231], data[232], data[233], data[234], data[235], data[236], data[237], data[238], data[239], data[240], data[241], data[242], data[243], data[244], data[245], data[246], data[247], data[248], data[249]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[250], data[251], data[252], data[253], data[254], data[255], data[256], data[257], data[258], data[259], data[260], data[261], data[262], data[263], data[264], data[265], data[266], data[267], data[268], data[269], data[270], data[271], data[272], data[273], data[274], data[275], data[276], data[277], data[278], data[279], data[280], data[281], data[282], data[283], data[284], data[285], data[286], data[287], data[288], data[289]);
                                TCP_SEND("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309], data[290], data[291], data[292], data[293], data[294], data[295], data[296], data[297], data[298], data[299], data[300], data[301], data[302], data[303], data[304], data[305], data[306], data[307], data[308], data[309]);
                                TCP_SEND(" \n");
                                TCP_SEND(" \n");
                        #endif
                        Analysis[8] &= ~(1 << 2);       //     deaktivieren der Daten sendung
                }
                Analysis[9] = 0;
                PT_YIELD(pt);

//   Analysis[0 bis 7]               Treffer der Daten Packets Übereinstimmung.
//   Analysis[8] - bit(0) = 1        Daten Liegen an und können vearbeitete werden
//   Analysis[8] - bit(1) = 1        Datenanalyse erfolgreich, Mindestens 3 Übereinstimmungen
//   Analysis[8] - bit(2) = 1        Daten sind Verarbeitet und können gesendet werden
        }
        TCP_HANDLER_END();

CONTROL_END
// ###############################################################################################################################
ISR(INT0_vect)
{
        timer_0 = TCNT0;
        counter ++;
        if ( counter >= 310 )
        {
                counter = 1 ;
        }
        WordPos=(( BitPos / 8 ) + ( WordCound * 5 ));

        if ( WordPos >= 40 )
        {
                BitPos = 0 ;
                WordCound = 0 ;
        }

        if ( timer_0 >= Time6 && timer_0 <= ( Time6 + 2 ) )
        {
                counter -- ;
        } else if ( timer_0 == Time0 || timer_0 == ( Time0 + 1 ) )
        {                                                               // L       0       (L - Bit - Normal)
                data[counter] = 0;
                WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));         // WordData[n] = 0;
                BitPos ++ ;
        } else if ( timer_0 == Time1 || timer_0 == ( Time1 + 1 ) )
        {                                                               // H       1       (H - Bit - Normal)
                data[counter] = 1;
                WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          // WordData[n] = 1;
                BitPos ++ ;
        } else if ( timer_0 == Time2 || timer_0 == ( Time2 + 1 ) )
        {                                                               // End-l   2       (Ende Datenwort L)
                data[counter] = 2;
                WordData[WordPos] &= ~(1 << ( 7 - (BitPos % 8)));       // WordData[n] = 0;
                BitPos ++ ;
        } else if ( timer_0 == Time3 || timer_0 == ( Time3 + 1 ) )
        {                                                               // End-h   3       (Ende Datenwort H)
                data[counter] = 3;
                WordData[WordPos] |= 1 << ( 7 - (BitPos % 8));          // WordData[n] = 1;
                BitPos ++ ;
        } else if ( timer_0 >= ( Time4 -2 ) && timer_0 <= ( Time4 + 3 ) )
        {                                                               // Start   4      (Start Datenwort)
                data[counter] = 4;
                if ( BitPos != 1 )
                {
                        WordCound ++ ;
                        WordData[ WordPos ] = 0 ;
                        WordData[ WordPos + 1 ] = 0 ;
                        WordData[ WordPos + 2 ] = 0 ;
                        WordData[ WordPos + 3 ] = 0 ;
                        WordData[ WordPos + 4 ] = 0 ;
                }
                BitPos = 0;
        } else if ( timer_0 == Time5 || timer_0 == ( Time5 + 1 ) )
        {                                                               // End-    5       (Daten Sendung Ende)
                data[counter] = 5;
        } else
        {                                                               // ?       8       (Nicht Erkanntes Timing)
                data[counter] = 8;
                BitPos ++ ;
        }
        TCNT0 = 0;

//
//     L       0       (L - Bit)                       30
//     H       1       (H - Bit)                       62
//     End-l   2       (Ende Datenwort L)              32
//     End-h   3       (Ende Datenwort H)              64
//     Start   4       (Start Datenwort)               138
//     End-    5       (Daten Sendung Ende)            5
//     _       6       (puls)                          6
//     Pause   7       (Timer Overflow)
//     ?       8       (Nicht Erkanntes Timing)
//
//     uint8_t BitPos = 0;             //     Bit Position innerhalb eines 36 bit worts (0 bis 36)
//     uint8_t WordCound = 0;          //     Daten Wort Count (0 bis 7)
//     uint8_t WordData[40];           //     1 Data Word = 5 Byte    /       Max 8 Data Words
//

//     WordData[0]     WordData[1]     WordData[2]     WordData[3]     WordData[4]
//
//     0    0          1    1          2    2          3    3          4    4
//     5    D          0    0          4    8          E    4          7    0
//     0101 1101       0000 0000       0100 1000       1110 0100       0111 0000
//     RRRR CCBB       ???S TTTT       TTTT TTTT       LLLL LLLL       cccc ----
//

}
// ###############################################################################################################################
ISR(TIMER0_OVF_vect)
{
        if ( WordCound >= 3 )
        {
                Analysis[8] |= (1 << 2);
        }
        counter = 0;
        data[counter] = 7;
        TIFR0  &= ~_BV(TOV0);           //     TIFR0(TOV0) = 0
        BitPos = 0;
        WordCound = 0;
}
// ###############################################################################################################################


//     gummi:~#
//     gummi:~# while true ; do socat stdio tcp4-listen:95 ; echo "##########" ; sleep 1 ; done
//
//     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
//             cd .. ; make clean ; make ; scp ethersex.bin 10.33.0.10:/srv/tftp/ACDE48D3995F ; cd control6/ ;
//             echo "bootloader" | socat stdio tcp4:10.0.0.40:2701
//
//     gummi:/usr/src/ethersex/090730_wichtel_ac:de:48:d3:99:5f/ethersex/control6#
//             cat funk_temp_und_feuchte_daten.src | sed 's///[\ \t]*.*//g' | sed 's/^\t\+$//'  | grep -v '^$'
//
//     gummi:~#
//             while true ; do socat stdio tcp4-listen:4444 | while read Line ; do
//             if [ "$(echo $Line | grep -c '^--')" = "1" ] ; then echo ; echo ; else
//             echo -en "$Line" | sed 's/^_//' ; fi ; done | sed 's/\(8[bc]0[78]\)/\n\1/g' ;
//             echo "##########" ; sleep 1 ; done
//
//                     Timing          Timer Count     Timer C. Hex    Decode
//     L       space 1920 bis 1999us   30-31,2         0x1E    0x1F    0
//     H       space 3990 bis 4049us   62,3-63,2       0x3E    0x3F    1
//     End-l   space 2060 bis 2089us   32,1-32,6       0x20    0x21    2
//     End-h   space 4130 bis 4169us   64,5-65,1       0x40    0x41    3
//     Start   space 8890 bis 8939us   138,9-139,6     0x8A    0x8B    4
//     End-    pulse  360 bis 369us    5,6-5,7         0x05            5
//     _       pulse  440 bis 519us    6,8-8,1         0x06    0x08    6
//     Pause                                                           7
//





Emfangen der "Wetter" Daten Mittels Syslog-NG

Sample "/etc/syslog-ng/syslog-ng.conf" File

################################################################################
# Speicherung der "Wetter" Daten (Temp und Feuchte)
################################################################################
source src_net_t95 {    tcp(    ip(10.0.0.77)   port(95)        max_connections(1000)   );      };
destination dst_file_t95 {      file("/mnt/log/current/$YEAR/$MONTH/$DAY/$HOUR/$HOST/$PROGRAM/$FACILITY.$PRIORITY.log"); };
log {   source(src_net_t95);    destination(dst_file_t95);      };
################################################################################



So sehen die daten dann gespeichert aus:
(/mnt/log/current/2009/08/03/08/wichtel/ethersex/daemon.err.log

Apr 30 09:42:39 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:24% manu:0 Match:7/7 data: e721082400
Apr 30 09:43:09 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:25% manu:0 Match:7/7 data: e72108a400
Apr 30 09:43:39 wichtel wheather: code:01-1110-11-001 temp:+26.4 humidity:24% manu:0 Match:7/7 data: e721082400