Faulhaber Serial Com Test  Version 1
A Qt interface to test Faulhaber MCBL 3006 motion controller
FaulhaberSerial.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * <Serial Com Test - Control of Faulhaber motor through serial port.>
3  * Copyright (C) 2015 B. Véron
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  ****************************************************************************/
18 
19 #ifndef FAULHABER_SERIAL_H
20 #define FAULHABER_SERIAL_H
21 
22 // CEP includes
23 #include <ErrorHandler.h>
24 
25 // Qt includes
26 #include <QtGlobal>
27 #include <QtSerialPort/QSerialPort>
28 #include <QSharedPointer>
29 #include <QString>
30 #include <QByteArray>
31 #include <QTime>
32 
33 // using namespace std;
34 
35 
37 
38 public:
41 
42  void initialize(const QString pCOMPortName);
43  void attachErrorHandler(QSharedPointer<ErrorHandler> pDIOCard);
44  bool open(QString pBaudRate = "19200", QString pParity = "n", QString pByteSize = "8", QString pStopBit = "1");
45  bool close();
46  bool receivePacket(int& pData);
47  bool send(int pUnit, QString pCommand, int pData, bool pUseData);
48 
49 protected:
50  QSerialPort *mSerialPort;
51 
52  QSharedPointer<ErrorHandler> mErrorHandler;
53 
55  bool mIsOpen;
56 
57  static const unsigned char CR;
58  static const int RXTIMEOUT;
59 };
60 
61 #endif // FAULHABER_SERIAL_H
62 
63 
64 //------------------------------------------------------------------------------------------------
65 // Doxygen comments:
66 
81 // * \author Nikolai Hungr & Baptiste Véron
82 // * \date 17/05/2016
83 // * \bug None for the moment...
84 // */
85 
QSharedPointer< ErrorHandler > mErrorHandler
Error handler.
Definition: FaulhaberSerial.h:52
static const unsigned char CR
Carriage return character used as special end character when communicating with Faulhaber motors...
Definition: FaulhaberSerial.h:57
bool mIsPortInitialized
Flag that defines if port has been initialized or not.
Definition: FaulhaberSerial.h:54
bool close()
Close communication with the COM port.
Definition: FaulhaberSerial.cpp:145
void initialize(const QString pCOMPortName)
Initialize the COM port member variables.
Definition: FaulhaberSerial.cpp:45
bool receivePacket(int &pData)
Read a full packet of data from the COM port.
Definition: FaulhaberSerial.cpp:154
bool send(int pUnit, QString pCommand, int pData, bool pUseData)
Send a packet to the COM port.
Definition: FaulhaberSerial.cpp:184
FaulhaberSerial()
Constructor.
Definition: FaulhaberSerial.cpp:30
void attachErrorHandler(QSharedPointer< ErrorHandler > pDIOCard)
Definition: FaulhaberSerial.cpp:53
bool open(QString pBaudRate="19200", QString pParity="n", QString pByteSize="8", QString pStopBit="1")
Open communication with the COM port.
Definition: FaulhaberSerial.cpp:58
static const int RXTIMEOUT
Communication timeout limit in milliseconds.
Definition: FaulhaberSerial.h:58
~FaulhaberSerial()
Definition: FaulhaberSerial.cpp:37
bool mIsOpen
Flag that defines if port has been opened or not.
Definition: FaulhaberSerial.h:55
Class for communicating with Faulhaber MCBL 3006 through serial COM ports.
Definition: FaulhaberSerial.h:36
QSerialPort * mSerialPort
In Qt5, QSerialPort handles the COM port.
Definition: FaulhaberSerial.h:50