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
f28a9286
Commit
f28a9286
authored
Sep 12, 2016
by
Alessio Morale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LP Support] - Add support for complex USB device layouts
parent
eca72e33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
14 deletions
+58
-14
CdcAcmSerialDriver.java
...com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
+58
-14
No files found.
android/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
View file @
f28a9286
...
...
@@ -47,31 +47,75 @@ public class CdcAcmSerialDriver extends CommonUsbSerialDriver {
@Override
public
void
open
()
throws
IOException
{
Log
.
d
(
TAG
,
"claiming interfaces, count="
+
mDevice
.
getInterfaceCount
());
Log
.
d
(
TAG
,
"device "
+
mDevice
);
mControlInterface
=
null
;
mDataInterface
=
null
;
mWriteEndpoint
=
null
;
mReadEndpoint
=
null
;
// locate all needed interfaces
for
(
int
i
=
0
;
i
<
mDevice
.
getInterfaceCount
();
i
++){
UsbInterface
iface
=
mDevice
.
getInterface
(
i
);
switch
(
iface
.
getInterfaceClass
()){
case
UsbConstants
.
USB_CLASS_COMM
:
mControlInterface
=
iface
;
Log
.
d
(
TAG
,
"control iface="
+
iface
);
break
;
case
UsbConstants
.
USB_CLASS_CDC_DATA
:
mDataInterface
=
iface
;
Log
.
d
(
TAG
,
"data iface="
+
iface
);
break
;
default
:
Log
.
d
(
TAG
,
"skipping iface="
+
iface
);
break
;
}
}
Log
.
d
(
TAG
,
"Claiming control interface."
);
mControlInterface
=
mDevice
.
getInterface
(
0
);
Log
.
d
(
TAG
,
"Control iface="
+
mControlInterface
);
// class should be USB_CLASS_COMM
// failback to the old way
if
(
mControlInterface
==
null
)
{
mControlInterface
=
mDevice
.
getInterface
(
0
);
Log
.
d
(
TAG
,
"Failback: Control iface="
+
mControlInterface
);
}
if
(!
mConnection
.
claimInterface
(
mControlInterface
,
true
))
{
throw
new
IOException
(
"Could not claim control interface."
);
}
mControlEndpoint
=
mControlInterface
.
getEndpoint
(
0
);
Log
.
d
(
TAG
,
"Control endpoint direction: "
+
mControlEndpoint
.
getDirection
());
Log
.
d
(
TAG
,
"Control endpoint: "
+
mControlEndpoint
);
Log
.
d
(
TAG
,
"Claiming data interface."
);
mDataInterface
=
mDevice
.
getInterface
(
1
);
Log
.
d
(
TAG
,
"
data iface="
+
mDataInterface
);
// class should be USB_CLASS_CDC_DATA
if
(
mDataInterface
==
null
)
{
mDataInterface
=
mDevice
.
getInterface
(
1
);
Log
.
d
(
TAG
,
"Failback:
data iface="
+
mDataInterface
);
}
if
(!
mConnection
.
claimInterface
(
mDataInterface
,
true
))
{
throw
new
IOException
(
"Could not claim data interface."
);
}
mReadEndpoint
=
mDataInterface
.
getEndpoint
(
1
);
Log
.
d
(
TAG
,
"Read endpoint direction: "
+
mReadEndpoint
.
getDirection
());
mWriteEndpoint
=
mDataInterface
.
getEndpoint
(
0
);
Log
.
d
(
TAG
,
"Write endpoint direction: "
+
mWriteEndpoint
.
getDirection
());
for
(
int
i
=
0
;
i
<
mDataInterface
.
getEndpointCount
();
i
++)
{
UsbEndpoint
endpoint
=
mDataInterface
.
getEndpoint
(
i
);
switch
(
endpoint
.
getDirection
())
{
case
UsbConstants
.
USB_DIR_OUT
:
mWriteEndpoint
=
endpoint
;
Log
.
d
(
TAG
,
"Write endpoint: "
+
mWriteEndpoint
);
break
;
case
UsbConstants
.
USB_DIR_IN
:
mReadEndpoint
=
endpoint
;
Log
.
d
(
TAG
,
"Read endpoint: "
+
mReadEndpoint
);
break
;
}
}
if
(
mReadEndpoint
==
null
||
mWriteEndpoint
==
null
){
// failback to the old method
mReadEndpoint
=
mDataInterface
.
getEndpoint
(
0
);
Log
.
d
(
TAG
,
"Read endpoint direction: "
+
mReadEndpoint
.
getDirection
());
mWriteEndpoint
=
mDataInterface
.
getEndpoint
(
1
);
Log
.
d
(
TAG
,
"Write endpoint direction: "
+
mWriteEndpoint
.
getDirection
());
}
}
private
int
sendAcmControlMessage
(
int
request
,
int
value
,
byte
[]
buf
)
{
...
...
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