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
7624ae36
Commit
7624ae36
authored
Apr 30, 2015
by
matthew coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working basic file upload - new file only
parent
0953865a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
19 deletions
+41
-19
QGCUASFileManager.cc
src/uas/QGCUASFileManager.cc
+36
-17
QGCUASFileManager.h
src/uas/QGCUASFileManager.h
+3
-1
QGCUASFileView.cc
src/ui/QGCUASFileView.cc
+2
-1
No files found.
src/uas/QGCUASFileManager.cc
View file @
7624ae36
...
...
@@ -206,9 +206,6 @@ void QGCUASFileManager::_createAckResponse(Request* createAck)
_currentOperation
=
kCOWrite
;
_activeSession
=
createAck
->
hdr
.
session
;
// File length comes back in data. Compare with
Q_ASSERT
(
createAck
->
hdr
.
size
==
sizeof
(
uint32_t
));
// Start the sequence of read commands
_writeOffset
=
0
;
// Start writing at beginning of file
...
...
@@ -220,6 +217,13 @@ void QGCUASFileManager::_createAckResponse(Request* createAck)
/// @brief Respond to the Ack associated with the write command.
void
QGCUASFileManager
::
_writeAckResponse
(
Request
*
writeAck
)
{
if
(
_writeOffset
+
_writeSize
>=
_writeFileSize
){
_writeFileAccumulator
.
clear
();
_writeFileSize
=
0
;
_currentOperation
=
kCOIdle
;
emit
uploadFileComplete
();
}
if
(
writeAck
->
hdr
.
session
!=
_activeSession
)
{
_currentOperation
=
kCOIdle
;
_writeFileAccumulator
.
clear
();
...
...
@@ -234,17 +238,18 @@ void QGCUASFileManager::_writeAckResponse(Request* writeAck)
return
;
}
if
(
writeAck
->
hdr
.
size
!=
_writeSize
)
{
if
(
writeAck
->
hdr
.
size
!=
sizeof
(
uint32_t
)
)
{
_currentOperation
=
kCOIdle
;
_writeFileAccumulator
.
clear
();
_emitErrorMessage
(
tr
(
"Write:
Offset returned (%1) differs from offset requested (%2)"
).
arg
(
writeAck
->
hdr
.
offset
).
arg
(
_writeOffset
));
_emitErrorMessage
(
tr
(
"Write:
Returned invalid size of write size data"
));
return
;
}
if
(
writeAck
->
hdr
.
size
!=
_writeFileSize
){
if
(
*
((
uint32_t
*
)
writeAck
->
data
)
!=
_writeSize
){
_currentOperation
=
kCOIdle
;
_writeFileAccumulator
.
clear
();
_emitErrorMessage
(
tr
(
"Write: Size returned (%1) differs from size requested (%2)"
).
arg
(
writeAck
->
hdr
.
size
).
arg
(
_writeSize
));
_emitErrorMessage
(
tr
(
"Write: Size returned (%1) differs from size requested (%2)"
).
arg
(
*
((
uint32_t
*
)
writeAck
->
data
)
).
arg
(
_writeSize
));
return
;
}
...
...
@@ -260,28 +265,27 @@ void QGCUASFileManager::_writeFileDatablock(void)
// static const uint8_t kMaxDataLength = Request.data;
if
(
_writeOffset
+
_writeSize
>=
_writeFileSize
){
_currentOperation
=
kCOIdle
;
_writeFileAccumulator
.
clear
();
emit
uploadFileComplete
();
_sendTerminateCommand
();
return
;
}
_writeOffset
+=
_writeSize
;
Request
request
;
request
.
hdr
.
session
=
_activeSession
;
request
.
hdr
.
opcode
=
kCmdWriteFile
;
request
.
hdr
.
offset
=
_writeOffset
;
_writeOffset
+=
_writeSize
;
if
(
_write
Offset
+
sizeof
(
request
.
data
)
<
_writeFileSize
)
if
(
_write
FileSize
-
_writeOffset
>
sizeof
(
request
.
data
)
)
_writeSize
=
sizeof
(
request
.
data
);
else
_writeSize
=
_writeFileSize
-
_writeOffset
-
1
;
_writeSize
=
_writeFileSize
-
_writeOffset
;
request
.
hdr
.
size
=
_writeSize
;
// memcpy this? _writeFileAccumulator.mid(_writeOffset, _writeSize), _writeSize);
for
(
uint32_t
index
=
_writeOffset
;
index
<
_writeOffset
+
_writeSize
;
index
++
)
request
.
data
[
index
]
=
_writeFileAccumulator
.
at
(
index
);
for
(
uint32_t
index
=
0
;
index
<
_writeSize
;
index
++
)
request
.
data
[
index
]
=
_writeFileAccumulator
.
at
(
_writeOffset
+
index
);
_sendRequest
(
&
request
);
}
...
...
@@ -377,6 +381,11 @@ void QGCUASFileManager::receiveMessage(LinkInterface* link, mavlink_message_t me
// This is not an error, just the end of the read loop
_closeReadSession
(
true
/* success */
);
return
;
}
else
if
(
previousOperation
==
kCOCreate
)
{
// End a failed create file operation
_sendTerminateCommand
();
_emitErrorMessage
(
tr
(
"Nak received creating file, error: %1"
).
arg
(
errorString
(
request
->
data
[
0
])));
return
;
}
else
{
// Generic Nak handling
if
(
previousOperation
==
kCORead
)
{
...
...
@@ -466,6 +475,11 @@ void QGCUASFileManager::downloadPath(const QString& from, const QDir& downloadDi
/// @param uploadFile Local file to upload from
void
QGCUASFileManager
::
uploadPath
(
const
QString
&
toPath
,
const
QFileInfo
&
uploadFile
)
{
if
(
_currentOperation
!=
kCOIdle
){
_emitErrorMessage
(
tr
(
"UAS File manager busy. Try again later"
));
return
;
}
if
(
toPath
.
isEmpty
())
{
return
;
}
...
...
@@ -481,6 +495,7 @@ void QGCUASFileManager::uploadPath(const QString& toPath, const QFileInfo& uploa
}
_writeFileAccumulator
=
file
.
readAll
();
_writeFileSize
=
_writeFileAccumulator
.
size
();
file
.
close
();
...
...
@@ -496,7 +511,7 @@ void QGCUASFileManager::uploadPath(const QString& toPath, const QFileInfo& uploa
request
.
hdr
.
opcode
=
kCmdCreateFile
;
request
.
hdr
.
offset
=
0
;
request
.
hdr
.
size
=
0
;
_fillRequestWithString
(
&
request
,
toPath
);
_fillRequestWithString
(
&
request
,
toPath
+
"/"
+
uploadFile
.
fileName
()
);
_sendRequest
(
&
request
);
}
...
...
@@ -521,6 +536,10 @@ QString QGCUASFileManager::errorString(uint8_t errorCode)
return
QString
(
"invalid session"
);
case
kErrNoSessionsAvailable
:
return
QString
(
"no sessions availble"
);
case
kErrFailFileExists
:
return
QString
(
"File already exists on target"
);
case
kErrFailFileProtected
:
return
QString
(
"File is write protected"
);
default:
return
QString
(
"unknown error code"
);
}
...
...
src/uas/QGCUASFileManager.h
View file @
7624ae36
...
...
@@ -145,7 +145,9 @@ protected:
kErrInvalidSession
,
///< Session is not currently open
kErrNoSessionsAvailable
,
///< All available Sessions in use
kErrEOF
,
///< Offset past end of file for List and Read commands
kErrUnknownCommand
///< Unknown command opcode
kErrUnknownCommand
,
///< Unknown command opcode
kErrFailFileExists
,
///< File exists already
kErrFailFileProtected
///< File is write protected
};
enum
OperationState
...
...
src/ui/QGCUASFileView.cc
View file @
7624ae36
...
...
@@ -113,11 +113,12 @@ void QGCUASFileView::_uploadFile(void)
path
.
prepend
(
"/"
+
name
);
item
=
item
->
parent
();
}
while
(
item
);
qDebug
()
<<
"Upload: "
<<
path
;
QString
uploadFromHere
=
QGCFileDialog
::
getOpenFileName
(
this
,
tr
(
"Upload File"
),
QDir
::
homePath
());
qDebug
()
<<
"Upload: "
<<
uploadFromHere
<<
"to path"
<<
path
;
_manager
->
uploadPath
(
path
,
uploadFromHere
);
}
...
...
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