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
e5985f0f
Commit
e5985f0f
authored
9 years ago
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1497 from dogmaphobic/androidSerial
Android SerialPort work.
parents
eae5dc8f
54c8a349
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
137 additions
and
135 deletions
+137
-135
UsbSerialProber.java
...rc/com/hoho/android/usbserial/driver/UsbSerialProber.java
+2
-2
UsbDeviceJNI.java
android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java
+4
-10
qserialport.cpp
libs/qtandroidserialport/src/qserialport.cpp
+6
-6
qserialport.h
libs/qtandroidserialport/src/qserialport.h
+6
-6
qserialport_android.cpp
libs/qtandroidserialport/src/qserialport_android.cpp
+37
-45
qserialport_p.h
libs/qtandroidserialport/src/qserialport_p.h
+6
-6
qserialportinfo.cpp
libs/qtandroidserialport/src/qserialportinfo.cpp
+6
-6
qserialportinfo.h
libs/qtandroidserialport/src/qserialportinfo.h
+6
-6
qserialportinfo_android.cpp
libs/qtandroidserialport/src/qserialportinfo_android.cpp
+33
-37
qserialportinfo_p.h
libs/qtandroidserialport/src/qserialportinfo_p.h
+6
-6
qtandroidserialport.pri
libs/qtandroidserialport/src/qtandroidserialport.pri
+0
-2
SerialLink.cc
src/comm/SerialLink.cc
+25
-3
No files found.
android/src/com/hoho/android/usbserial/driver/UsbSerialProber.java
View file @
e5985f0f
...
@@ -162,10 +162,10 @@ public enum UsbSerialProber {
...
@@ -162,10 +162,10 @@ public enum UsbSerialProber {
*/
*/
public
static
List
<
UsbSerialDriver
>
findAllDevices
(
final
UsbManager
usbManager
)
{
public
static
List
<
UsbSerialDriver
>
findAllDevices
(
final
UsbManager
usbManager
)
{
final
List
<
UsbSerialDriver
>
result
=
new
ArrayList
<
UsbSerialDriver
>();
final
List
<
UsbSerialDriver
>
result
=
new
ArrayList
<
UsbSerialDriver
>();
Log
.
i
(
"QGC_UsbSerialProber"
,
"Looking for USB devices"
);
//
Log.i("QGC_UsbSerialProber", "Looking for USB devices");
// For each UsbDevice, call probe() for each prober.
// For each UsbDevice, call probe() for each prober.
for
(
final
UsbDevice
usbDevice
:
usbManager
.
getDeviceList
().
values
())
{
for
(
final
UsbDevice
usbDevice
:
usbManager
.
getDeviceList
().
values
())
{
Log
.
i
(
"QGC_UsbSerialProber"
,
"Probing device: "
+
usbDevice
.
getDeviceName
()
+
" mid: "
+
usbDevice
.
getVendorId
()
+
" pid: "
+
usbDevice
.
getDeviceId
());
//
Log.i("QGC_UsbSerialProber", "Probing device: " + usbDevice.getDeviceName() + " mid: " + usbDevice.getVendorId() + " pid: " + usbDevice.getDeviceId());
result
.
addAll
(
probeSingleDevice
(
usbManager
,
usbDevice
));
result
.
addAll
(
probeSingleDevice
(
usbManager
,
usbDevice
));
}
}
return
result
;
return
result
;
...
...
This diff is collapsed.
Click to expand it.
android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java
View file @
e5985f0f
...
@@ -199,7 +199,7 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -199,7 +199,7 @@ public class UsbDeviceJNI extends QtActivity
tempL
=
tempL
+
Integer
.
toString
(
deviceL
.
getVendorId
())
+
":"
;
tempL
=
tempL
+
Integer
.
toString
(
deviceL
.
getVendorId
())
+
":"
;
listL
[
countL
]
=
tempL
;
listL
[
countL
]
=
tempL
;
countL
++;
countL
++;
Log
.
i
(
TAG
,
"Found "
+
tempL
);
//
Log.i(TAG, "Found " + tempL);
}
}
}
}
...
@@ -260,6 +260,7 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -260,6 +260,7 @@ public class UsbDeviceJNI extends QtActivity
if
(
m_instance
.
m_UsbReceiver
==
null
)
if
(
m_instance
.
m_UsbReceiver
==
null
)
{
{
Log
.
i
(
TAG
,
"Creating new broadcast receiver"
);
m_instance
.
m_UsbReceiver
=
new
BroadcastReceiver
()
m_instance
.
m_UsbReceiver
=
new
BroadcastReceiver
()
{
{
public
void
onReceive
(
Context
contextA
,
Intent
intentA
)
public
void
onReceive
(
Context
contextA
,
Intent
intentA
)
...
@@ -273,7 +274,6 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -273,7 +274,6 @@ public class UsbDeviceJNI extends QtActivity
{
{
if
(
m_userData
.
containsKey
(
deviceL
.
getDeviceId
()))
if
(
m_userData
.
containsKey
(
deviceL
.
getDeviceId
()))
{
{
// UsbDeviceJNI.close(deviceL.getDeviceId());
nativeDeviceHasDisconnected
(
m_userData
.
get
(
deviceL
.
getDeviceId
()));
nativeDeviceHasDisconnected
(
m_userData
.
get
(
deviceL
.
getDeviceId
()));
}
}
}
}
...
@@ -294,6 +294,7 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -294,6 +294,7 @@ public class UsbDeviceJNI extends QtActivity
Log
.
e
(
TAG
,
"UsbIoManager instance is null"
);
Log
.
e
(
TAG
,
"UsbIoManager instance is null"
);
m_ioManager
.
put
(
idL
,
managerL
);
m_ioManager
.
put
(
idL
,
managerL
);
m_Executor
.
submit
(
managerL
);
m_Executor
.
submit
(
managerL
);
Log
.
i
(
TAG
,
"Port open successfull"
);
return
idL
;
return
idL
;
}
}
}
}
...
@@ -312,13 +313,11 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -312,13 +313,11 @@ public class UsbDeviceJNI extends QtActivity
m_ioManager
.
remove
(
idL
);
m_ioManager
.
remove
(
idL
);
}
}
Log
.
e
(
TAG
,
"Port open exception"
);
return
BAD_PORT
;
return
BAD_PORT
;
}
}
}
}
public
static
void
startIoManager
(
int
idA
)
public
static
void
startIoManager
(
int
idA
)
{
{
if
(
m_ioManager
.
get
(
idA
)
!=
null
)
if
(
m_ioManager
.
get
(
idA
)
!=
null
)
...
@@ -334,8 +333,6 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -334,8 +333,6 @@ public class UsbDeviceJNI extends QtActivity
m_Executor
.
submit
(
managerL
);
m_Executor
.
submit
(
managerL
);
}
}
public
static
void
stopIoManager
(
int
idA
)
public
static
void
stopIoManager
(
int
idA
)
{
{
if
(
m_ioManager
.
get
(
idA
)
==
null
)
if
(
m_ioManager
.
get
(
idA
)
==
null
)
...
@@ -345,9 +342,6 @@ public class UsbDeviceJNI extends QtActivity
...
@@ -345,9 +342,6 @@ public class UsbDeviceJNI extends QtActivity
m_ioManager
.
remove
(
idA
);
m_ioManager
.
remove
(
idA
);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
// Sets the parameters on an open port.
// Sets the parameters on an open port.
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialport.cpp
View file @
e5985f0f
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -13,9 +13,9 @@
...
@@ -13,9 +13,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -26,8 +26,8 @@
...
@@ -26,8 +26,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialport.h
View file @
e5985f0f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
**
**
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialport_android.cpp
View file @
e5985f0f
...
@@ -3,40 +3,32 @@
...
@@ -3,40 +3,32 @@
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
** $QT_BEGIN_LICENSE:LGPL$
** $QT_BEGIN_LICENSE:LGPL
21
$
** Commercial License Usage
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** General Public License version 2.1 or version 3 as published by the Free
** Foundation and appearing in the file LICENSE.LGPL included in the
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** packaging of this file. Please review the following information to
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** ensure the GNU Lesser General Public License version 2.1 requirements
** following information to ensure the GNU Lesser General Public License
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights.
These rights are described in the Digia Qt
LGPL Exception
** rights.
These rights are described in The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
**
**
****************************************************************************/
****************************************************************************/
...
@@ -119,29 +111,6 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
...
@@ -119,29 +111,6 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
rwMode
=
mode
;
rwMode
=
mode
;
__android_log_print
(
ANDROID_LOG_INFO
,
V_TAG
,
"Opening %s"
,
systemLocation
.
toLatin1
().
data
());
__android_log_print
(
ANDROID_LOG_INFO
,
V_TAG
,
"Opening %s"
,
systemLocation
.
toLatin1
().
data
());
QAndroidJniObject
jnameL
=
QAndroidJniObject
::
fromString
(
systemLocation
);
deviceId
=
QAndroidJniObject
::
callStaticMethod
<
jint
>
(
V_jniClassName
,
"open"
,
"(Ljava/lang/String;I)I"
,
jnameL
.
object
<
jstring
>
(),
(
jint
)
this
);
isReadStopped
=
false
;
if
(
deviceId
==
BAD_PORT
)
{
__android_log_print
(
ANDROID_LOG_ERROR
,
V_TAG
,
"Error opening %s"
,
systemLocation
.
toLatin1
().
data
());
q_ptr
->
setError
(
QSerialPort
::
DeviceNotFoundError
);
return
false
;
}
descriptor
=
QAndroidJniObject
::
callStaticMethod
<
jint
>
(
V_jniClassName
,
"getDeviceHandle"
,
"(I)I"
,
deviceId
);
if
(
!
hasRegisteredFunctions
)
if
(
!
hasRegisteredFunctions
)
{
{
// REGISTER THE C++ FUNCTION WITH JNI
// REGISTER THE C++ FUNCTION WITH JNI
...
@@ -155,7 +124,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
...
@@ -155,7 +124,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
QAndroidJniObject
javaClassL
(
V_jniClassName
);
QAndroidJniObject
javaClassL
(
V_jniClassName
);
jclass
objectClassL
=
envL
->
GetObjectClass
(
javaClassL
.
object
<
jobject
>
());
jclass
objectClassL
=
envL
->
GetObjectClass
(
javaClassL
.
object
<
jobject
>
());
jint
valL
=
envL
->
RegisterNatives
(
objectClassL
,
methodsL
,
sizeof
(
methodsL
)
/
sizeof
(
methodsL
[
0
]
));
jint
valL
=
envL
->
RegisterNatives
(
objectClassL
,
methodsL
,
sizeof
(
methodsL
)
/
sizeof
(
JNINativeMethod
));
envL
->
DeleteLocalRef
(
objectClassL
);
envL
->
DeleteLocalRef
(
objectClassL
);
hasRegisteredFunctions
=
true
;
hasRegisteredFunctions
=
true
;
...
@@ -169,6 +138,29 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
...
@@ -169,6 +138,29 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
}
}
}
}
QAndroidJniObject
jnameL
=
QAndroidJniObject
::
fromString
(
systemLocation
);
deviceId
=
QAndroidJniObject
::
callStaticMethod
<
jint
>
(
V_jniClassName
,
"open"
,
"(Ljava/lang/String;I)I"
,
jnameL
.
object
<
jstring
>
(),
(
jint
)
this
);
isReadStopped
=
false
;
if
(
deviceId
==
BAD_PORT
)
{
__android_log_print
(
ANDROID_LOG_ERROR
,
V_TAG
,
"Error opening %s"
,
systemLocation
.
toLatin1
().
data
());
q_ptr
->
setError
(
QSerialPort
::
DeviceNotFoundError
);
return
false
;
}
descriptor
=
QAndroidJniObject
::
callStaticMethod
<
jint
>
(
V_jniClassName
,
"getDeviceHandle"
,
"(I)I"
,
deviceId
);
if
(
rwMode
==
QIODevice
::
WriteOnly
)
if
(
rwMode
==
QIODevice
::
WriteOnly
)
stopReadThread
();
stopReadThread
();
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialport_p.h
View file @
e5985f0f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -12,9 +12,9 @@
...
@@ -12,9 +12,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialportinfo.cpp
View file @
e5985f0f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -12,9 +12,9 @@
...
@@ -12,9 +12,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialportinfo.h
View file @
e5985f0f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
**
**
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialportinfo_android.cpp
View file @
e5985f0f
...
@@ -3,40 +3,32 @@
...
@@ -3,40 +3,32 @@
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
** $QT_BEGIN_LICENSE:LGPL$
** $QT_BEGIN_LICENSE:LGPL
21
$
** Commercial License Usage
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** General Public License version 2.1 or version 3 as published by the Free
** Foundation and appearing in the file LICENSE.LGPL included in the
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** packaging of this file. Please review the following information to
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** ensure the GNU Lesser General Public License version 2.1 requirements
** following information to ensure the GNU Lesser General Public License
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights.
These rights are described in the Digia Qt
LGPL Exception
** rights.
These rights are described in The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
**
**
****************************************************************************/
****************************************************************************/
...
@@ -56,11 +48,11 @@ QT_BEGIN_NAMESPACE
...
@@ -56,11 +48,11 @@ QT_BEGIN_NAMESPACE
static
const
char
V_jniClassName
[]
{
"org/qgroundcontrol/qgchelper/UsbDeviceJNI"
};
static
const
char
V_jniClassName
[]
{
"org/qgroundcontrol/qgchelper/UsbDeviceJNI"
};
static
const
char
V_TAG
[]
{
"QGC_QSerialPortInfo"
};
static
const
char
V_TAG
[]
{
"QGC_QSerialPortInfo"
};
QList
<
QSerialPortInfo
>
availablePortsByFiltersOfDevices
()
QList
<
QSerialPortInfo
>
availablePortsByFiltersOfDevices
(
bool
&
ok
)
{
{
QList
<
QSerialPortInfo
>
serialPortInfoList
;
QList
<
QSerialPortInfo
>
serialPortInfoList
;
__android_log_print
(
ANDROID_LOG_INFO
,
V_TAG
,
"Collecting device list"
);
//
__android_log_print(ANDROID_LOG_INFO, V_TAG, "Collecting device list");
QAndroidJniObject
resultL
=
QAndroidJniObject
::
callStaticObjectMethod
(
QAndroidJniObject
resultL
=
QAndroidJniObject
::
callStaticObjectMethod
(
V_jniClassName
,
V_jniClassName
,
"availableDevicesInfo"
,
"availableDevicesInfo"
,
...
@@ -68,6 +60,7 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
...
@@ -68,6 +60,7 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
if
(
!
resultL
.
isValid
())
{
if
(
!
resultL
.
isValid
())
{
__android_log_print
(
ANDROID_LOG_ERROR
,
V_TAG
,
"Error from availableDevicesInfo"
);
__android_log_print
(
ANDROID_LOG_ERROR
,
V_TAG
,
"Error from availableDevicesInfo"
);
ok
=
false
;
return
serialPortInfoList
;
return
serialPortInfoList
;
}
}
...
@@ -75,24 +68,24 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
...
@@ -75,24 +68,24 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
jobjectArray
objArrayL
=
resultL
.
object
<
jobjectArray
>
();
jobjectArray
objArrayL
=
resultL
.
object
<
jobjectArray
>
();
int
countL
=
envL
->
GetArrayLength
(
objArrayL
);
int
countL
=
envL
->
GetArrayLength
(
objArrayL
);
for
(
int
iL
=
0
;
iL
<
countL
;
iL
++
)
for
(
int
iL
=
0
;
iL
<
countL
;
iL
++
)
{
{
QSerialPortInfo
infoL
;
QSerialPortInfo
Private
priv
;
jstring
stringL
=
(
jstring
)(
envL
->
GetObjectArrayElement
(
objArrayL
,
iL
));
jstring
stringL
=
(
jstring
)(
envL
->
GetObjectArrayElement
(
objArrayL
,
iL
));
const
char
*
rawStringL
=
envL
->
GetStringUTFChars
(
stringL
,
0
);
const
char
*
rawStringL
=
envL
->
GetStringUTFChars
(
stringL
,
0
);
__android_log_print
(
ANDROID_LOG_INFO
,
V_TAG
,
"Adding device: %s"
,
rawStringL
);
//
__android_log_print(ANDROID_LOG_INFO, V_TAG, "Adding device: %s", rawStringL);
QStringList
strListL
=
QString
::
fromUtf8
(
rawStringL
).
split
(
QStringLiteral
(
":"
));
QStringList
strListL
=
QString
::
fromUtf8
(
rawStringL
).
split
(
QStringLiteral
(
":"
));
envL
->
ReleaseStringUTFChars
(
stringL
,
rawStringL
);
envL
->
ReleaseStringUTFChars
(
stringL
,
rawStringL
);
infoL
.
d_ptr
->
portName
=
strListL
[
0
];
priv
.
portName
=
strListL
[
0
];
infoL
.
d_ptr
->
device
=
strListL
[
0
];
priv
.
device
=
strListL
[
0
];
infoL
.
d_ptr
->
manufacturer
=
strListL
[
1
];
priv
.
manufacturer
=
strListL
[
1
];
infoL
.
d_ptr
->
productIdentifier
=
strListL
[
2
].
toInt
();
priv
.
productIdentifier
=
strListL
[
2
].
toInt
();
infoL
.
d_ptr
->
hasProductIdentifier
=
(
infoL
.
d_ptr
->
productIdentifier
!=
0
)
?
true
:
false
;
priv
.
hasProductIdentifier
=
(
priv
.
productIdentifier
!=
0
)
?
true
:
false
;
infoL
.
d_ptr
->
vendorIdentifier
=
strListL
[
3
].
toInt
();
priv
.
vendorIdentifier
=
strListL
[
3
].
toInt
();
infoL
.
d_ptr
->
hasVendorIdentifier
=
(
infoL
.
d_ptr
->
vendorIdentifier
!=
0
)
?
true
:
false
;
priv
.
hasVendorIdentifier
=
(
priv
.
vendorIdentifier
!=
0
)
?
true
:
false
;
serialPortInfoList
.
append
(
infoL
);
serialPortInfoList
.
append
(
priv
);
}
}
return
serialPortInfoList
;
return
serialPortInfoList
;
...
@@ -100,17 +93,20 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
...
@@ -100,17 +93,20 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices()
QList
<
QSerialPortInfo
>
availablePortsBySysfs
()
QList
<
QSerialPortInfo
>
availablePortsBySysfs
()
{
{
return
availablePortsByFiltersOfDevices
();
bool
ok
;
return
availablePortsByFiltersOfDevices
(
ok
);
}
}
QList
<
QSerialPortInfo
>
availablePortsByUdev
()
QList
<
QSerialPortInfo
>
availablePortsByUdev
()
{
{
return
availablePortsByFiltersOfDevices
();
bool
ok
;
return
availablePortsByFiltersOfDevices
(
ok
);
}
}
QList
<
QSerialPortInfo
>
QSerialPortInfo
::
availablePorts
()
QList
<
QSerialPortInfo
>
QSerialPortInfo
::
availablePorts
()
{
{
return
availablePortsByFiltersOfDevices
();
bool
ok
;
return
availablePortsByFiltersOfDevices
(
ok
);
}
}
QList
<
qint32
>
QSerialPortInfo
::
standardBaudRates
()
QList
<
qint32
>
QSerialPortInfo
::
standardBaudRates
()
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialportinfo_p.h
View file @
e5985f0f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
** Contact: http://www.qt
-project.org/legal
** Contact: http://www.qt
.io/licensing/
**
**
** This file is part of the QtSerialPort module of the Qt Toolkit.
** This file is part of the QtSerialPort module of the Qt Toolkit.
**
**
...
@@ -12,9 +12,9 @@
...
@@ -12,9 +12,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and
Digia. For licensing terms and
** a written agreement between you and
The Qt Company. For licensing terms
**
conditions see http://qt.digia.com/licensing. For further information
**
and conditions see http://www.qt.io/terms-conditions. For further
**
use the contact form at http://qt.digia.com
/contact-us.
**
information use the contact form at http://www.qt.io
/contact-us.
**
**
** GNU Lesser General Public License Usage
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** Alternatively, this file may be used under the terms of the GNU Lesser
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
**
In addition, as a special exception, Digia
gives you certain additional
**
As a special exception, The Qt Company
gives you certain additional
** rights. These rights are described in
the Digia Qt
LGPL Exception
** rights. These rights are described in
The Qt Company
LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
**
** $QT_END_LICENSE$
** $QT_END_LICENSE$
...
...
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qtandroidserialport.pri
View file @
e5985f0f
...
@@ -21,8 +21,6 @@ android {
...
@@ -21,8 +21,6 @@ android {
CONFIG += mobility
CONFIG += mobility
INCLUDEPATH += $$PWD/qt4support/include
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
}
}
This diff is collapsed.
Click to expand it.
src/comm/SerialLink.cc
View file @
e5985f0f
...
@@ -93,6 +93,7 @@ bool SerialLink::_isBootloader()
...
@@ -93,6 +93,7 @@ bool SerialLink::_isBootloader()
**/
**/
void
SerialLink
::
run
()
void
SerialLink
::
run
()
{
{
#ifndef __android__
// Initialize the connection
// Initialize the connection
if
(
!
_hardwareConnect
(
_type
))
{
if
(
!
_hardwareConnect
(
_type
))
{
// Need to error out here.
// Need to error out here.
...
@@ -103,6 +104,7 @@ void SerialLink::run()
...
@@ -103,6 +104,7 @@ void SerialLink::run()
_emitLinkError
(
"Error connecting: "
+
err
);
_emitLinkError
(
"Error connecting: "
+
err
);
return
;
return
;
}
}
#endif
qint64
msecs
=
QDateTime
::
currentMSecsSinceEpoch
();
qint64
msecs
=
QDateTime
::
currentMSecsSinceEpoch
();
qint64
initialmsecs
=
QDateTime
::
currentMSecsSinceEpoch
();
qint64
initialmsecs
=
QDateTime
::
currentMSecsSinceEpoch
();
...
@@ -255,10 +257,13 @@ bool SerialLink::_disconnect(void)
...
@@ -255,10 +257,13 @@ bool SerialLink::_disconnect(void)
_stopp
=
true
;
_stopp
=
true
;
}
}
wait
();
// This will terminate the thread and close the serial port
wait
();
// This will terminate the thread and close the serial port
return
true
;
}
else
{
}
_transmitBuffer
.
clear
();
//clear the output buffer to avoid sending garbage at next connect
_transmitBuffer
.
clear
();
//clear the output buffer to avoid sending garbage at next connect
qCDebug
(
SerialLinkLog
)
<<
"Already disconnected"
;
qCDebug
(
SerialLinkLog
)
<<
"Already disconnected"
;
}
#ifdef __android__
LinkManager
::
instance
()
->
suspendConfigurationUpdates
(
false
);
#endif
return
true
;
return
true
;
}
}
...
@@ -276,6 +281,19 @@ bool SerialLink::_connect(void)
...
@@ -276,6 +281,19 @@ bool SerialLink::_connect(void)
QMutexLocker
locker
(
&
this
->
_stoppMutex
);
QMutexLocker
locker
(
&
this
->
_stoppMutex
);
_stopp
=
false
;
_stopp
=
false
;
}
}
#ifdef __android__
LinkManager
::
instance
()
->
suspendConfigurationUpdates
(
true
);
// Initialize the connection
if
(
!
_hardwareConnect
(
_type
))
{
// Need to error out here.
QString
err
(
"Could not create port."
);
if
(
_port
)
{
err
=
_port
->
errorString
();
}
_emitLinkError
(
"Error connecting: "
+
err
);
return
false
;
}
#endif
start
(
HighPriority
);
start
(
HighPriority
);
return
true
;
return
true
;
}
}
...
@@ -338,6 +356,9 @@ bool SerialLink::_hardwareConnect(QString &type)
...
@@ -338,6 +356,9 @@ bool SerialLink::_hardwareConnect(QString &type)
// After the bootloader times out, it still can take a second or so for the Pixhawk USB driver to come up and make
// After the bootloader times out, it still can take a second or so for the Pixhawk USB driver to come up and make
// the port available for open. So we retry a few times to wait for it.
// the port available for open. So we retry a few times to wait for it.
#ifdef __android__
_port
->
open
(
QIODevice
::
ReadWrite
);
#else
for
(
int
openRetries
=
0
;
openRetries
<
4
;
openRetries
++
)
{
for
(
int
openRetries
=
0
;
openRetries
<
4
;
openRetries
++
)
{
if
(
!
_port
->
open
(
QIODevice
::
ReadWrite
))
{
if
(
!
_port
->
open
(
QIODevice
::
ReadWrite
))
{
qCDebug
(
SerialLinkLog
)
<<
"Port open failed, retrying"
;
qCDebug
(
SerialLinkLog
)
<<
"Port open failed, retrying"
;
...
@@ -346,6 +367,7 @@ bool SerialLink::_hardwareConnect(QString &type)
...
@@ -346,6 +367,7 @@ bool SerialLink::_hardwareConnect(QString &type)
break
;
break
;
}
}
}
}
#endif
if
(
!
_port
->
isOpen
()
)
{
if
(
!
_port
->
isOpen
()
)
{
emit
communicationUpdate
(
getName
(),
"Error opening port: "
+
_port
->
errorString
());
emit
communicationUpdate
(
getName
(),
"Error opening port: "
+
_port
->
errorString
());
_port
->
close
();
_port
->
close
();
...
...
This diff is collapsed.
Click to expand it.
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