#include <stdio.h>
#include <time.h>
#include <sys/times.h>
#include "messlib.h"
#include <sys/utsname.h>
#include <sys/resource.h>

void main(int argc, char *argv[])
{
  char dmm_string[14];
  int dmm_fd;
  char * wert;
  float wert_real;
  struct utsname info;

  if(argc!=3){
    fprintf(stdout,"usage: read_port  port baudrate \n");
    fprintf(stdout,"\n\n");
    fprintf(stdout,"	port           =/dev/ttySX\n");
    fprintf(stdout,"	baudrate       =Übertragungsgeschwindigkeit\n");    
    fprintf(stdout,"\n\n");
    fprintf(stdout,"EXAMPLE: read_port /dev/ttyS2 600\n");
    exit();
  }  
 

  if((dmm_fd=init_dmm(argv[1],atoi(argv[2])))<1){
    fprintf(stderr,"Fehler beim Initialisieren von %s !\n",argv[1]);
    exit();
  }
	

  uname(&info);
    if(read_dmm(dmm_fd,dmm_string)==1){
      dmm_string[9]='\0';     
      wert=&dmm_string[2];
      sscanf(wert,"%e",&wert_real);
      wert_real=1000*wert_real;
      fprintf(stdout,"%d\n",(int)wert_real);
      fprintf(stdout,"%d\n",(int)wert_real);
      fprintf(stdout,"hallo\n");
      fprintf(stdout,"%s\n",info.nodename);
    }
    else{
      fprintf(stderr,"Fehler beim Lesen von %s !\n",argv[1]);
    }
  close_dmm(dmm_fd);
}
  
