• Willkommen im Forum „Wetterstationsforum.info - Archiv“.
 

Neuigkeiten:

Dieses Forum dient ausschließlich zu Archivzwecken.
Für Fragen nutze bitte unser aktuelles Forum, welches du unter https://wetterstationsforum.info findest.

Hauptmenü

Großes Problem mit log2300.c gelöst!

Begonnen von egoshooter, 18.12.2010, 02:13:56

⏪ vorheriges - nächstes ⏩

egoshooter

Moin,
nach dem meine Slug vor 2 Wochen zusammen gebrochen war,
bin ich immer noch am Reparieren.
Die NSLU neu aufgesetzt, unslingt und Open2300 wieder drauf.
Config file bearbeitet cw2300 und log2300 per script gestartet.
Ein Blick in mein Log "Schei*e"
Hatte seinerzeit die log2300.c meinen Anforderungen angepasst und "ge -maked"  - lief wunderbar :-) aber kein Backup angefertigt......
Da ich von der C bzw Linux Syntax sehr wenig Erfahrung hatte/habe, habe ich wieder ins Blaue per Trial and Error programmiert.
Ich habe auch alles soweit wieder hinbekommen.
Nur meine Windböen/ Gusts werden in Miles/h weggeschrieben und möchte da gerne m/s stehen haben.
Kann da mal einer darüber schauen wo es hakt?
Codezeilen folgen:
Make sagt too few arguments

Am Ende das Original

Beste Grüße

Arne

   WEATHERSTATION ws2300;
   FILE *fileptr;
   unsigned char logline[3000] = "";
   char datestring[50];        //used to hold the date stamp for the log file
   const char *directions[]= {"N","NNE","NE","ENE","E","ESE","SE","SSE",
                              "S","SSW","SW","WSW","W","WNW","NW","NNW"};
   double winddir[6];
   int tempint;
   struct config_type config;
   time_t basictime;

   get_configuration(&config, argv[2]);

   ws2300 = open_weatherstation(config.serial_device_name);

  /* Get log filename. */

   if (argc <2> 3)
   {
      print_usage();
   }         

   fileptr = fopen(argv[1], "a+");
   if (fileptr == NULL)
   {
      printf("Cannot open file %s\n",argv[1]);
      exit(-1);
   }


   

   /* READ TEMPERATURE OUTDOOR */

   sprintf(logline,"%s%.1f ", logline,
           temperature_outdoor(ws2300, config.temperature_conv));
   
   
   /* READ DEWPOINT */

   sprintf(logline,"%s%.1f ", logline,
           dewpoint(ws2300, config.temperature_conv));
   
   
   /* READ RELATIVE HUMIDITY OUTDOOR */

   sprintf(logline,"%s%d ", logline, humidity_outdoor(ws2300));   


   /* READ WIND SPEED AND DIRECTION */

   sprintf(logline,"%s%.1f ", logline,
          wind_all(ws2300, config.wind_speed_conv_factor, &tempint, winddir));
   sprintf(logline,"%s%.1f %s ", logline, winddir[0], directions[tempint]);

         /* WIND GUST */
   
 sprintf(logline, "%s%.1f ", logline,
           wind_minmax(ws2300, config.wind_speed_conv_factor));


   
   /* READ RAIN 1H */

   sprintf(logline,"%s%.2f ", logline,
           rain_1h(ws2300, config.rain_conv_factor));
   
   
   /* READ RAIN 24H */

   sprintf(logline,"%s%.2f ", logline,
           rain_24h(ws2300, config.rain_conv_factor));


   /* READ RAIN TOTAL */
   
   sprintf(logline,"%s%.2f ", logline,
           rain_total(ws2300, config.rain_conv_factor));

   
   /* READ RELATIVE PRESSURE */

   sprintf(logline,"%s%.3f ", logline,
           rel_pressure(ws2300, config.pressure_conv_factor));
   




   /* GET DATE AND TIME FOR LOG FILE, PLACE BEFORE ALL DATA IN LOG LINE */
   
   time(&basictime);
   strftime(datestring,sizeof(datestring),"%Y%m%d%H%M%S %Y-%b-%d %H:%M:%S",
            localtime(&basictime));

   // Print out and leave

   // printf("%s %s\n",datestring, logline); //disabled to be used in cron job
   fprintf(fileptr,"%s %s\n",datestring, logline);

   close_weatherstation(ws2300);
   
   fclose(fileptr);

   exit(0);



