/*PURPOSE*/
/*	This file will open the serial port at "/dev/ttyUSB0", which */
/*	corresponds to a mouser USB to serial converter.  	     */
/*	It initializes the serial converte 			     */

#include <errno.h>		/* Include Error Definitions*/	
#include <fcntl.h>		/* File control definitions */	
#include <sys/file.h>		/* Not sure */
#include <unistd.h>		/* File control definitions */
#include <stdio.h>		/* Standard Input Output */
#include <termio.h>		/* File control definitions */
#include <termios.h>
#include <sys/ioctl.h>
#include <string.h>
#include <sys/fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>

int main(int argc, char *argv[]){
  
  unsigned char rmessage[60];	/*The array to temporarily hold the data */
  struct termios options;	/*Structure containing the terminal settings*/
  
  FILE *datafile;		/*File for the data output*/
  int i=0;

  while (1){
 
		 FILE *datafile;
		 time_t rawtime;
		 struct tm *ptr;
  		 size_t strtime;
  		 int h,m,s;
		 char datestring[50];
 		 rawtime=time(NULL);
		 ptr=localtime(&rawtime);
  		 s=ptr->tm_sec;
		 h=ptr->tm_hour;
		 m=ptr->tm_min;

 		 strtime=strftime(datestring,20,"%b_%d_%G",ptr);
		 char day[strtime];
		 char basedir[]="/weather_data/";
		 strncpy(day,datestring,strtime);
		 strcat(basedir,datestring);
		 datafile=fopen(basedir,"a");
		 fclose(datafile);
		 sleep(0.001);
		 i=i+1;
		 printf("%d\n",i);
	    	}			
  
  return 0;

}

