Overview
- Object ID : 4889 (2024-09-29 12:01:43)
- Author : ersmith
- Content : Code
- Microcontroller : Propeller 2
- Language : SPIN2
- Categories : Data Storage, Protocol
- Licence : MIT
Content
P2-HOST-FS
HOST FS - code for accessing the host filesystem via the 9P protocol
Host Filesystem Features
Key features of this filesystem for the P2 chip:
- Read and write files and directories directly on the host PC
- Transport agnostic; defaults to using the serial port, but can easily be modified to use ethernet or other connections
- Uses the 9P protocol, which is a widely used and simple protocol for network file systems
API
The API for the host file system is very straightforward, and heavily inspired by Stephen Moraco's and Chip Gracey's Parallax Flash File system
Adding the Host FS to your own project
This section describes how to quickly get the host filesystem working in your project.
Include the Host FS object in your top file
Place the downloaded hostfs.spin2
in your project and in your top-level object include the flash object:
OBJ { Objects Used by this Object }
host : "hostfs" ' the host filesystem
Provide a Serial (or other) Interface for the File System
Hostfs needs to talk to the host by some mechanism. The actual interface is very simple: it needs to be able to send a block of data and receive another block as response. The API for this is:
pub sendrecv(bufstart, bufend, maxlen) : reply_len
where bufstart
is a pointer to the start of the data to send (and is also where the received data will be placed), bufend
is a pointer to the end of the data to send, and maxlen
is the maximum size of the buffer. The function returns the actual number of bytes received in the reply from the host.
See the detailed documentation in the .zip file for more details.