HwSerialLine.h 1.69 KB
Newer Older
kirov's avatar
kirov committed
1
2
3
4
5
6
7
8
9
10
#ifndef HWSERIALLINE_H
#define HWSERIALLINE_H

#include <string>
#include "Exceptions.h"


namespace lima {


11
12
13
14
15
#define TMOUT_DEFAULT        -2
#define TMOUT_BLOCK_FOREVER  -1
#define TMOUT_NO_BLOCK        0


kirov's avatar
kirov committed
16
17
18
19
20
21
22
class HwSerialLine
{
  public :
	HwSerialLine( char line_term='\r', double timeout=1.0 );
	virtual ~HwSerialLine();

	virtual void getAvail( int &avail ) = 0;
23

kirov's avatar
kirov committed
24
	virtual void read( std::string& buffer, int& len, double timeout ) = 0;
25

kirov's avatar
kirov committed
26
	virtual void write( const std::string& buffer, int block_size = 0,
27
	                    double block_delay=0, bool no_wait=false ) = 0;
kirov's avatar
kirov committed
28
29

	virtual void readStr( std::string& buffer, int max_len, 
kirov's avatar
kirov committed
30
31
	                      const std::string& term, 
	                      double timeout=TMOUT_DEFAULT );
32

kirov's avatar
kirov committed
33
34
	virtual void readLine( std::string& buffer, int max_len, 
	                       double timeout=TMOUT_DEFAULT );
35
36
37
38

	virtual void writeRead( const std::string& writebuffer, int block_size,
	                        double block_delay, bool no_wait,
	                        std::string& readbuffer, /*int max_len, ???*/
kirov's avatar
kirov committed
39
	                        double timeout=TMOUT_DEFAULT );
40
41
42
43
44

	virtual void writeReadStr( const std::string& writebuffer, 
	                           int block_size, double block_delay, 
	                           bool no_wait, std::string& readbuffer, 
	                           int max_len, const std::string& term, 
kirov's avatar
kirov committed
45
	                           double timeout=TMOUT_DEFAULT );
kirov's avatar
kirov committed
46

47
	virtual void readAvailable( std::string& buffer, /*int max_len, ???*/
kirov's avatar
kirov committed
48
	                            double timeout=TMOUT_DEFAULT );
kirov's avatar
kirov committed
49
50
51
52
53

	virtual void flush();

  private :
	char   m_line_term;
54
	double m_timeout;  /* Will be used with TMOUT_DEFAULT */
kirov's avatar
kirov committed
55
56
57
58
59
60
};


}

#endif /* HWSERIALLINE_H */