Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

VrAR5000Source.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- 
00002  *
00003  *  Copyright 1997 Massachusetts Institute of Technology
00004  * 
00005  *  Permission to use, copy, modify, distribute, and sell this software and its
00006  *  documentation for any purpose is hereby granted without fee, provided that
00007  *  the above copyright notice appear in all copies and that both that
00008  *  copyright notice and this permission notice appear in supporting
00009  *  documentation, and that the name of M.I.T. not be used in advertising or
00010  *  publicity pertaining to distribution of the software without specific,
00011  *  written prior permission.  M.I.T. makes no representations about the
00012  *  suitability of this software for any purpose.  It is provided "as is"
00013  *  without express or implied warranty.
00014  * 
00015  */
00016 
00017 
00018 #ifndef _VRAR5000SOURCE_H_
00019 #define _VRAR5000SOURCE_H_
00020 
00021 extern "C" {
00022 #include <sys/ioctl.h>
00023 #include <fcntl.h>
00024 #include <errno.h>
00025 #include <string.h>
00026 }
00027 
00028 #include <VrSource.h>
00029 #include <VrGuppiSource.h>
00030 
00031 template<class oType> 
00032 class VrAR5000Source: public VrGuppiSource<oType> {
00033 protected:
00034   int serialfd;
00035   int rxFrequency;
00036 public:
00037   void on() {write(serialfd, "X\r\n",3); sleep(2);}
00038   void off() {write(serialfd, "QP\r\n",4);}
00039   void setRxFrequency(float f);
00040   VrAR5000Source(double sampling_freq);
00041   virtual ~VrAR5000Source();  
00042 };
00043 
00044 template<class oType> void
00045 VrAR5000Source<oType>::setRxFrequency(float f)
00046 {
00047   char cmd[20];
00048   int len;
00049 
00050   sprintf(cmd, "RF%f\r\n", f);
00051   len = strlen(cmd);
00052   if ((write(serialfd,cmd,len)) < 0) {
00053     fprintf(stderr, "write to serial port returned errno %d\n", errno);
00054   }
00055   return;
00056 }
00057 
00058 
00059 template<class oType> 
00060 VrAR5000Source<oType>::VrAR5000Source(double sampling_freq)
00061   :VrGuppiSource<oType>(sampling_freq)
00062 {
00063   if ((serialfd = open("/dev/ttyS1", O_RDWR)) < 0) {
00064     fprintf(stderr, "Error openeing serial port, errno %d\n", errno);
00065     exit(1);
00066   }
00067   on();
00068 }
00069 
00070 template<class oType>
00071 VrAR5000Source<oType>::~VrAR5000Source()
00072 {
00073   off();
00074   close(serialfd);
00075 }
00076 
00077 #endif

Generated on Tue Mar 15 23:46:36 2005 for GNU Radio by  doxygen 1.4.0