MoteHost: Introduce remote::error exception with easy usable constructor
[remote/remote-mci.git] / diku_mch / SerialControl.h
blob50cbcc6363dc363edf4ca939c82b1e18efea2e6a
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 result_t openTty();
32 result_t closeTty();
33 bool runChild(char * const args[], char * const envp[]);
34 result_t getChildResult();
35 result_t cancelProgramming();
36 result_t reset();
37 result_t start();
38 result_t stop();
39 ssize_t readBuf(char *buf, size_t len);
40 ssize_t writeBuf(const char *buf, size_t len);
41 int getFd();
42 status_t getStatus();
43 const std::string& getTty();
44 protected:
45 bool hasChild();
46 bool isOpen();
47 void cleanUpProgram();
48 bool clearDTR();
49 bool setDTR();
50 int port;
51 bool isRunning, portIsOpen;
52 pid_t childPid;
53 result_t childResult;
54 std::string tty;
55 struct termios oldsertio;
60 #endif