sbp.file_io module

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.

class sbp.file_io.MsgFileioReadDirReq(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_READ_DIR_REQ (0x00A9).

You can have MSG_FILEIO_READ_DIR_REQ inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Read sequence number
offset
: int
The offset to skip the first n elements of the file list
dirname
: string
Name of the directory to list
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
dirname
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
offset
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioReadDirResp(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_READ_DIR_RESP (0x00AA).

You can have MSG_FILEIO_READ_DIR_RESP inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Read sequence number
contents
: array
Contents of read directory
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
contents
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioReadReq(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_READ_REQ (0x00A8).

You can have MSG_FILEIO_READ_REQ inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Read sequence number
offset
: int
File offset
chunk_size
: int
Chunk size to read
filename
: string
Name of the file to read from
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
chunk_size
filename
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
offset
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioReadResp(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_READ_RESP (0x00A3).

You can have MSG_FILEIO_READ_RESP inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Read sequence number
contents
: array
Contents of read file
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
contents
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioRemove(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_REMOVE (0x00AC).

You can have MSG_FILEIO_REMOVE inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
filename
: string
Name of the file to delete
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
filename
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioWriteReq(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_WRITE_REQ (0x00AD).

You can have MSG_FILEIO_WRITE_REQ inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Write sequence number
offset
: int
Offset into the file at which to start writing in bytes
filename
: string
Name of the file to write to
data
: array
Variable-length array of data to write
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
data
filename
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
offset
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]
class sbp.file_io.MsgFileioWriteResp(sbp=None, **kwargs)[source]

Bases: sbp.msg.SBP

SBP class for message MSG_FILEIO_WRITE_RESP (0x00AB).

You can have MSG_FILEIO_WRITE_RESP inherit its fields directly from an inherited SBP object, or construct it inline using a dict of its fields.

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.

sbp
: SBP
SBP parent object to inherit from.
sequence
: int
Write sequence number
sender
: int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
from_binary(d)[source]

Given a binary payload d, update the appropriate payload fields of the message.

static from_json(s)[source]

Given a JSON-encoded string s, build a message object.

static from_json_dict(d)[source]
sequence
to_binary()[source]

Produce a framed/packed SBP message.

to_json_dict()[source]