direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
interfaceAvr.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef INTERFACEAVR_H
22 #define INTERFACEAVR_H
23 
24 #include <QtGlobal> // for Q_OS_* Makro!
25 
26 #include "direcsSerial.h"
27 
28 #include <QFile>
29 #include <QObject>
30 #include <QDebug>
31 
32 
39 class InterfaceAvr : public QObject
40 {
41  Q_OBJECT
42 
43  public:
44  InterfaceAvr();
45  ~InterfaceAvr();
46 
52  bool openComPort(QString comPort);
53 
57  void closeComPort();
58 
65  bool sendChar(unsigned char character, QString callingClassName = "none");
66 
73  bool receiveChar(unsigned char *character, QString callingClassName = "none");
74 
82  bool sendString(QString string, QString callingClassName = "none");
83 
91  bool receiveString(QString &string, QString callingClassName = "none");
92 
99  bool receiveInt(int *value, QString callingClassName = "none");
100 
108  bool convertStringToInt(QString string, int &value);
109 
110 
111  signals:
117  void robotState(bool state);
118 
123  void tooMuchErrors();
124 
130  void message(QString text, bool CR=true, bool sayIt=false, bool addTimestamp=true);
131 
132 
133  private:
134  QString className;
136 
137  static const bool ON = true;
138  static const bool OFF = false;
139 
140  static const int BAUDRATE = 38400;
141 
142  static const char starter = 42;
143  static const char terminator = 35;
144 };
145 
146 #endif