Das verwendete Oszi (Tektronix THS720A) wird hier nur als Digitalmultimeter verwendet.
Download


/*
* Programm um ein Tektronix Oszi auszulesen (wird als Multimeter verwendet)
* Ralph Uhl    ralph@r-uhl.de
*/
#include <stdio.h>
#include <string>
#include <fstream>       //includet auch iostream
#include <unistd.h>      //read, write, close
#include <fcntl.h>
#include <termios.h>
#include <stdlib.h>      //fuer atof
 

class Tektro {
  private:
   ofstream liout;
   ifstream liin;
   void set(char*);
  public:
   Tektro();
   Tektro(char*);
   ~Tektro();
   string init();
   float liesMesswert();
};

Tektro::Tektro(){
  liout.open("/dev/ttyS1",ios::app);
  liin.open("/dev/ttyS1",ios::in);
  if (!liin || !liout) {
   cout<<"RS-232 kann nicht geoeffnet werden!"<<endl;exit(1);
   }
  set("/dev/ttyS1");
 
}
 

Tektro::Tektro(char* device){
   liout.open(device,ios::app);
   liin.open(device,ios::in);
   if (!liin || !liout) {
   cout<<"RS-232 kann nicht geoeffnet werden!"<<endl;exit(1);
   }
   set(device);
}

Tektro::~Tektro(){
//Filedescriptor schliessen + lcd
liout.close();
liin.close();
}

void Tektro::set(char * device){
 
  struct termios settings;

  int fd = open(device, O_RDWR | O_NOCTTY);
  if (fd == -1){cout << "ha RS-232 kann nicht geoeffnet werden!"<<endl;exit(1);}

  //Setzen der Inputflags
  settings.c_iflag = IGNPAR | IGNPAR;
 
  //Setzen der Outputflags
  settings.c_oflag = 0;
 
  //Setzen der Controlflags
  settings.c_cflag = CS8;

  //Setzen der Localflags
  settings.c_lflag = 0;

  // Maximale Zeit, die beim Lesen gewartet wird (in 0.1s)
  settings.c_cc[VTIME] = 10;

  // Minimale Anzahl der zu lesenden Bytes
  settings.c_cc[VMIN] = 0;

  //Setzen der Uebertragungsgeschwindigkeit
  cfsetspeed(&settings, B9600);
 
  //Einstellungen an Schnittstelle uebergeben
  tcsetattr(fd, TCSANOW, &settings);
//return (fd);
  close(fd);
}float Tektro::liesMesswert(){
  liout << "DMM:VAL?\r" << endl;
  string s;
  float fre;
  liin >> s;
  liin >> fre;
  return(fre);
}

int main(int argc, char* argv[]){

int delay;
int numpts;
string s;
char* filename;
float fr;
Tektro* a;
ofstream file;
if (argc > 1) a = new Tektro(argv[1]);
else a = new Tektro();

cout << "Zeit zwischen zwei Messpunkten ?" << endl;
cin >> delay;
cout << "Anzahl Messpunkte ?" << endl;
cin >> numpts;

cout << "Dateiname ?" << endl;
cin >> filename;

file.open(filename,ios::noreplace | ios::out);
if (!file){
            cout << filename<< " gibts schon Du Dussel!"<<endl; }
else{
 for (int i=0;i<numpts;i++){
      // file << i*tBase << "\t"<<data[i]<<endl;
 
      fr = a -> liesMesswert();
      file << i*delay << "\t"<<fr<<endl;
 
      cout << i*delay<<"\t"<< fr << endl;
      sleep (delay);
      }
}
file.close();
cout << "file zu" <<endl;
delete a;
cout << "Schnittstelle wech " << endl;
return 0;
}
 
 
 
 



last update 2.1.2001