-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_io.h
157 lines (137 loc) · 6.07 KB
/
file_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright (C) 2015-2018 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/
/*****************************************************************************
* Automatically generated from yaml/swiftnav/sbp/file_io.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/
/** \defgroup file_io File_io
*
* * Messages for using device's onboard flash filesystem
* functionality. This allows data to be stored persistently in the
* device's program flash with wear-levelling using a simple filesystem
* interface. The file system interface (CFS) defines an abstract API
* for reading directories and for reading and writing files.
*
* Note that some of these messages share the same message type ID for both the
* host request and the device response.
* \{ */
#ifndef LIBSBP_FILE_IO_MESSAGES_H
#define LIBSBP_FILE_IO_MESSAGES_H
#include "common.h"
/** Read file from the file system (host => device)
*
* The file read message reads a certain length (up to 255 bytes)
* from a given offset into a file, and returns the data in a
* MSG_FILEIO_READ_RESP message where the message length field
* indicates how many bytes were succesfully read.The sequence
* number in the request will be returned in the response.
* If the message is invalid, a followup MSG_PRINT message will
* print "Invalid fileio read message". A device will only respond
* to this message when it is received from sender ID 0x42.
*/
#define SBP_MSG_FILEIO_READ_REQ 0x00A8
typedef struct {
u32 sequence; /**< Read sequence number */
u32 offset; /**< File offset [bytes] */
u8 chunk_size; /**< Chunk size to read [bytes] */
char filename[0]; /**< Name of the file to read from */
} msg_fileio_read_req_t;
/** File read from the file system (host <= device)
*
* The file read message reads a certain length (up to 255 bytes)
* from a given offset into a file, and returns the data in a
* message where the message length field indicates how many bytes
* were succesfully read. The sequence number in the response is
* preserved from the request.
*/
#define SBP_MSG_FILEIO_READ_RESP 0x00A3
typedef struct {
u32 sequence; /**< Read sequence number */
u8 contents[0]; /**< Contents of read file */
} msg_fileio_read_resp_t;
/** List files in a directory (host => device)
*
* The read directory message lists the files in a directory on the
* device's onboard flash file system. The offset parameter can be
* used to skip the first n elements of the file list. Returns a
* MSG_FILEIO_READ_DIR_RESP message containing the directory
* listings as a NULL delimited list. The listing is chunked over
* multiple SBP packets. The sequence number in the request will be
* returned in the response. If message is invalid, a followup
* MSG_PRINT message will print "Invalid fileio read message".
* A device will only respond to this message when it is received
* from sender ID 0x42.
*/
#define SBP_MSG_FILEIO_READ_DIR_REQ 0x00A9
typedef struct {
u32 sequence; /**< Read sequence number */
u32 offset; /**< The offset to skip the first n elements of the file list
*/
char dirname[0]; /**< Name of the directory to list */
} msg_fileio_read_dir_req_t;
/** Files listed in a directory (host <= device)
*
* The read directory message lists the files in a directory on the
* device's onboard flash file system. Message contains the directory
* listings as a NULL delimited list. The listing is chunked over
* multiple SBP packets and the end of the list is identified by an
* entry containing just the character 0xFF. The sequence number in
* the response is preserved from the request.
*/
#define SBP_MSG_FILEIO_READ_DIR_RESP 0x00AA
typedef struct {
u32 sequence; /**< Read sequence number */
u8 contents[0]; /**< Contents of read directory */
} msg_fileio_read_dir_resp_t;
/** Delete a file from the file system (host => device)
*
* The file remove message deletes a file from the file system.
* If the message is invalid, a followup MSG_PRINT message will
* print "Invalid fileio remove message". A device will only
* process this message when it is received from sender ID 0x42.
*/
#define SBP_MSG_FILEIO_REMOVE 0x00AC
typedef struct {
char filename[0]; /**< Name of the file to delete */
} msg_fileio_remove_t;
/** Write to file (host => device)
*
* The file write message writes a certain length (up to 255 bytes)
* of data to a file at a given offset. Returns a copy of the
* original MSG_FILEIO_WRITE_RESP message to check integrity of
* the write. The sequence number in the request will be returned
* in the response. If message is invalid, a followup MSG_PRINT
* message will print "Invalid fileio write message". A device will
* only process this message when it is received from sender ID
* 0x42.
*/
#define SBP_MSG_FILEIO_WRITE_REQ 0x00AD
typedef struct {
u32 sequence; /**< Write sequence number */
u32 offset; /**< Offset into the file at which to start writing in bytes [bytes] */
char filename[0]; /**< Name of the file to write to */
u8 data[0]; /**< Variable-length array of data to write */
} msg_fileio_write_req_t;
/** File written to (host <= device)
*
* The file write message writes a certain length (up to 255 bytes)
* of data to a file at a given offset. The message is a copy of the
* original MSG_FILEIO_WRITE_REQ message to check integrity of the
* write. The sequence number in the response is preserved from the
* request.
*/
#define SBP_MSG_FILEIO_WRITE_RESP 0x00AB
typedef struct {
u32 sequence; /**< Write sequence number */
} msg_fileio_write_resp_t;
/** \} */
#endif /* LIBSBP_FILE_IO_MESSAGES_H */