Commit bf824f44 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Structure and makefile updated

parent d86ddbac
*.o
.settings/
.cproject
.project
PRIVATE/
CHANGELOG
File deleted
#include <iostream>
#include <string.h>
#include <driver_serial.hpp>
int main(){
std::string cmd;
char term[1];
term[0]=13;
char buf[500];
driver_serial serial = driver_serial("/dev/ttyUSB1",term,1,19200);
while (1){
std::cout << "CMD: ";
std::cin >> cmd;
//if (cmd.compare("QUIT")){
// break;
//}
//cmd=cmd+(char) 13;
serial.send((const char*) cmd.c_str());
serial.receive(buf,sizeof(buf),1);
std::cout << buf << std::endl;
}
}
// C Headers
#include <stdio.h>
// C++ Headers
#include <iostream> // Standard I/O
// Custom C++ Headers
#include <Filter_Obs.hpp>
#include <driver_obs_obsdaq.hpp>
#include <buffer_obs_pipe.hpp>
int main() {
// New data vector
data_obs_vector data = data_obs_vector();
data_obs_vector data0 = data_obs_vector();
// Initialize new buffer
buffer_obs_pipe pipe_in = buffer_obs_pipe();
buffer_obs_pipe pipe_out = buffer_obs_pipe();
// Initialize new filter
Filter_Obs filter = Filter_Obs();
std::vector <data_obs*> tofilter;
for (int i=0;i<5;i++){
tofilter.push_back(new data_obs_vector());
}
//filter.median_odd_running_vec(&pipe_in,&pipe_out, 5);
filter.lowpass_PLASMON_1Hz(&pipe_in,&pipe_out,640);
double filter1_win[]={0.00000000,0.00005934,0.00012869,0.00020467,0.00028254,0.00035629,0.00041885,0.00046247,0.00047925,0.00046172,0.00040364,0.00030074,0.00015153,-0.00004204,-0.00027398,-0.00053397,-0.00080733,-0.00107531,-0.00131591,-0.00150492,-0.00161756,-0.00163027,-0.00152288,-0.00128078,-0.00089712,-0.00037471,0.00027244,0.00101835,0.00182487,0.00264267,0.00341299,0.00407058,0.00454748,0.00477771,0.00470236,0.00427512,0.00346756,0.00227400,0.00071541,-0.00115799,-0.00326580,-0.00549837,-0.00771983,-0.00977320,-0.01148740,-0.01268595,-0.01319690,-0.01286345,-0.01155462,-0.00917531,-0.00567502,-0.00105456,0.00462973,0.01126474,0.01868264,0.02666616,0.03495694,0.04326671,0.05129062,0.05872201,0.06526776,0.07066341,0.07468700,0.07717085,0.07801061,0.07717085,0.07468700,0.07066341,0.06526776,0.05872201,0.05129062,0.04326671,0.03495694,0.02666616,0.01868264,0.01126474,0.00462973,-0.00105456,-0.00567502,-0.00917531,-0.01155462,-0.01286345,-0.01319690,-0.01268595,-0.01148740,-0.00977320,-0.00771983,-0.00549837,-0.00326580,-0.00115799,0.00071541,0.00227400,0.00346756,0.00427512,0.00470236,0.00477771,0.00454748,0.00407058,0.00341299,0.00264267,0.00182487,0.00101835,0.00027244,-0.00037471,-0.00089712,-0.00128078,-0.00152288,-0.00163027,-0.00161756,-0.00150492,-0.00131591,-0.00107531,-0.00080733,-0.00053397,-0.00027398,-0.00004204,0.00015153,0.00030074,0.00040364,0.00046172,0.00047925,0.00046247,0.00041885,0.00035629,0.00028254,0.00020467,0.00012869,0.00005934,0.00000000};
int filter1_length=129;
int filter1_sample=8;
//filter.fir_window_vec(&pipe_in,&pipe_in,filter1_win,filter1_length,
// filter1_sample);
/*
std::string str;
while (1){
pipe.pop(&data);
data.string(&str);
std::cout << "PROCESSED: " << str << std::endl;
}
*/
}
File deleted
//#include <buffer_obs_pipe.hpp>
//#include <driver_obs_gsm19.hpp>
#include <data_obs_scalar.hpp>
#include <data_obs_vector.hpp>
//#include <driver_serial_emulate.hpp>
#include <driver_serial.hpp>
#include <driver_obs_gsm19.hpp>
#include <driver_obs_gsm90.hpp>
#include <buffer_obs_pipe.hpp>
#include <buffer_obs_queue.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <ctime>
#include <thread>
int main() {
buffer_obs_queue queue = buffer_obs_queue();
data_obs_vector data_vec = data_obs_vector();
data_vec.set_time(1999,10,14,10,20,13,145);
data_vec.set_data(10,20,30,20.5,22.2);
queue.put(&data_vec);
data_obs_vector* data1_vec = new data_obs_vector();
queue.pop(data1_vec);
}
This diff is collapsed.
This diff is collapsed.
File added
File added
SRC=src/
BUILD=built/
SRC_DIR=./src/
OBJ_DIR=./lib/
HDR_DIR=./include/
USR_DIR=./usr/
BIN_DIR=./bin/
#--------------------------------------
#--------------------------------------
OBJs = $(shell ls -d $(SRC)*.cpp | sed 's/\.cpp/\.o/g')
OBJ = $(subst $(SRC),$(BUILD),$(OBJs))
SRC_FILES = $(wildcard $(SRC_DIR)*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)%.cpp,$(OBJ_DIR)%.o,$(SRC_FILES))
USR_FILES = $(wildcard $(USR_DIR)*.cpp)
USR_TARGET = $(patsubst $(USR_DIR)%.cpp,%,$(USR_FILES))
#--------------------------------------
CC=g++
CCFLAGS=-g -lrt -std=c++11 -pthread
EXCL=driver_serial.o
EXCL=driver_serial_emulate.o
all: GSM_Logger OBSDAQ_Logger Serial_Talk Stream_Reader TEST
.SECONDARY:
GSM_Logger: $(filter-out $(BUILD)$(EXCL) ,$(OBJ)) GSM_Logger.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
OBSDAQ_Logger: $(filter-out $(BUILD)$(EXCL) ,$(OBJ)) OBSDAQ_Logger.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
TEST: $(filter-out $(BUILD)$(EXCL) ,$(OBJ)) TEST.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
Stream_Reader: $(filter-out $(BUILD)$(EXCL) ,$(OBJ)) Stream_Reader.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
Serial_Talk: $(BUILD)driver_serial.o Serial_Talk.cpp
all: $(USR_TARGET:%=$(BIN_DIR)%)
%: $(BIN_DIR)%
@echo ---- DONE ----
$(BIN_DIR)%: $(filter-out $(OBJ_DIR)$(EXCL) ,$(OBJ_FILES)) $(USR_DIR)%.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
$(BUILD)%.o: $(SRC)%.cpp
$(CC) $(CCFLAGS) -c $< -o $(subst $(SRC),$(BUILD),$@) -I./include/
$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
$(CC) $(CCFLAGS) -c -o $@ $< -I$(HDR_DIR)
clean:
rm $(BUILD)*.o
rm $(BIN_DIR)*
rm $(OBJ_DIR)*
SRC=src/
BUILD=built/
#--------------------------------------
#--------------------------------------
OBJs = $(shell ls -d $(SRC)*.cpp | sed 's/\.cpp/\.o/g')
OBJ = $(subst $(SRC),$(BUILD),$(OBJs))
#--------------------------------------
CC=g++
CCFLAGS=-g -lrt
all: TEST GSM_Logger OBSDAQ_Logger Serial_Talk
GSM_Logger: $(filter-out $(BUILD)driver_serial.o ,$(OBJ)) GSM_Logger.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
OBSDAQ_Logger: $(filter-out $(BUILD)driver_serial.o ,$(OBJ)) OBSDAQ_Logger.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
TEST: $(filter-out $(BUILD)driver_serial.o ,$(OBJ)) TEST.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
Serial_Talk: $(BUILD)driver_serial.o Serial_Talk.cpp
$(CC) $(CCFLAGS) -o $(@) $^ -I./include/
$(BUILD)%.o: $(SRC)%.cpp
$(CC) $(CCFLAGS) -c $< -o $(subst $(SRC),$(BUILD),$@) -I./include/
clean:
rm $(BUILD)*.o
/*
* Driver_Obs_Serial.cpp
*
* Created on: May 12, 2016
* Author: mors
*/
#include "Driver_Obs_Serial.hpp"
#include <stdio.h>
/********************************************************************************
********************************************************************************
* *
* Constructors. *
* *
*********************************************************************************
********************************************************************************/
Driver_Obs_Serial::Driver_Obs_Serial(std::string port, buffer_obs* buffer) :
serial(port) {
this->buffer = buffer;
// TODO Add a reset function which sends commands at each baud rate test to
// restore intrument from dubious state (e.g. for GSM: 'o' if in baud
// rate selection menu, S if in test menu etc....
}
/********************************************************************************
*********************************************************************************
* *
* PUBLIC METHODS *
* *
*********************************************************************************
********************************************************************************/
/********************************************************************************
* *
* Receive raw from serial port without time information. *
* *
********************************************************************************/
int Driver_Obs_Serial::receive_raw(char *buf, int buflen, double timeout) {
return(serial.receive_raw(buf,buflen,timeout));
}
/********************************************************************************
* *
* Receive from serial port without time information. *
* *
********************************************************************************/
int Driver_Obs_Serial::receive(char *buf, int buflen, double timeout) {
return(serial.receive(buf,buflen,timeout));
}
/********************************************************************************
* *
* Receive from serial port with time information. *
* *
********************************************************************************/
int Driver_Obs_Serial::receive(char *buf, int buflen, double timeout,
struct timespec *recv_time) {
return(serial.receive(buf,buflen,timeout,recv_time));
}
/********************************************************************************
* *
* Send a command to the serial port. CMD is given as constant char. *
* *
********************************************************************************/
int Driver_Obs_Serial::send(const char* cmd) {
printf("Send: %s\n",cmd);
return(serial.send(cmd));
}
/********************************************************************************
* *
* Send a command to the serial port. *
* *
********************************************************************************/
int Driver_Obs_Serial::send(char *cmd) {
return(serial.send(cmd));
}
/********************************************************************************
* *
* Flush the buffer of the serial port. *
* *
********************************************************************************/
int Driver_Obs_Serial::flush() {
return(serial.flush());
}
/********************************************************************************
* *
* Set the termination characters. *
* *
********************************************************************************/
int Driver_Obs_Serial::set_term(const char* term, int termlen) {
return(serial.set_term(term,termlen));
}
/********************************************************************************
********************************************************************************
* *
* Private Methods. *
* *
********************************************************************************
*******************************************************************************/
/********************************************************************************
* *
* Initialize the GSM. *
* *
* Set baud rate as provided and set termination characters.
* *
********************************************************************************/
int Driver_Obs_Serial::set_baud(int baud) {
////////////////////////////////////////////////////////////////////////////////
//
// Set the baud rate
//
////////////////////////////////////////////////////////////////////////////////
if (serial.set_baud(baud) < 0) {
return (-1);
}
return (0);
}
/********************************************************************************
* *
* Initialize the Serial Instrument. *
* *
* Auto-determine baud rate.
* *
********************************************************************************/
int Driver_Obs_Serial::set_baud(const char* init_char) {
////////////////////////////////////////////////////////////////////////////////
//
// Try to auto-determine the baud rate
//
////////////////////////////////////////////////////////////////////////////////
int baud = 0;
char buf[100];
// The valid baudrates as derived in the serial driver
int* valid_baudrates;
int valid_baudrates_size;
serial.get_baudrates(&valid_baudrates, &valid_baudrates_size);
// Try different baudrates
for (int i = 0; i < valid_baudrates_size; i++) {
printf("---- Test baud rate: %7d ----\n", valid_baudrates[i]);
serial.set_baud(valid_baudrates[i]);
serial.send(init_char);
if (serial.receive(buf, sizeof(buf), 0.1) >= 0) {
baud = valid_baudrates[i];
break;
}
}
// Check if baud rate could be determined
if (baud == 0) {
printf(
"==== Baud rate could not be determined. Defaulting to 9600. ====\n");
return (-1);
} else {
printf("==== Baud rate set to %7d ====\n", baud);
return (0);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment