aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-10-23tests/import: Add .exp file for module_getattr.py to not require Py 3.7.Damien George
2018-10-23examples/unix/ffi_example: Clean up and update the ffi example.Paul Sokolovsky
1. Use uctypes.bytearray_at(). Implementation of the "ffi" module predates that of "uctypes", so initially some convenience functions to access memory were added to ffi. Later, they landed in uctypes (which follows CPython's ctype module). So, replace undocumented experimental functions from ffi to documented ones from uctypes. 2. Use more suitable type codes for arguments (e.g. "P" (const void*) instead of "p" (void*). 3. Some better var naming. 4. Clarify some messages printed by the example.
2018-10-23docs/conf.py: Use https for intersphinx link to docs.python.org.Paul Sokolovsky
To get rid of warning when building the docs saying there's a redirect from http: to https:.
2018-10-23docs/library/uctypes: Add examples and make general updates.Paul Sokolovsky
Examples are added to the beginning of the module docs, similarly to docs for many other modules. Improvements to grammar, style, and clarity. Some paragraphs are updated with better suggestions. A warning added of the effect incorrect usage of the module may have. Describe the fact that offset range used in one defined structure is limited.
2018-10-23tests/extmod/uctypes_sizeof_layout: Test for sizeof of different layout.Paul Sokolovsky
On almost all realistic platforms, native layout should be larger (or equal) than packed layout.
2018-10-23extmod/moductypes: Make sizeof() accept "layout" parameter.Paul Sokolovsky
sizeof() can work in two ways: a) calculate size of already instantiated structure ("sizeof variable") - in this case we already no layout; b) size of structure decsription ("sizeof type"). In the latter case, LAYOUT_NATIVE was assumed, but there should possibility to calculate size for other layouts too. So, with this patch, there're now 2 forms: uctypes.sizeof(struct) uctypes.sizeof(struct_desc, layout)
2018-10-23py/objmodule: Implement PEP 562's __getattr__ for modules.Paul m. p. P
Configurable via MICROPY_MODULE_GETATTR, disabled by default. Among other things __getattr__ for modules can help to build lazy loading / code unloading at runtime.
2018-10-22tests: Make bytes/str.count() tests skippable.Paul Sokolovsky
2018-10-22py/objstr: Make str.count() method configurable.Paul Sokolovsky
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled. Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling it saves 408 bytes on x86.
2018-10-19tools/pyboard.py: In TelnetToSerial.close replace try/except with if.Martin Dybdal
Some Python linters don't like unconditional except clauses because they catch SystemExit and KeyboardInterrupt, which usually is not the intended behaviour.
2018-10-19esp32/network_ppp: Add PPPoS functionality.Eric Poulsen
This commit adds network.PPP(stream) which allows to create a TCP/IP network interface over a stream object (eg a UART).
2018-10-19docs/pyb.Pin: Minor typo fix to specify Pin in pyb.Pin.cpu.Dave Hylands
2018-10-19esp32/modesp32: Add hall_sensor() function.Eric Poulsen
2018-10-19unix/Makefile: Allow to override/omit pthread lib name.Paul Sokolovsky
For example, on Android, pthread functions are part of libc, so LIBPTHREAD should be empty.
2018-10-18docs/uio: Document StringIO/BytesIO(alloc_size) constructors.Paul Sokolovsky
2018-10-18tests/basics/class_getattr: Remove invalid test for __getattribute__.Damien George
Part of this test was trying to test some functionality of __getattribute__ but this method name was misspelt so it wasn't doing anything useful. Fixing the typo in this name makes the test fail because MicroPython doesn't support user defined __getattribute__ methods. So this part of the test is removed. The remaining tests are modified slightly to make it clearer what they are testing.
2018-10-18py/objtype: Remove comment about catching exc from user __getattr__.Damien George
Any exception raised in a user __getattr__ should be propagated out. A test is added to verify these semantics.
2018-10-17extmod/modonewire: Fix reset timings to match 1-wire specs.Damien George
Fixes issue #4116.
2018-10-17stm32/boards/stm32h743.ld: Fix total flash size, should be 2048k.Damien George
Fixes issue #4240.
2018-10-17stm32/spi: Fix calculation of SPI clock source on H7 MCUs.iabdalkader
2018-10-17unix/modffi: Add support for "q"/"Q" specs (int64_t/uint64_t).Paul Sokolovsky
2018-10-17unix/modusocket: Finish socket.settimeout() implementation.Paul Sokolovsky
1. Return correct error code for non-blocking vs timed out socket (POSIX returns EAGAIN for both, we want ETIMEDOUT in case of timed out socket). To achieve this, blocking/non-blocking flag is added to the mp_obj_socket_t, to avoid issuing fcntl() syscall each time EAGAIN occurs. (mp_obj_socket_t used to be 8 bytes, having some room in a standard 16-byte alloc block.) 2. Handle socket.settimeout(0) properly - in Python, that means non-blocking mode, but SO_RCVTIMEO/SO_SNDTIMEO of 0 is infinite timeout. 3. Overall, make sure that socket.settimeout() call switches blocking state as expected.
2018-10-17unix/modusocket: Initial implementation of socket.settimeout().Danielle Madeley
2018-10-15stm32/usbd_cdc_interface: Refactor USB CDC tx code to not use SOF IRQ.Damien George
Prior to this commit the USB CDC used the USB start-of-frame (SOF) IRQ to regularly check if buffered data needed to be sent out to the USB host. This wasted resources (CPU, power) if no data needed to be sent. This commit changes how the USB CDC transmits buffered data: - When new data is first available to send the data is queued immediately on the USB IN endpoint, ready to be sent as soon as possible. - Subsequent additions to the buffer (via usbd_cdc_try_tx()) will wait. - When the low-level USB driver has finished sending out the data queued in the USB IN endpoint it calls usbd_cdc_tx_ready() which immediately queues any outstanding data, waiting for the next IN frame. The benefits on this new approach are: - SOF IRQ does not need to run continuously so device has a better chance to sleep for longer, and be more responsive to other IRQs. - Because SOF IRQ is off, current consumption is reduced by a small amount, roughly 200uA when USB is connected (measured on PYBv1.0). - CDC tx throughput (USB IN) on PYBv1.0 is about 2.3 faster (USB OUT is unchanged). - When USB is connected, Python code that is executing is slightly faster because SOF IRQ no longer interrupts continuously. - On F733 with USB HS, CDC tx throughput is about the same as prior to this commit. - On F733 with USB HS, Python code is about 5% faster because of no SOF. As part of this refactor, the serial port should no longer echo initial characters when the serial port is first opened (this only used to happen rarely on USB FS, but on USB HS is was more evident).
2018-10-15stm32/usbd_cdc_interface: Handle disconnect IRQ to set VCP disconnected.Damien George
pyb.USB_VCP().isconnected() will now return False if the USB is disconnected after having previously been connected. See issue #4210.
2018-10-15py/emitnative: Put None/False/True in global native const table.Damien George
So these constant objects can be loaded by dereferencing the REG_FUN_TABLE pointer instead of loading immediate values. This reduces the size of generated native code (when such constants are used), and means that pointers to these constants are no longer stored in the assembly code.
2018-10-15py/emitnative: Push internal None rather than const obj where possible.Damien George
This shifts the work of loading the constant None object on to load_reg_stack_imm(), making the handling of None more centralised.
2018-10-15py/emitnative: Simplify viper mode handling in emit_native_import_name.Damien George
2018-10-15py/emitnative: Consolidate use of stacked immediate values to one func.Damien George
This commit adds the helper function load_reg_stack_imm() which deals with constant immediate values and converting them to Python objects if needed.
2018-10-15docs/machine.Pin: Document "hard" argument of Pin.irq method.Peter Hinch
2018-10-13docs/machine.Pin: Add note regarding irq handler argument.Peter Hinch
2018-10-13lib/utils/pyexec: Forcefully unlock the heap if locked and REPL active.Damien George
Otherwise there is really nothing that can be done, it can't be unlocked by the user because there is no way to allocate memory to execute the unlock. See issue #4205 and #4209.
2018-10-13tests/uctypes_sizeof_od: Test for using OrderedDict as struct descriptorPaul Sokolovsky
Just a copy of uctypes_sizeof.py with minimal changes.
2018-10-13extmod/moductypes: Accept OrderedDict as a structure description.Paul Sokolovsky
Using OrderedDict (i.e. stable order of fields) would for example allow to automatically calculate field offsets in structures.
2018-10-13py/emitnative: Remove unused ptr argument from ASM_CALL_IND macro.Damien George
2018-10-13py/asmthumb: Remove unused fun_ptr arg from asm_thumb_bl_ind function.Damien George
2018-10-13py/asmarm: Simplify asm_arm_bl_ind to only load via index, not literal.Damien George
The maximum index into mp_fun_table is currently less than 1024 and should stay that way to keep things efficient for all architectures, so there is no need to handle loading the pointer directly via a literal in this function.
2018-10-13py/emitnative: Load native fun table ptr from const table for all archs.Damien George
All architectures now have a dedicated register to hold the pointer to the native function table mp_fun_table, and so they all need to load this register at the start of the native function. This commit makes the loading of this register uniform across architectures by passing the pointer in the constant table for the native function, and then loading the register from the constant table. Doing it this way means that the pointer is not stored in the assembly code, helping to make the code more portable.
2018-10-13py/asmx86: Change indirect calls to load fun ptr from the native table.Damien George
Instead of storing the function pointer directly in the assembly code. This makes the generated code more independent of the runtime (so easier to relocate the code), and reduces the generated code size.
2018-10-13py/asmx86: Change stack management to reference locals by esp not ebp.Damien George
The esp register is always a fixed distance below ebp, and using esp to reference locals on the stack frees up the ebp register for general purpose use (which is important for an architecture with only 8 user registers).
2018-10-13py/asmx64: Change indirect calls to load fun ptr from the native table.Damien George
Instead of storing the function pointer directly in the assembly code. This makes the generated code more independent of the runtime (so easier to relocate the code), and reduces the generated code size.
2018-10-13py/asmx64: Change stack management to reference locals by rsp not rbp.Damien George
The rsp register is always a fixed distance below rbp, and using rsp to reference locals on the stack frees up the rbp register for general purpose use.
2018-10-11nrf/bluetooth: Set GAP_ADV_MAX_SIZE to 31 (s132/s140).Glenn Ruben Bakke
For s132 and s140, GAP_ADV_MAX_SIZE was currently set to BLE_GATT_ATT_MTU_DEFAULT, which is 23. The correct value should have been 31, but there are no define for this in the s132/s140 header files as for s110. Updating define in ble_drv.c to the correct value of 31.
2018-10-05stm32/main: Add configuration macros for board to set heap start/end.Andrew Leech
The macros are MICROPY_HEAP_START and MICROPY_HEAP_END, and if not defined by a board then the default values will be used (maximum heap from SRAM as defined by linker symbols). As part of this commit the SDRAM initialisation is moved to much earlier in main() to potentially make it available to other peripherals and avoid re-initialisation on soft-reboot. On boards with SDRAM enabled the heap has been set to use that.
2018-10-05windows/msvc: Implement file/directory type query.stijn
Add some more POSIX compatibility by adding a d_type field to the dirent structure and defining corresponding macros so listdir_next in the unix' port modos.c can use it, end result being uos.ilistdir now reports the file type.
2018-10-05windows/msvc: Fix incorrect indentation in dirent.c.stijn
2018-10-05extmod/moductypes: Remove BITFIELD from aggregate types enum.Paul Sokolovsky
This value is unused. It was an artifact of early draft design, but bitfields were optimized to use scalar one-word encoding, to allow compact encoding of typical multiple bitfields in MCU control registers.
2018-10-05docs/uselect: Describe more aspects of poll.register/modify behavior.Paul Sokolovsky
E.g., register() can be called again for the same object, while modify() will raise exception if object was not register()ed before.
2018-10-05tests/uselect_poll_basic: Add basic test for uselect.poll invariants.Paul Sokolovsky
This test doesn't check the actual I/O behavior, just "static" invariants like behavior on duplicate calls or calls when I/O object is not registered with poller.
2018-10-05unix/moduselect: Raise OSError(ENOENT) if obj to modify is not in pollerPaul Sokolovsky
Previously, the function silently succeeded. The new behavior is consistent with both baremetal uselect implementation and CPython 3.