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
d7a538a5
Commit
d7a538a5
authored
May 08, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CP - Fix compiler warnings (Android)
parent
d778158a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
22 deletions
+14
-22
QGCCommon.pri
QGCCommon.pri
+1
-0
qserialport_android.cpp
libs/qtandroidserialport/src/qserialport_android.cpp
+13
-22
No files found.
QGCCommon.pri
View file @
d7a538a5
...
...
@@ -40,6 +40,7 @@ linux {
DEFINES += QGC_ENABLE_BLUETOOTH
DEFINES += QGC_GST_TAISYNC_ENABLED
DEFINES += QGC_GST_MICROHARD_ENABLED
QMAKE_CXXFLAGS += -Wno-address-of-packed-member
target.path = $$DESTDIR
equals(ANDROID_TARGET_ARCH, x86) {
CONFIG += Androidx86Build
...
...
libs/qtandroidserialport/src/qserialport_android.cpp
View file @
d7a538a5
...
...
@@ -55,14 +55,13 @@ QT_BEGIN_NAMESPACE
#define BAD_PORT 0
static
const
char
kJniClassName
[]
{
"org/mavlink/qgroundcontrol/QGCActivity"
};
static
const
char
kJTag
[]
{
"QGC_QSerialPort"
};
static
void
jniDeviceHasDisconnected
(
JNIEnv
*
envA
,
jobject
thizA
,
jint
userDataA
)
{
Q_UNUSED
(
envA
);
Q_UNUSED
(
thizA
);
if
(
userDataA
!=
0
)
(
(
QSerialPortPrivate
*
)
userDataA
)
->
q_ptr
->
close
();
(
reinterpret_cast
<
QSerialPortPrivate
*>
(
userDataA
)
)
->
q_ptr
->
close
();
}
static
void
jniDeviceNewData
(
JNIEnv
*
envA
,
jobject
thizA
,
jint
userDataA
,
jbyteArray
dataA
)
...
...
@@ -70,9 +69,9 @@ static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jint userDataA, jbyteA
Q_UNUSED
(
thizA
);
if
(
userDataA
!=
0
)
{
jbyte
*
bytesL
=
envA
->
GetByteArrayElements
(
dataA
,
NULL
);
jbyte
*
bytesL
=
envA
->
GetByteArrayElements
(
dataA
,
nullptr
);
jsize
lenL
=
envA
->
GetArrayLength
(
dataA
);
(
(
QSerialPortPrivate
*
)
userDataA
)
->
newDataArrived
((
char
*
)
bytesL
,
lenL
);
(
reinterpret_cast
<
QSerialPortPrivate
*>
(
userDataA
))
->
newDataArrived
(
reinterpret_cast
<
char
*>
(
bytesL
)
,
lenL
);
envA
->
ReleaseByteArrayElements
(
dataA
,
bytesL
,
JNI_ABORT
);
}
}
...
...
@@ -82,12 +81,12 @@ static void jniDeviceException(JNIEnv *envA, jobject thizA, jint userDataA, jstr
Q_UNUSED
(
thizA
);
if
(
userDataA
!=
0
)
{
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
NULL
);
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
nullptr
);
QString
strL
=
QString
::
fromUtf8
(
stringL
);
envA
->
ReleaseStringUTFChars
(
messageA
,
stringL
);
if
(
envA
->
ExceptionCheck
())
envA
->
ExceptionClear
();
(
(
QSerialPortPrivate
*
)
userDataA
)
->
exceptionArrived
(
strL
);
(
reinterpret_cast
<
QSerialPortPrivate
*>
(
userDataA
)
)
->
exceptionArrived
(
strL
);
}
}
...
...
@@ -95,7 +94,7 @@ static void jniLogDebug(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED
(
thizA
);
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
NULL
);
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
nullptr
);
QString
logMessage
=
QString
::
fromUtf8
(
stringL
);
envA
->
ReleaseStringUTFChars
(
messageA
,
stringL
);
if
(
envA
->
ExceptionCheck
())
...
...
@@ -107,7 +106,7 @@ static void jniLogWarning(JNIEnv *envA, jobject thizA, jstring messageA)
{
Q_UNUSED
(
thizA
);
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
NULL
);
const
char
*
stringL
=
envA
->
GetStringUTFChars
(
messageA
,
nullptr
);
QString
logMessage
=
QString
::
fromUtf8
(
stringL
);
envA
->
ReleaseStringUTFChars
(
messageA
,
stringL
);
if
(
envA
->
ExceptionCheck
())
...
...
@@ -190,7 +189,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
"(Landroid/content/Context;Ljava/lang/String;I)I"
,
QtAndroid
::
androidActivity
().
object
(),
jnameL
.
object
<
jstring
>
(),
(
jint
)
this
);
reinterpret_cast
<
jint
>
(
this
)
);
cleanJavaException
();
isReadStopped
=
false
;
...
...
@@ -395,7 +394,7 @@ void QSerialPortPrivate::startWriting()
bool
QSerialPortPrivate
::
waitForReadyRead
(
int
msecs
)
{
int
origL
=
readBuffer
.
size
(
);
int
origL
=
static_cast
<
int
>
(
readBuffer
.
size
()
);
if
(
origL
>
0
)
return
true
;
...
...
@@ -528,7 +527,7 @@ void QSerialPortPrivate::newDataArrived(char *bytesA, int lengthA)
// Always buffered, read data from the port into the read buffer
if
(
readBufferMaxSize
&&
(
bytesToReadL
>
(
readBufferMaxSize
-
readBuffer
.
size
())))
{
bytesToReadL
=
readBufferMaxSize
-
readBuffer
.
size
(
);
bytesToReadL
=
static_cast
<
int
>
(
readBufferMaxSize
-
readBuffer
.
size
()
);
if
(
bytesToReadL
<=
0
)
{
// Buffer is full. User must read data from the buffer
// before we can read more from the port.
...
...
@@ -538,7 +537,7 @@ void QSerialPortPrivate::newDataArrived(char *bytesA, int lengthA)
}
char
*
ptr
=
readBuffer
.
reserve
(
bytesToReadL
);
memcpy
(
ptr
,
bytesA
,
bytesToReadL
);
memcpy
(
ptr
,
bytesA
,
static_cast
<
size_t
>
(
bytesToReadL
)
);
emit
q
->
readyRead
();
}
...
...
@@ -617,8 +616,8 @@ qint64 QSerialPortPrivate::writeToPort(const char *data, qint64 maxSize)
}
QAndroidJniEnvironment
jniEnv
;
jbyteArray
jarrayL
=
jniEnv
->
NewByteArray
(
maxSize
);
jniEnv
->
SetByteArrayRegion
(
jarrayL
,
0
,
maxSize
,
(
jbyte
*
)
data
);
jbyteArray
jarrayL
=
jniEnv
->
NewByteArray
(
static_cast
<
jsize
>
(
maxSize
)
);
jniEnv
->
SetByteArrayRegion
(
jarrayL
,
0
,
static_cast
<
jsize
>
(
maxSize
),
(
jbyte
*
)
data
);
if
(
jniEnv
->
ExceptionCheck
())
jniEnv
->
ExceptionClear
();
int
resultL
=
QAndroidJniObject
::
callStaticMethod
<
jint
>
(
...
...
@@ -640,14 +639,6 @@ qint64 QSerialPortPrivate::writeToPort(const char *data, qint64 maxSize)
return
resultL
;
}
static
inline
bool
evenParity
(
quint8
c
)
{
c
^=
c
>>
4
;
//(c7 ^ c3)(c6 ^ c2)(c5 ^ c1)(c4 ^ c0)
c
^=
c
>>
2
;
//[(c7 ^ c3)(c5 ^ c1)][(c6 ^ c2)(c4 ^ c0)]
c
^=
c
>>
1
;
return
c
&
1
;
//(c7 ^ c3)(c5 ^ c1)(c6 ^ c2)(c4 ^ c0)
}
typedef
QMap
<
qint32
,
qint32
>
BaudRateMap
;
// The OS specific defines can be found in termios.h
...
...
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