Issue 25: Use common backend for setting and clearing the DTR bit
[remote/remote-mci.git] / diku_mch / SerialControl.h
blobda4078f6272528e6abc4c91edc063731832c9463
1 #ifndef _SERIALCONTROL_H_
2 #define _SERIALCONTROL_H_
4 #include <string>
5 #include <errno.h>
6 #include <termios.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <sys/signal.h>
12 #include <sys/types.h>
13 #include <sys/wait.h>
14 #include <sys/ioctl.h>
16 #include "libutil/Log.h"
17 #include "types.h"
18 #include "motecontrol/localconstants.h"
20 namespace remote { namespace diku_mch {
22 using namespace protocols;
23 using namespace protocols::motecontrol;
24 using namespace util;
26 class SerialControl
28 public:
29 SerialControl();
30 ~SerialControl();
31 bool runChild(char * const args[], char * const envp[]);
32 result_t getChildResult();
33 result_t cancelProgramming();
34 result_t reset();
35 result_t start();
36 result_t stop();
37 ssize_t readBuf(char *buf, size_t len);
38 ssize_t writeBuf(const char *buf, size_t len);
39 int getFd();
40 status_t getStatus();
41 const std::string& getTty();
42 protected:
43 bool hasChild();
44 bool isOpen();
45 result_t openTty();
46 result_t closeTty();
47 bool endChild(bool killChild);
48 bool controlDTR(bool enable);
49 int port;
50 bool isRunning, portIsOpen;
51 pid_t childPid;
52 std::string tty;
53 struct termios oldsertio;
58 #endif