FrelonSerialLine.h 929 Bytes
Newer Older
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
#ifndef FRELONSERIALLINE_H
#define FRELONSERIALLINE_H

#include "Frelon.h"

namespace lima
{

namespace Frelon
{

class SerialLine : public HwSerialLine
{
 public:
	enum MsgPart {
		MsgSync, MsgCmd, MsgVal, MsgReq, MsgTerm, 
	};
	
	static const double TimeoutSingle, TimeoutNormal, TimeoutMax, 
			    TimeoutReset;
	
	SerialLine(Espia::SerialLine& espia_ser_line);
	
	virtual void write(const std::string& buffer, 
			   bool no_wait = false);
	virtual void read(std::string& buffer, int len, 
			  double timeout = TimeoutDefault);
	virtual void readStr(std::string& buffer, int len, 
			     double timeout = TimeoutDefault);
	
	virtual void getNumAvailBytes(int &avail);
	
	void splitMsg(const std::string& msg, 
		      std::map<MsgPart, std::string>& msg_parts) const;

 private:
	Espia::SerialLine& m_espia_ser_line;
	bool m_multi_line_cmd;
};


} // namespace Frelon



} // namespace lima


#endif // FRELONSERIALLINE_H