/* open xml2300.c * * Version 1.10 * * Control WS2300 weather station * * Copyright 2003-2005, Kenneth Lavrsen * This program is published under the GNU General Public license * * Update History: * 1.0 2004 Feb 27 Matt Woodward Inital version sent to Kenneth * Lavrsen 2004 Feb 27 * based on fetch2300 v 1.0. * Introduced also the serial port * interface for Windows * * 1.2 2004 Mar 07 Kenneth Lavrsen Completely re-written to match * (OZ1IDD) rw2300 v 1.2 */ #include "rw2300.h" /******************************************************************** * print_usage prints a short user guide * * Input: none * * Output: prints to stdout * * Returns: exits program * ********************************************************************/ void print_usage(void) { printf("\n"); printf("xml2300 - Read and write data to your WS-2300 weather station.\n"); printf("Version %s (C)2004 Kenneth Lavrsen.\n", VERSION); printf("This program is released under the GNU General Public License (GPL)\n\n"); printf("Usage:\n"); printf("With default config file: xml2300 xml-file\n"); printf("With given config file: xml2300 xml-file config-file\n"); exit(0); } /********** MAIN PROGRAM ************************************************ * * This program reads all current and min/max data from a WS2300 * weather station and write it to an XML file. * * It takes two parameters. xml_file_path and config_file_path * * If the config_file_path parameter is omitted the program will look * at the default paths. See the open2300.conf-dist file for info * ***********************************************************************/ int main(int argc, char *argv[]) { WEATHERSTATION ws2300; 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]; char tendency[15]; char forecast[15]; struct config_type config; double tempfloat_min, tempfloat_max; int tempint, tempint_min, tempint_max; struct timestamp time_min, time_max; time_t basictime; //char datestring[100]; //used to hold the date stamp for the log file FILE *fileptr; if (argc < 2 || argc > 3) { print_usage(); } get_configuration(&config, argv[2]); fileptr = fopen(argv[1], "w"); if (fileptr == NULL) { printf("Cannot open file %s\n",argv[1]); exit(EXIT_FAILURE); } ws2300 = open_weatherstation(config.serial_device_name); /* XML header */ fprintf(fileptr, "\n" "\n"); /* GET DATE AND TIME FOR LOG FILE, PLACE BEFORE ALL DATA IN LOG LINE */ /* , \n"); fflush(fileptr); fclose(fileptr); close_weatherstation(ws2300); return (0); }