Initial commit
[remote/remote-mci.git] / diku_mch / SerialControl.h
blobb846720c8575850be1f7399820e068dabc08b5a5
1 #ifndef _SERIALCONTROL_H_
2 #define _SERIALCONTROL_H_
4 #include "types.h"
5 #include "motecontrol/localconstants.h"
6 #include "Configuration.h"
7 #include <string>
9 #include <termios.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <fcntl.h>
14 #include <sys/signal.h>
15 #include <sys/types.h>
16 #include <sys/wait.h>
17 #include <sys/ioctl.h>
19 namespace remote { namespace diku_mch {
21 using namespace protocols;
22 using namespace protocols::motecontrol;
24 class SerialControl
26 public:
27 SerialControl(unsigned int portnumber);
28 const std::string& getDeviceName();
29 result_t _open();
30 result_t _close();
31 pid_t program(uint64_t macAddress, uint16_t tosAddress,std::string program);
32 bool getProgrammingResult(result_t& result);
33 result_t cancelProgramming();
34 result_t reset();
35 result_t start();
36 result_t stop();
37 int readBuf(char* buf, int len);
38 int writeBuf(const char* buf, int len);
39 char readChar();
40 void writeChar(char c);
41 int getFd();
42 status_t getStatus();
43 protected:
44 void cleanUpProgram();
45 bool clearDTR();
46 bool setDTR();
47 int port,prg_pid;
48 bool isRunning, isOpen, isProgramming,wasProgramming;
49 result_t prg_result;
50 std::string DeviceName;
51 std::string flashFile;
52 struct termios newsertio, oldsertio;
57 #endif