00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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