Original:---------------------------------------
int main(int argc, char *argv[])
{
   WEATHERSTATION ws2300;
   FILE *fileptr;
   unsigned char logline[3000] = "";
   char datestring[50];        //used to hold the date stamp for the log file
   const char *directions[]= {"N","NNE","NE","ENE","E","ESE","SE","SSE",
                              "S","SSW","SW","WSW","W","WNW","NW","NNW"};
   double winddir[6];
   int tempint;
   char tendency[15];
   char forecast[15];
   struct config_type config;
   time_t basictime;

   get_configuration(&config, argv[2]);

   ws2300 = open_weatherstation(config.serial_device_name);

  /* Get log filename. */

   if (argc <2> 3)
   {
      print_usage();
   }         

   fileptr = fopen(argv[1], "a+");
   if (fileptr == NULL)
   {
      printf("Cannot open file %s\n",argv[1]);
      exit(-1);
   }


   /* READ TEMPERATURE INDOOR */
   
   sprintf(logline,"%s%.1f ", logline,
           temperature_indoor(ws2300, config.temperature_conv));
   

   /* READ TEMPERATURE OUTDOOR */

   sprintf(logline,"%s%.1f ", logline,
           temperature_outdoor(ws2300, config.temperature_conv));
   
   
   /* READ DEWPOINT */

   sprintf(logline,"%s%.1f ", logline,
           dewpoint(ws2300, config.temperature_conv));
   
   
   /* READ RELATIVE HUMIDITY INDOOR */

   sprintf(logline,"%s%d ", logline, humidity_indoor(ws2300));   
   
   
   /* READ RELATIVE HUMIDITY OUTDOOR */

   sprintf(logline,"%s%d ", logline, humidity_outdoor(ws2300));   


   /* READ WIND SPEED AND DIRECTION */

   sprintf(logline,"%s%.1f ", logline,
          wind_all(ws2300, config.wind_speed_conv_factor, &tempint, winddir));
   sprintf(logline,"%s%.1f %s ", logline, winddir[0], directions[tempint]);


   /* READ WINDCHILL */
   
   sprintf(logline,"%s%.1f ", logline,
           windchill(ws2300, config.temperature_conv));

   
   /* READ RAIN 1H */

   sprintf(logline,"%s%.2f ", logline,
           rain_1h(ws2300, config.rain_conv_factor));
   
   
   /* READ RAIN 24H */

   sprintf(logline,"%s%.2f ", logline,
           rain_24h(ws2300, config.rain_conv_factor));

   
   /* READ RAIN TOTAL */
   
   sprintf(logline,"%s%.2f ", logline,
           rain_total(ws2300, config.rain_conv_factor));

   
   /* READ RELATIVE PRESSURE */

   sprintf(logline,"%s%.3f ", logline,
           rel_pressure(ws2300, config.pressure_conv_factor));
   

   /* READ TENDENCY AND FORECAST */
   
   tendency_forecast(ws2300, tendency, forecast);
   sprintf(logline,"%s%s %s ", logline, tendency, forecast);


   /* GET DATE AND TIME FOR LOG FILE, PLACE BEFORE ALL DATA IN LOG LINE */
   
   time(&basictime);
   strftime(datestring,sizeof(datestring),"%Y%m%d%H%M%S %Y-%b-%d %H:%M:%S",
            localtime(&basictime));

   // Print out and leave

   // printf("%s %s\n",datestring, logline); //disabled to be used in cron job
   fprintf(fileptr,"%s %s\n",datestring, logline);

   close_weatherstation(ws2300);
   
   fclose(fileptr);

   exit(0);
}

-----------hier wird dann selbstverständlich nicht gemeckert

Pfanner

Ohne mir jetzt den Code angesehen zu haben, stellt man die Einheiten doch in der open2300.conf ein.

Gruß
Stefan

egoshooter

Moin Stefan,

ja das ist richtig, gilt aber nicht für log2300.
Weil log2300 keine Böen schreibt, habe ich den Code einfach aus cw2300 herauskopiert und alles was mit arps zu tun hat gelöscht.
Citizen weather will aber mp/h.
Hatte es auch mal mit dem Code aus fetch2300 probiert:

/* READ WINDSPEED MIN/MAX */

   wind_minmax(ws2300, config.wind_speed_conv_factor, &tempfloat_min,
               &tempfloat_max, &time_min, &time_max);

   sprintf(logline, "%sWSmin %.1f\n", logline, tempfloat_min);
   sprintf(logline, "%sWSmax %.1f\n", logline, tempfloat_max);

   sprintf(logline,"%sTWSmin %02d:%02d\nDWSmin %04d-%02d-%02d\n", logline,
           time_min.hour, time_min.minute, time_min.year,
           time_min.month, time_min.day);
   sprintf(logline,"%sTWSmax %02d:%02d\nDWSmax %04d-%02d-%02d\n", logline,
           time_max.hour, time_max.minute, time_max.year,
           time_max.month, time_max.day);


Nur möchte ich weder das Datum noch das Minimum zusätzlich geschrieben haben.
Weißt Du da einen Reim drauf?

Beste Grüße
Arne

Pfanner

Hmm,

probiers mal so:

/* WIND GUST */

sprintf(logline, "%s%.1f ", logline, wind_minmax(ws2300,config.wind_speed_conv_factor,NULL,NULL,NULL,NULL));


Gruß
Stefan

egoshooter

Moin Stefan,

:top:
das war es! Vielen vielen Dank!

Wünsche noch ein frohes Fest

Arne

BTW. Mein Anemometer ist erst heute wieder aufgetaut :eek: