From 002797a3b43d19fc4e289608038867312165b09d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 19 Mar 2018 20:40:52 -0500 Subject: Fix array vs pointer error in declaration of circuitpython_help_text Building with gcc 5.4.1 (Debian Stretch) with the unsupported -Wno-error=lto-type-mismatch flag removed, the following diagnostic occurs: ../../py/builtin.h:121:19: error: type of 'circuitpython_help_text' does not match original declaration [-Werror] extern const char MICROPY_PY_BUILTINS_HELP_TEXT[]; ^ ../../shared-bindings/help.c:38:13: note: previously declared here const char *circuitpython_help_text = ^ lto1: all warnings being treated as errors lto-wrapper: fatal error: /usr/bin/arm-none-eabi-gcc returned 1 exit status --- shared-bindings/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-bindings') diff --git a/shared-bindings/help.c b/shared-bindings/help.c index cdd9a4a93..d8ffc13dd 100644 --- a/shared-bindings/help.c +++ b/shared-bindings/help.c @@ -35,7 +35,7 @@ //| prints general port information. //| -const char *circuitpython_help_text = +const char circuitpython_help_text[] = "Welcome to Adafruit CircuitPython " MICROPY_GIT_TAG "!\r\n" "\r\n" "Please visit learn.adafruit.com/category/circuitpython for project guides.\r\n" -- cgit v1.2.3 From c08f5a3a0071dd1940a09c6b5f0bdd8e4768c7f0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 27 Mar 2018 21:28:18 -0500 Subject: Add storage.getmount to retrieve the mount object associated with a path --- shared-bindings/storage/__init__.c | 10 ++++++++++ shared-bindings/storage/__init__.h | 1 + shared-module/storage/__init__.c | 4 ++++ 3 files changed, 15 insertions(+) (limited to 'shared-bindings') diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 6f6a30da6..837017ef9 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -122,12 +122,22 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a } MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount); +//| .. function:: getmount(mount_path) +//| +//| Retrieves the mount object associated with the mount path +//| +mp_obj_t storage_getmount(const mp_obj_t mnt_in) { + return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in)); +} +MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount); + STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) }, { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) }, { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) }, { MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) }, + { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) }, //| .. class:: VfsFat(block_device) //| diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h index 574b5ff8d..76b9ae854 100644 --- a/shared-bindings/storage/__init__.h +++ b/shared-bindings/storage/__init__.h @@ -34,5 +34,6 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly) void common_hal_storage_umount_path(const char* path); void common_hal_storage_umount_object(mp_obj_t vfs_obj); void common_hal_storage_remount(const char* path, bool readonly); +mp_obj_t common_hal_storage_getmount(const char* path); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index 3e7b90384..5b0bbe01e 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -121,3 +121,7 @@ STATIC mp_obj_t storage_object_from_path(const char* mount_path) { void common_hal_storage_umount_path(const char* mount_path) { common_hal_storage_umount_object(storage_object_from_path(mount_path)); } + +mp_obj_t common_hal_storage_getmount(const char *mount_path) { + return storage_object_from_path(mount_path); +} -- cgit v1.2.3 From 34f5498760452e30cb9b76e43f5ec65f36936376 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 27 Mar 2018 21:28:19 -0500 Subject: Document storage.VfsFat more thoroughly --- shared-bindings/storage/__init__.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'shared-bindings') diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 837017ef9..734cabcc1 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -145,6 +145,49 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| //| :param block_device: Block device the the filesystem lives on //| + //| .. attribute:: label + //| + //| The filesystem label, up to 11 case-insensitive bytes. Note that + //| this property can only be set when the device is writable by the + //| microcontroller. + //| + //| .. method:: mkfs + //| + //| Format the block device, deleting any data that may have been there + //| + //| .. method:: open(path, mode) + //| + //| Like builtin ``open()`` + //| + //| .. method:: ilistdir([path]) + //| + //| Return an iterator whose values describe files and folders within + //| ``path`` + //| + //| .. method:: mkdir(path) + //| + //| Like `os.mkdir` + //| + //| .. method:: rmdir(path) + //| + //| Like `os.rmdir` + //| + //| .. method:: stat(path) + //| + //| Like `os.stat` + //| + //| .. method:: statvfs(path) + //| + //| Like `os.statvfs` + //| + //| .. method:: mount(readonly, mkfs) + //| + //| Don't call this directly, call `storage.mount`. + //| + //| .. method:: umount + //| + //| Don't call this directly, call `storage.umount`. + //| { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) }, }; -- cgit v1.2.3 From 6ca4fd82eddcaaf75b0052d6a14a5938ffce8153 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 31 Mar 2018 20:41:16 +0200 Subject: Add a type check to the gamepad module Make sure that all the arguments passed are indeed DigitalInOut. This avoids crashes when the users pass something else. --- shared-bindings/gamepad/GamePad.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'shared-bindings') diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index a03b9318d..d80d1fcf6 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -27,6 +27,7 @@ #include "py/runtime.h" #include "py/mphal.h" #include "shared-module/gamepad/GamePad.h" +#include "shared-bindings/digitalio/DigitalInOut.h" #include "GamePad.h" @@ -96,6 +97,12 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, gamepad_singleton = m_new_obj(gamepad_obj_t); gamepad_singleton->base.type = &gamepad_type; } + for (size_t i = 0; i < n_args; ++i) { + if (!MP_OBJ_IS_TYPE(args[i], &digitalio_digitalinout_type)) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + "Expected a %q", digitalio_digitalinout_type.name)); + } + } gamepad_init(n_args, args); return MP_OBJ_FROM_PTR(gamepad_singleton); } -- cgit v1.2.3