Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
48f4d3ba
Commit
48f4d3ba
authored
Mar 30, 2011
by
James Goppert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished abstracting serial port.
parent
d7e07781
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
293 additions
and
115 deletions
+293
-115
CMakeLists.txt
CMakeLists.txt
+1
-0
qgroundcontrol.pro
qgroundcontrol.pro
+1
-0
SerialInterface.h
src/comm/SerialInterface.h
+171
-0
SerialLink.cc
src/comm/SerialLink.cc
+106
-106
SerialLink.h
src/comm/SerialLink.h
+14
-9
No files found.
CMakeLists.txt
View file @
48f4d3ba
...
...
@@ -394,6 +394,7 @@ set(qgroundcontrolMocSrc
#src/comm/OpalLink.h
src/comm/MAVLinkProtocol.h
src/comm/SerialLinkInterface.h
src/comm/SerialInterface.h
src/comm/UDPLink.h
src/comm/LinkManager.h
src/comm/LinkInterface.h
...
...
qgroundcontrol.pro
View file @
48f4d3ba
...
...
@@ -189,6 +189,7 @@ HEADERS += src/MG.h \
src
/
comm
/
LinkManager
.
h
\
src
/
comm
/
LinkInterface
.
h
\
src
/
comm
/
SerialLinkInterface
.
h
\
src
/
comm
/
SerialInterface
.
h
\
src
/
comm
/
SerialLink
.
h
\
src
/
comm
/
SerialSimulationLink
.
h
\
src
/
comm
/
ProtocolInterface
.
h
\
...
...
src/comm/SerialInterface.h
0 → 100644
View file @
48f4d3ba
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Brief Description
*
* @author James Goppertr <james.goppert@gmail.edu>
*
*/
#ifndef SERIALINTERFACE_H
#define SERIALINTERFACE_H
#include <QIODevice>
#include "qextserialport.h"
/**
* @brief The SerialInterface abstracts low level serial calls
*/
class
SerialInterface
:
public
QObject
{
Q_OBJECT
signals:
void
aboutToClose
();
public:
enum
baudRateType
{
BAUD50
,
//POSIX ONLY
BAUD75
,
//POSIX ONLY
BAUD110
,
BAUD134
,
//POSIX ONLY
BAUD150
,
//POSIX ONLY
BAUD200
,
//POSIX ONLY
BAUD300
,
BAUD600
,
BAUD1200
,
BAUD1800
,
//POSIX ONLY
BAUD2400
,
BAUD4800
,
BAUD9600
,
BAUD14400
,
//WINDOWS ONLY
BAUD19200
,
BAUD38400
,
BAUD56000
,
//WINDOWS ONLY
BAUD57600
,
BAUD76800
,
//POSIX ONLY
BAUD115200
,
BAUD128000
,
// WINDOWS ONLY
BAUD230400
,
// WINDOWS ONLY
BAUD256000
,
// WINDOWS ONLY
BAUD460800
,
// WINDOWS ONLY
BAUD921600
// WINDOWS ONLY
};
enum
dataBitsType
{
DATA_5
,
DATA_6
,
DATA_7
,
DATA_8
};
enum
parityType
{
PAR_NONE
,
PAR_ODD
,
PAR_EVEN
,
PAR_MARK
,
//WINDOWS ONLY
PAR_SPACE
};
enum
stopBitsType
{
STOP_1
,
STOP_1_5
,
//WINDOWS ONLY
STOP_2
};
enum
flowType
{
FLOW_OFF
,
FLOW_HARDWARE
,
FLOW_XONXOFF
};
/**
* structure to contain port settings
*/
struct
portSettings
{
baudRateType
BaudRate
;
dataBitsType
DataBits
;
parityType
Parity
;
stopBitsType
StopBits
;
flowType
FlowControl
;
long
timeout_Millisec
;
};
virtual
bool
isOpen
()
=
0
;
virtual
bool
isWriteable
()
=
0
;
virtual
bool
bytesAvailable
()
=
0
;
virtual
int
write
(
const
char
*
data
,
qint64
size
)
=
0
;
virtual
void
read
(
char
*
data
,
qint64
numBytes
)
=
0
;
virtual
void
flush
()
=
0
;
virtual
void
close
()
=
0
;
virtual
void
open
(
QIODevice
::
OpenModeFlag
flag
)
=
0
;
virtual
void
setBaudRate
(
baudRateType
baudrate
)
=
0
;
virtual
void
setParity
(
parityType
parity
)
=
0
;
virtual
void
setStopBits
(
stopBitsType
stopBits
)
=
0
;
virtual
void
setDataBits
(
dataBitsType
dataBits
)
=
0
;
virtual
void
setTimeout
(
qint64
timeout
)
=
0
;
};
class
SerialQextserial
:
public
SerialInterface
{
Q_OBJECT
private:
QextSerialPort
*
_port
;
signals:
void
aboutToClose
();
public:
SerialQextserial
(
QString
porthandle
,
QextSerialPort
::
QueryMode
mode
)
:
_port
(
NULL
)
{
_port
=
new
QextSerialPort
(
porthandle
,
QextSerialPort
::
Polling
);
//QObject::connect(_port,SIGNAL(aboutToClose()),this,SIGNAL(aboutToClose()));
}
virtual
bool
isOpen
()
{
return
_port
->
isOpen
();
}
virtual
bool
isWriteable
()
{
return
_port
->
isWritable
();
}
// yess, that is mis-spelled, writable
virtual
bool
bytesAvailable
()
{
return
_port
->
bytesAvailable
();
}
virtual
int
write
(
const
char
*
data
,
qint64
size
)
{
return
_port
->
write
(
data
,
size
);
}
virtual
void
read
(
char
*
data
,
qint64
numBytes
)
{
_port
->
read
(
data
,
numBytes
);
}
virtual
void
flush
()
{
_port
->
flush
();
}
virtual
void
close
()
{
_port
->
close
();
}
virtual
void
open
(
QIODevice
::
OpenModeFlag
flag
)
{
_port
->
open
(
flag
);
}
virtual
void
setBaudRate
(
SerialInterface
::
baudRateType
baudrate
)
{
_port
->
setBaudRate
((
BaudRateType
)
baudrate
);
}
virtual
void
setParity
(
SerialInterface
::
parityType
parity
)
{
_port
->
setParity
((
ParityType
)
parity
);
}
virtual
void
setStopBits
(
SerialInterface
::
stopBitsType
stopBits
)
{
_port
->
setStopBits
((
StopBitsType
)
stopBits
);
}
virtual
void
setDataBits
(
SerialInterface
::
dataBitsType
dataBits
)
{
_port
->
setDataBits
((
DataBitsType
)
dataBits
);
}
virtual
void
setTimeout
(
qint64
timeout
)
{
_port
->
setTimeout
(
timeout
);
};
};
class
SerialQserial
{
};
#endif // SERIALINTERFACE_H
src/comm/SerialLink.cc
View file @
48f4d3ba
This diff is collapsed.
Click to expand it.
src/comm/SerialLink.h
View file @
48f4d3ba
...
...
@@ -36,7 +36,7 @@ This file is part of the QGROUNDCONTROL project
#include <QThread>
#include <QMutex>
#include <QString>
#include
<qextserialport.h>
#include
"SerialInterface.h"
#include <configuration.h>
#include "SerialLinkInterface.h"
#ifdef _WIN32
...
...
@@ -57,7 +57,12 @@ class SerialLink : public SerialLinkInterface {
//Q_INTERFACES(SerialLinkInterface:LinkInterface)
public:
SerialLink
(
QString
portname
=
""
,
BaudRateType
baudrate
=
BAUD57600
,
FlowType
flow
=
FLOW_OFF
,
ParityType
parity
=
PAR_NONE
,
DataBitsType
dataBits
=
DATA_8
,
StopBitsType
stopBits
=
STOP_1
);
SerialLink
(
QString
portname
=
""
,
SerialInterface
::
baudRateType
baudrate
=
SerialInterface
::
BAUD57600
,
SerialInterface
::
flowType
flow
=
SerialInterface
::
FLOW_OFF
,
SerialInterface
::
parityType
parity
=
SerialInterface
::
PAR_NONE
,
SerialInterface
::
dataBitsType
dataBits
=
SerialInterface
::
DATA_8
,
SerialInterface
::
stopBitsType
stopBits
=
SerialInterface
::
STOP_1
);
~
SerialLink
();
static
const
int
poll_interval
=
SERIAL_POLL_INTERVAL
;
///< Polling interval, defined in configuration.h
...
...
@@ -132,18 +137,18 @@ protected slots:
void
checkForBytes
();
protected:
QextSerialPort
*
port
;
SerialInterface
*
port
;
#ifdef _WIN32
HANDLE
winPort
;
DCB
winPortSettings
;
#endif
QString
porthandle
;
QString
name
;
B
audRateType
baudrate
;
F
lowType
flow
;
P
arityType
parity
;
D
ataBitsType
dataBits
;
S
topBitsType
stopBits
;
SerialInterface
::
b
audRateType
baudrate
;
SerialInterface
::
f
lowType
flow
;
SerialInterface
::
p
arityType
parity
;
SerialInterface
::
d
ataBitsType
dataBits
;
SerialInterface
::
s
topBitsType
stopBits
;
int
timeout
;
int
id
;
...
...
@@ -163,7 +168,7 @@ protected:
bool
hardwareConnect
();
signals:
// Signals are defined by LinkInterface
void
aboutToCloseFlag
();
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment