Skip to content

Commit dc3310d

Browse files
committed
Add contents to read dir and read file.
1 parent f388de9 commit dc3310d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

c/include/libsbp/file_io.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typedef struct __attribute__((packed)) {
6464
u32 offset; /**< File offset [bytes] */
6565
u8 chunk_size; /**< Chunk size read [bytes] */
6666
char filename[20]; /**< Name of the file read from (NULL padded) */
67+
u8 contents[0]; /**< Contents of read file */
6768
} msg_fileio_read_response_t;
6869

6970

@@ -98,9 +99,10 @@ typedef struct __attribute__((packed)) {
9899
*/
99100
#define SBP_MSG_FILEIO_READ_DIR_RESPONSE 0x00AA
100101
typedef struct __attribute__((packed)) {
101-
u32 offset; /**< The offset to skip the first n elements of the file list
102+
u32 offset; /**< The offset to skip the first n elements of the file list
102103
*/
103104
char dirname[20]; /**< Name of the directory to list (NULL padded) */
105+
u8 contents[0]; /**< Contents of read directory */
104106
} msg_fileio_read_dir_response_t;
105107

106108

python/sbp/file_io.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,17 @@ class MsgFileioReadResponse(SBP):
142142
Chunk size read
143143
filename : string
144144
Name of the file read from (NULL padded)
145+
contents : array
146+
Contents of read file
145147
sender : int
146148
Optional sender ID, defaults to 0
147149
148150
"""
149151
_parser = Struct("MsgFileioReadResponse",
150152
ULInt32('offset'),
151153
ULInt8('chunk_size'),
152-
String('filename', 20),)
154+
String('filename', 20),
155+
OptionalGreedyRange(ULInt8('contents')),)
153156

154157
def __init__(self, sbp=None, **kwargs):
155158
if sbp:
@@ -162,6 +165,7 @@ def __init__(self, sbp=None, **kwargs):
162165
self.offset = kwargs.pop('offset')
163166
self.chunk_size = kwargs.pop('chunk_size')
164167
self.filename = kwargs.pop('filename')
168+
self.contents = kwargs.pop('contents')
165169

166170
def __repr__(self):
167171
return fmt_repr(self)
@@ -307,13 +311,16 @@ class MsgFileioReadDirResponse(SBP):
307311
308312
dirname : string
309313
Name of the directory to list (NULL padded)
314+
contents : array
315+
Contents of read directory
310316
sender : int
311317
Optional sender ID, defaults to 0
312318
313319
"""
314320
_parser = Struct("MsgFileioReadDirResponse",
315321
ULInt32('offset'),
316-
String('dirname', 20),)
322+
String('dirname', 20),
323+
OptionalGreedyRange(ULInt8('contents')),)
317324

318325
def __init__(self, sbp=None, **kwargs):
319326
if sbp:
@@ -325,6 +332,7 @@ def __init__(self, sbp=None, **kwargs):
325332
self.sender = kwargs.pop('sender', 0)
326333
self.offset = kwargs.pop('offset')
327334
self.dirname = kwargs.pop('dirname')
335+
self.contents = kwargs.pop('contents')
328336

329337
def __repr__(self):
330338
return fmt_repr(self)

spec/yaml/swiftnav/sbp/file_io.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ definitions:
7171
type: string
7272
size: 20
7373
desc: Name of the file read from (NULL padded)
74+
- contents:
75+
type: array
76+
fill: u8
77+
desc: Contents of read file
7478

7579
- MSG_FILEIO_READ_DIR_REQUEST:
7680
id: 0x00A9
@@ -114,6 +118,10 @@ definitions:
114118
type: string
115119
size: 20
116120
desc: Name of the directory to list (NULL padded)
121+
- contents:
122+
type: array
123+
fill: u8
124+
desc: Contents of read directory
117125

118126
- MSG_FILEIO_REMOVE:
119127
id: 0x00AC

0 commit comments

Comments
 (0)