diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-07-13 22:51:10 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2018-07-13 22:51:10 -0400 |
| commit | e2e01efa84d2ed46d004edf48076e4701accc176 (patch) | |
| tree | 8c877ce226b6404b117990db92c9cfc93950df60 /extmod | |
| parent | 0d27f4d9a66dcb47b545e715d1833094b0c7b484 (diff) | |
compiles and runs; hangs on import storage;storage.VfsFat.<tab>
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/vfs.h | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat.c | 6 | ||||
| -rw-r--r-- | extmod/vfs_fat.h | 25 | ||||
| -rw-r--r-- | extmod/vfs_fat_diskio.c | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat_file.c | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat_file.h | 50 |
6 files changed, 27 insertions, 60 deletions
diff --git a/extmod/vfs.h b/extmod/vfs.h index 5ab2067e5..38c77943c 100644 --- a/extmod/vfs.h +++ b/extmod/vfs.h @@ -68,6 +68,8 @@ typedef struct _mp_vfs_ilistdir_it_t { bool is_iter; } mp_vfs_ilistdir_it_t; +mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in); + mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out); mp_import_stat_t mp_vfs_import_stat(const char *path); mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 633c04389..bf58afb1e 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -48,7 +48,7 @@ #define mp_obj_fat_vfs_t fs_user_mount_t -STATIC mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) { +mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) { fs_user_mount_t *vfs = vfs_in; FILINFO fno; assert(vfs != NULL); @@ -411,11 +411,11 @@ STATIC mp_obj_t vfs_fat_getlabel(mp_obj_t self_in) { if (res != FR_OK) { mp_raise_OSError(fresult_to_errno_table[res]); } - return mp_obj_new_str(working_buf, strlen(working_buf), false); + return mp_obj_new_str(working_buf, strlen(working_buf)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getlabel_obj, vfs_fat_getlabel); -static mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) { +STATIC mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) { fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); const char *label_str = mp_obj_str_get_str(label_in); FRESULT res = f_setlabel(&self->fatfs, label_str); diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h index 273ddc84e..3f46c278f 100644 --- a/extmod/vfs_fat.h +++ b/extmod/vfs_fat.h @@ -35,8 +35,9 @@ #define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func #define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount #define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl +#define FSUSER_NO_FILESYSTEM (0x0008) // the block device has no filesystem on it // Device is writable over USB and read-only to MicroPython. -#define FSUSER_USB_WRITABLE (0x0008) +#define FSUSER_USB_WRITABLE (0x0010) typedef struct _fs_user_mount_t { mp_obj_base_t base; @@ -54,12 +55,28 @@ typedef struct _fs_user_mount_t { FATFS fatfs; } fs_user_mount_t; +typedef struct _pyb_file_obj_t { + mp_obj_base_t base; + FIL fp; +} pyb_file_obj_t; + + +// These should be general types (mpy TOOD says so). In micropython, these are defined in +// mpconfigport.h. +#define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio + +extern const mp_obj_type_t mp_type_fileio; +extern const mp_obj_type_t mp_type_textio; + extern const byte fresult_to_errno_table[20]; extern const mp_obj_type_t mp_fat_vfs_type; +extern const mp_obj_type_t mp_type_vfs_fat_fileio; +extern const mp_obj_type_t mp_type_vfs_fat_textio; + +mp_import_stat_t fat_vfs_import_stat(void *vfs, const char *path); -mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path); -mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode); -MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); +MP_DECLARE_CONST_FUN_OBJ_3(fat_vfs_open_obj); mp_obj_t fat_vfs_ilistdir2(struct _fs_user_mount_t *vfs, const char *path, bool is_str_type); diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c index a147d601a..95ef77895 100644 --- a/extmod/vfs_fat_diskio.c +++ b/extmod/vfs_fat_diskio.c @@ -57,7 +57,7 @@ STATIC fs_user_mount_t *disk_get_device(void *bdev) { STATIC DSTATUS disk_initialize ( - bdev_t pdrv /* Physical drive nmuber (0..) */ + bdev_t pdrv /* Physical drive number (0..) */ ) { fs_user_mount_t *vfs = disk_get_device(pdrv); diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 86ae65aef..e3eebc9c4 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -27,8 +27,6 @@ #include "py/mpconfig.h" #if MICROPY_VFS && MICROPY_VFS_FAT -#include "extmod/vfs_fat_file.h" - #include <stdio.h> #include "py/runtime.h" diff --git a/extmod/vfs_fat_file.h b/extmod/vfs_fat_file.h deleted file mode 100644 index 11e4b7aa8..000000000 --- a/extmod/vfs_fat_file.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_EXTMOD_VFS_FAT_FILE_H -#define MICROPY_INCLUDED_EXTMOD_VFS_FAT_FILE_H - -#include "py/mpconfig.h" - -#if MICROPY_VFS && MICROPY_VFS_FAT - -#include "lib/oofatfs/ff.h" -#include "py/obj.h" - -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio - -extern const mp_obj_type_t mp_type_fileio; -extern const mp_obj_type_t mp_type_textio; - -typedef struct _pyb_file_obj_t { - mp_obj_base_t base; - FIL fp; -} pyb_file_obj_t; - -#endif // MICROPY_VFS && MICROPY_VFS_FAT - -#endif // MICROPY_INCLUDED_EXTMOD_VFS_FAT_FILE_H |
