Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Filesystem/AP_Filesystem_Mission.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#pragma once1617#include "AP_Filesystem_config.h"1819#if AP_FILESYSTEM_MISSION_ENABLED2021#include "AP_Filesystem_backend.h"22#include <GCS_MAVLink/GCS_MAVLink.h>23#include <AP_Common/ExpandingString.h>2425class AP_Filesystem_Mission : public AP_Filesystem_Backend26{27public:28// functions that closely match the equivalent posix calls29int open(const char *fname, int flags, bool allow_absolute_paths = false) override;30int close(int fd) override;31int32_t read(int fd, void *buf, uint32_t count) override;32int32_t lseek(int fd, int32_t offset, int whence) override;33int32_t write(int fd, const void *buf, uint32_t count) override;34int stat(const char *pathname, struct stat *stbuf) override;3536private:37// only allow up to 4 files at a time38static constexpr uint8_t max_open_file = 4;3940static constexpr uint16_t mission_magic = 0x763d;4142enum class Options {43NO_CLEAR = (1U<<0), // don't clear the old mission44};4546// header at front of the file47struct header {48uint16_t magic = mission_magic;49uint16_t data_type; // MAV_MISSION_TYPE_*50uint16_t options; // optional features51uint16_t start; // first WP num, 0 for full upload52uint16_t num_items;53};5455struct rfile {56bool open;57ExpandingString *writebuf;58uint32_t file_ofs;59uint32_t num_items;60enum MAV_MISSION_TYPE mtype;61uint32_t last_op_ms;62} file[max_open_file];6364bool check_file_name(const char *fname, enum MAV_MISSION_TYPE &mtype);6566// get one item67bool get_item(uint32_t idx, enum MAV_MISSION_TYPE mtype, mavlink_mission_item_int_t &item) const;6869// get number of items70uint32_t get_num_items(enum MAV_MISSION_TYPE mtype) const;7172// finish loading items73bool finish_upload(const rfile &r);74bool finish_upload_mission(const struct header &hdr, const rfile &r, const uint8_t *b);75bool finish_upload_fence(const struct header &hdr, const rfile &r, const uint8_t *b);76bool finish_upload_rally(const struct header &hdr, const rfile &r, const uint8_t *b);7778// see if a block of memory is all zero79bool all_zero(const uint8_t *b, uint8_t size) const;80};8182#endif // AP_FILESYSTEM_MISSION_ENABLED838485