Driver_Obs_Serial.hpp~ 2.14 KB
Newer Older
Achim Morschhauser's avatar
Achim Morschhauser committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Driver_Obs_Serial.h
 *
 *  Created on: May 12, 2016
 *      Author: mors
 */

#ifndef INCLUDE_DRIVER_OBS_SERIAL_HPP_
#define INCLUDE_DRIVER_OBS_SERIAL_HPP_

#include <driver_serial_emulate.hpp>
//#include <driver_serial.hpp>
#include <driver_obs.hpp>

class Driver_Obs_Serial: protected driver_obs {

//
// Private class variables
//

/** The serial driver to use */
private: driver_serial_emulate serial;
//private: driver_serial serial;

//
// Constructors
//

public:

/** Constructor with baud rate */
Driver_Obs_Serial(std::string port, buffer_obs* buffer);

/**
 * Constructors of derived classes must call set_term(term,termlen)
 * and set_baud(const char* init_char) or set_baud(int baud).
 */

//
// Public Methods
//

/** Take a single measurement. An object data_obs with the timestamp is returned.
    This method must be implemented as specified in the abstract class driver_obs */
public: virtual int get(data_obs* data)=0;

/** Take continuous measurement in triggered mode */
public: virtual int run(int freq)=0;
/** Take continuous measurement in freerun mode */
public: virtual int freerun(int freq)=0;
/** Stop continuous measurements */
public: virtual int stop()=0;

//
// Private Methods
//

protected:

/** Receive raw from serial port without time information. */
virtual int receive_raw(char *buf, int buflen, double timeout);
/** Receive from serial port without time information. */
virtual int receive(char *buf, int buflen, double timeout);
/** Receive from serial port with time information. */
virtual int receive(char *buf, int buflen, double timeout,
		struct timespec *recv_time);

/** Send a command to the serial port. */
virtual int send(const char* cmd);
/** Send a command to the serial port. */
virtual int send(char* cmd);

/** Flush the buffer of the serial port. */
virtual int flush();

/** Initialize the instrument with automatic determination of the baud rate */
virtual int set_baud(const char* init_char);
/** Initialize the instrument with given baud rate */
virtual int set_baud(int baud);

/** Set the termination characters. */
virtual int set_term(const char* term,int termlen);

};



#endif /* INCLUDE_DRIVER_OBS_SERIAL_HPP_ */