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
85e138a9
Commit
85e138a9
authored
Jun 07, 2014
by
none
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote file listing
parent
e5ea25d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
12 deletions
+166
-12
QGCUASFileManager.cc
src/uas/QGCUASFileManager.cc
+110
-9
QGCUASFileManager.h
src/uas/QGCUASFileManager.h
+56
-3
No files found.
src/uas/QGCUASFileManager.cc
View file @
85e138a9
...
...
@@ -4,6 +4,7 @@
#include <QFile>
#include <QDir>
#include <string>
static
const
quint32
crctab
[]
=
{
...
...
@@ -75,20 +76,120 @@ void QGCUASFileManager::nothingMessage()
void
QGCUASFileManager
::
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
)
{
switch
(
message
.
msgid
)
{
case
MAVLINK_MSG_ID_ENCAPSULATED_DATA
:
emit
statusMessage
(
"GOT ENC DATA"
);
break
;
if
(
message
.
msgid
!=
MAVLINK_MSG_ID_ENCAPSULATED_DATA
)
{
// wtf, not for us
return
;
}
mavlink_encapsulated_data_t
data
;
mavlink_msg_encapsulated_data_decode
(
&
message
,
&
data
);
const
RequestHeader
*
hdr
=
(
const
RequestHeader
*
)
&
data
.
data
[
0
];
unsigned
seqnr
=
data
.
seqnr
;
switch
(
_current_operation
)
{
case
kCOIdle
:
// we should not be seeing anything here.. shut the other guy up
sendReset
();
break
;
case
kCOList
:
if
(
hdr
->
opcode
==
kCmdList
)
{
listDecode
(
&
hdr
->
data
[
0
],
hdr
->
size
);
}
break
;
}
}
void
QGCUASFileManager
::
listRecursively
(
const
QString
&
from
)
{
// This sends out one line to the text area
emit
statusMessage
(
"/"
);
emit
statusMessage
(
" fs/"
);
emit
statusMessage
(
" microsd/"
);
emit
statusMessage
(
" log001.bin"
);
if
(
_current_operation
!=
kCOIdle
)
{
// XXX beep and don't do anything
}
// XXX clear the text widget
emit
statusMessage
(
"requesting list..."
);
// initialise the lister
_list_path
=
from
;
_list_offset
=
0
;
_current_operation
=
kCOList
;
// and send the initial request
sendList
();
}
void
QGCUASFileManager
::
listDecode
(
const
uint8_t
*
data
,
unsigned
len
)
{
unsigned
offset
=
0
;
unsigned
files
=
0
;
// parse filenames out of the buffer
while
(
offset
<
len
)
{
// get the length of the name
unsigned
nlen
=
strnlen
((
const
char
*
)
data
+
offset
,
len
-
offset
);
if
(
nlen
==
0
)
{
break
;
}
// put it in the view
emit
statusMessage
(
QString
((
const
char
*
)
data
+
offset
));
// account for the name + NUL
offset
+=
nlen
+
1
;
// account for the file
files
++
;
}
// we have run out of files to list
if
(
files
==
0
)
{
_current_operation
=
kCOIdle
;
}
else
{
// update our state
_list_offset
+=
files
;
// and send another request
sendList
();
}
}
void
QGCUASFileManager
::
sendReset
()
{
mavlink_message_t
message
;
RequestHeader
hdr
;
hdr
.
magic
=
'f'
;
hdr
.
session
=
0
;
hdr
.
opcode
=
kCmdReset
;
hdr
.
crc32
=
0
;
hdr
.
offset
=
0
;
hdr
.
size
=
0
;
hdr
.
crc32
=
crc32
((
uint8_t
*
)
&
hdr
,
sizeof
(
hdr
)
+
hdr
.
size
,
0
);
mavlink_msg_encapsulated_data_pack
(
250
,
0
,
&
message
,
_encdata_seq
,
(
uint8_t
*
)
&
hdr
);
// XXX 250 is a magic length
_mav
->
sendMessage
(
message
);
}
void
QGCUASFileManager
::
sendList
()
{
mavlink_message_t
message
;
RequestHeader
hdr
;
hdr
.
magic
=
'f'
;
hdr
.
session
=
0
;
hdr
.
opcode
=
kCmdList
;
hdr
.
crc32
=
0
;
hdr
.
offset
=
_list_offset
;
strncpy
((
char
*
)
&
hdr
.
data
[
0
],
_list_path
.
toStdString
().
c_str
(),
200
);
// XXX should have a real limit here
hdr
.
size
=
strlen
((
const
char
*
)
&
hdr
.
data
[
0
]);
hdr
.
crc32
=
crc32
((
uint8_t
*
)
&
hdr
,
sizeof
(
hdr
)
+
hdr
.
size
,
0
);
mavlink_msg_encapsulated_data_pack
(
250
,
0
,
&
message
,
_encdata_seq
,
(
uint8_t
*
)
&
hdr
);
// XXX 250 is a magic length
_mav
->
sendMessage
(
message
);
}
void
QGCUASFileManager
::
downloadPath
(
const
QString
&
from
,
const
QString
&
to
)
...
...
src/uas/QGCUASFileManager.h
View file @
85e138a9
...
...
@@ -19,11 +19,9 @@ public slots:
void
nothingMessage
();
void
listRecursively
(
const
QString
&
from
);
void
downloadPath
(
const
QString
&
from
,
const
QString
&
to
);
// void timedOut();
protected:
UASInterface
*
_mav
;
quint16
_encdata_seq
;
struct
RequestHeader
{
uint8_t
magic
;
...
...
@@ -35,6 +33,61 @@ protected:
uint8_t
data
[];
};
enum
Opcode
{
kCmdNone
,
// ignored, always acked
kCmdTerminate
,
// releases sessionID, closes file
kCmdReset
,
// terminates all sessions
kCmdList
,
// list files in <path> from <offset>
kCmdOpen
,
// opens <path> for reading, returns <session>
kCmdRead
,
// reads <size> bytes from <offset> in <session>
kCmdCreate
,
// creates <path> for writing, returns <session>
kCmdWrite
,
// appends <size> bytes at <offset> in <session>
kCmdRemove
,
// remove file (only if created by server?)
kRspAck
,
kRspNak
};
enum
ErrorCode
{
kErrNone
,
kErrNoRequest
,
kErrNoSession
,
kErrSequence
,
kErrNotDir
,
kErrNotFile
,
kErrEOF
,
kErrNotAppend
,
kErrTooBig
,
kErrIO
,
kErrPerm
};
enum
OperationState
{
kCOIdle
,
// not doing anything
kCOList
,
// waiting for a List response
};
OperationState
_current_operation
;
unsigned
_retry_counter
;
UASInterface
*
_mav
;
quint16
_encdata_seq
;
unsigned
_session_id
;
// session ID for current session
unsigned
_list_offset
;
// offset for the current List operation
QString
_list_path
;
// path for the current List operation
void
sendTerminate
();
void
sendReset
();
void
sendList
();
void
listDecode
(
const
uint8_t
*
data
,
unsigned
len
);
static
quint32
crc32
(
const
uint8_t
*
src
,
unsigned
len
,
unsigned
state
);
};
...
...
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