Commit 555c397f authored by Achim Morschhauser's avatar Achim Morschhauser

Initial commit

parents
*.o
*.d
Driver_Obs_Pseudo
.project
.cproject
.settings
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: Driver_Obs_Pseudo
# Tool invocations
Driver_Obs_Pseudo: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -pthread -o "Driver_Obs_Pseudo" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) Driver_Obs_Pseudo
-@echo ' '
.PHONY: all clean dependents
-include ../makefile.targets
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS :=
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
C_UPPER_SRCS :=
CXX_SRCS :=
C++_SRCS :=
OBJ_SRCS :=
CC_SRCS :=
ASM_SRCS :=
CPP_SRCS :=
C_SRCS :=
O_SRCS :=
S_UPPER_SRCS :=
CC_DEPS :=
C++_DEPS :=
EXECUTABLES :=
C_UPPER_DEPS :=
CXX_DEPS :=
OBJS :=
CPP_DEPS :=
C_DEPS :=
# Every subdirectory with source files must be described here
SUBDIRS := \
src \
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../src/ADAM_Pseudo.cpp \
../src/Driver_Obs_Pseudo.cpp \
../src/GSM90Pseudo.cpp \
../src/LEMI_Pseudo.cpp \
../src/SerialPseudo.cpp
OBJS += \
./src/ADAM_Pseudo.o \
./src/Driver_Obs_Pseudo.o \
./src/GSM90Pseudo.o \
./src/LEMI_Pseudo.o \
./src/SerialPseudo.o
CPP_DEPS += \
./src/ADAM_Pseudo.d \
./src/Driver_Obs_Pseudo.d \
./src/GSM90Pseudo.d \
./src/LEMI_Pseudo.d \
./src/SerialPseudo.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -I"/mnt/DATA/mors/.eclipse2/Driver_Obs_Pseudo/src" -O0 -g3 -Wall -c -fmessage-length=0 -pthread -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
/*
* ADAM_Pseudo.cpp
*
* Created on: Jun 16, 2020
* Author: mors
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <thread>
#include "ADAM_Pseudo.h"
ADAM_Pseudo::ADAM_Pseudo() {
// TODO Auto-generated constructor stub
}
ADAM_Pseudo::~ADAM_Pseudo() {
// TODO Auto-generated destructor stub
}
int ADAM_Pseudo::start() {
std::thread listener(&ADAM_Pseudo::listen, this);
while (1){
}
return(0);
}
int ADAM_Pseudo::stop() {
return(0);
}
int ADAM_Pseudo::listen(){
int len;
std::string buf,cmd;
buf.resize(100);
char term[2];
term[0]=10;
term[1]=13;
while (1){
if ((len=read(fid, &buf[0], buf.size())) > 0){
buf.resize(len);
std::cout << "READ: " << buf << '|' << std::endl;
// Request all data
if (buf.compare(0,3,"#01") == 0){
cmd="+0.7210+0.0526-0.2493+3.0251+3.0172+0.0000+0.0000+0.0000";
} else {
cmd="NIX";
}
std::cout << "WRITE: " << cmd << std::endl;
write(fid,cmd.c_str(),cmd.length());
}
}
return(0);
}
/*
* ADAM_Pseudo.h
*
* Created on: Jun 16, 2020
* Author: mors
*/
#ifndef ADAM_PSEUDO_H_
#define ADAM_PSEUDO_H_
#include <SerialPseudo.h>
class ADAM_Pseudo : public Serial_Pseudo {
public:
ADAM_Pseudo();
virtual ~ADAM_Pseudo();
public:
int start();
int stop();
int listen();
};
#endif /* ADAM_PSEUDO_H_ */
//============================================================================
// Name : Driver_Obs_Pseudo.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <ADAM_Pseudo.h>
#include <LEMI_Pseudo.h>
using namespace std;
int main() {
LEMI_Pseudo LEMI;
LEMI.start();
return 0;
}
/*
* GSM90Pseudo.cpp
*
* Created on: Jun 15, 2020
* Author: mors
*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "GSM90Pseudo.h"
GSM90_Pseudo::GSM90_Pseudo() {
// TODO Auto-generated constructor stub
}
GSM90_Pseudo::~GSM90_Pseudo() {
// TODO Auto-generated destructor stub
}
int GSM90_Pseudo::start() {
check_pseudo();
return(0);
}
int GSM90_Pseudo::stop() {
return(0);
}
int GSM90_Pseudo::check_pseudo(){
////////////////////////////////////////////////////////////////////////////
//
// Listen for data and react.
//
////////////////////////////////////////////////////////////////////////////
/*
std::string buf, cmd;
buf.resize(100);
char term[2];
int len;
bool autocycle=0;
bool freerun=0;
int timesel=0;
int fieldsel=0;
int samplsel=0;
std::string timefmt[3] = {"hhmmss", "hhmmss.s", "hh:mm:ss"};
std::string sampling[3] = {"0001.0s"};
term[0]=10;
term[1]=13;
while (1){
// Only read single character
if (len=read(fid, &buf[0], buf.size()) > 0){
buf.resize(len);
std::cout << "READ: " << buf << std::endl;
if (buf.compare("S") == 0){
cmd="Gem Systems GSM-90F1 1013973 v7.0 31 I 2017 M e90F1.v7\n \
a";
// Select time fmt
} else if (buf.compare("P") == 0){
cmd=timefmt[++timesel%3]+term;
// Select output fmt
} else if (buf.compare("Q") == 0){
switch (fieldsel){
case 0:
cmd="date " + timefmt[timesel%3] + " field" + term;
break;
}
// Increase sampling rate
} else if (buf.compare("U") == 0){
if (samplsel++ == 2) {
samplsel=0;
}
cmd = sampling[samplsel]+term;
// Decrease sampling rate
} else if (buf.compare("D") == 0){
if (samplsel-- == 0) {
samplsel=0;
}
cmd = sampling[samplsel]+term;
// Toggle GPS
} else if (buf.compare("G") == 0){
cmd="GPS yes"+std::string(term);
// Freerun mode
} else if (buf.compare("R") == 0){
freerun=1;
//run(sampling,fid);
} else {
cmd="NIX";
}
std::cout << "WRITE: " << cmd << std::endl;
write(fid,cmd.c_str(),cmd.length());
}
}
*/
return(0);
}
/*
* GSM90Pseudo.h
*
* Created on: Jun 15, 2020
* Author: mors
*/
#ifndef GSM90PSEUDO_H_
#define GSM90PSEUDO_H_
#include <SerialPseudo.h>
class GSM90_Pseudo {
public:
GSM90_Pseudo();
virtual ~GSM90_Pseudo();
/** Start the device **/
int start();
/** Stop the device **/
int stop();
private:
int check_pseudo();
};
#endif /* GSM90PSEUDO_H_ */
/*
* LEMI_Pseudo.cpp
*
* Created on: Jun 16, 2020
* Author: mors
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <thread>
#include "LEMI_Pseudo.h"
LEMI_Pseudo::LEMI_Pseudo() {
// TODO Auto-generated constructor stub
}
LEMI_Pseudo::~LEMI_Pseudo() {
// TODO Auto-generated destructor stub
}
int LEMI_Pseudo::start() {
int stoptime;
std::thread listener(&LEMI_Pseudo::listen, this);
while (1){
std::cin >> stoptime;
stopfortime = stoptime;
}
return(0);
}
int LEMI_Pseudo::stop() {
return(0);
}
int LEMI_Pseudo::listen(){
using namespace std;
int len;
string buf,cmd;
buf.resize(100);
char term[2];
term[0]=10; // \r
//term[0]=13; // \n
struct timespec recv_time;
struct tm t = {0};
while (1){
if (record==1) {
// Get system time
clock_gettime(CLOCK_REALTIME, &recv_time);
gmtime_r(&recv_time.tv_sec,&t);
ostringstream str;
str << setfill('0') << right
<< setw(4) << t.tm_year+1900 << ' '
<< setw(2) << t.tm_mon-1 << ' '
<< setw(2) << t.tm_mday << ' '
<< setw(2) << t.tm_hour << ' '
<< setw(2) << t.tm_min << ' '
<< setw(2) << t.tm_sec;
// str << ' ' << setw(6) << estimated_timing_error;
// TODO: Add corrupt value every now and when
cmd=str.str();
cmd+=" 21.83 717.68 -145.46 -88.48 11.8 1";
cmd+=term;
std::cout << "WRITE: " << cmd << std::endl;
write(fid,cmd.c_str(),cmd.length());
if (stopfortime == 0){
sleep(1);
} else {
sleep(stopfortime);
stopfortime=0;
}
} else if ((len=read(fid, &buf[0], buf.size())) > 0){
buf.resize(len);
std::cout << "READ: " << buf << '|' << std::endl;
// Request all data
if ( (buf.compare(0,2,"=9") == 0) ||
(buf.compare(0,4,"=8=9") == 0) ){
cmd="?9";
record=1;
} else {
cmd="NIX";
}
std::cout << "WRITE: " << cmd << std::endl;
cmd+=term;
write(fid,cmd.c_str(),cmd.length());
if (record){
sleep(5);
}
}
}
return(0);
}
/*
* LEMI_Pseudo.h
*
* Created on: Jun 16, 2020
* Author: mors
*/
#ifndef LEMI_PSEUDO_H_
#define LEMI_PSEUDO_H_
#include <SerialPseudo.h>
class LEMI_Pseudo : public Serial_Pseudo {
private:
int record=0;
int stopfortime=0;
public:
LEMI_Pseudo();
virtual ~LEMI_Pseudo();
public:
int start();
int stop();
int listen();
};
#endif /* LEMI_PSEUDO_H_ */
/*
* SerialPseudo.cpp
*
* Created on: Jun 15, 2020
* Author: mors
*/
// C header
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h> // for open and some related constants
#include <unistd.h>
#include "SerialPseudo.h"
Serial_Pseudo::Serial_Pseudo() {
openit();
}
Serial_Pseudo::~Serial_Pseudo() {
// TODO Auto-generated destructor stub
}
int Serial_Pseudo::openit(){
////////////////////////////////////////////////////////////////////////////
//
// Open the pseudoterminal.
//
////////////////////////////////////////////////////////////////////////////
fid = open("/dev/ptmx",O_RDWR);
grantpt(fid);
unlockpt(fid);
slavename = ptsname(fid);
printf("Virtual port opened: %s\n",slavename);
if (!isatty(fid)) {
fprintf(stderr,"The specified port does not correspond "
"to a serial device!\n");
return (-1);
}
return(1);
}
/*
* SerialPseudo.h
*
* Created on: Jun 15, 2020
* Author: mors
*/
#ifndef SERIALPSEUDO_H_
#define SERIALPSEUDO_H_
class Serial_Pseudo {
public:
// Pseudoterminal
int</