Commit Graph

7748 Commits

Author SHA1 Message Date
Paul Sokolovsky ae831ec0a8 docs/library/micropython: Deconditionalize. 2017-04-16 09:18:47 +03:00
Damien George 61616e84ce extmod/machine_signal: Rename "inverted" arg to "invert", it's shorter.
A shorter name takes less code size, less room in scripts and is faster to
type at the REPL.

Tests and HW-API examples are updated to reflect the change.
2017-04-15 21:01:47 +03:00
Paul Sokolovsky 209eaec599 socket_send: Don't send more than MTU allows.
As Zephyr currently doesn't handle MTU itself (ZEP-1998), limit amount
of data we send on our side.

Also, if we get unsuccessful result from net_nbuf_append(), calculate
how much data it has added still. This works around ZEP-1984.
2017-04-14 19:46:27 +03:00
Paul Sokolovsky 5b8122f2bb tests/run-tests: Search feature checks wrt to main script location.
If run-tests script is run from another dir, we still want to look up
feature checks in run-tests' dir.
2017-04-14 17:07:13 +03:00
Paul Sokolovsky a1c39ffb69 docs/esp8266/tutorial/intro: Reword section on flash size requirement.
Give a clearly dissuading tone on end users trying 512KB version
- it has to many end-usery features lacking.
2017-04-14 01:12:04 +03:00
Paul Sokolovsky fbe7a81e30 esp8266/README: Add notice about 512K version. 2017-04-14 01:03:46 +03:00
Paul Sokolovsky 40acbc2e10 esp8266/README: Replace reference of alpha status to beta status. 2017-04-14 00:56:41 +03:00
Paul Sokolovsky 84e17063c3 zephyr/modusocket: Strip packet header right in the receive callback.
Instead of complicating recv() implementation.
2017-04-13 22:19:16 +03:00
Damien George 967cad7434 tests/extmod/utimeq1: Improve coverage of utimeq module. 2017-04-13 23:34:28 +10:00
Damien George c7e8c6f7de py/gc: Execute finaliser code in a protected environment.
If a finaliser raises an exception then it must not propagate through the
GC sweep function.  This patch protects against such a thing by running
finaliser code via the mp_call_function_1_protected call.

This patch also adds scheduler lock/unlock calls around the finaliser
execution to further protect against any possible reentrancy issues: the
memory manager is already locked when doing a collection, but we also don't
want to allow any scheduled code to run, KeyboardInterrupts to interupt the
code, nor threads to switch.
2017-04-12 13:52:04 +10:00
Damien George 08242eed26 py/nlrsetjmp: Add check for failed NLR jump.
Also optimise the function so it only needs to call the MP_STATE_THREAD
macro once (following how other nlr code is written).
2017-04-12 13:50:31 +10:00
Damien George fe79234ca0 unix: Enabled high-quality float hashing in coverage build. 2017-04-12 13:38:17 +10:00
Damien George a73501b1d6 py/objfloat: Add implementation of high-quality float hashing.
Disabled by default.
2017-04-12 13:38:17 +10:00
Damien George 816413e4b2 py: Optimise types for common case where type has a single parent type.
The common cases for inheritance are 0 or 1 parent types, for both built-in
types (eg built-in exceptions) as well as user defined types.  So it makes
sense to optimise the case of 1 parent type by storing just the type and
not a tuple of 1 value (that value being the single parent type).

This patch makes such an optimisation.  Even though there is a bit more
code to handle the two cases (either a single type or a tuple with 2 or
more values) it helps reduce overall code size because it eliminates the
need to create a static tuple to hold single parents (eg for the built-in
exceptions).  It also helps reduce RAM usage for user defined types that
only derive from a single parent.

Changes in code size (in bytes) due to this patch:

    bare-arm:       -16
    minimal (x86): -176
    unix (x86-64): -320
    unix nanbox:   -384
    stmhal:         -64
    cc3200:         -32
    esp8266:       -108
2017-04-12 13:22:21 +10:00
Damien George fc710169b7 py/obj: Clean up and add comments describing mp_obj_type_t struct. 2017-04-12 13:20:26 +10:00
Paul Sokolovsky 81d302b8f8 zephyr/modusocket: Call net_nbuf_print_frags() in recv callback if DEBUG > 1. 2017-04-11 15:25:42 +03:00
Damien George e31fbd9b41 py/objint: Use unsigned arithmetic when formatting an integer.
Otherwise the edge case of the most negative integer value will not convert
correctly.
2017-04-11 15:18:35 +10:00
Damien George f66df1efc8 py/objint: Extract small int value directly because type is known. 2017-04-11 15:16:09 +10:00
Damien George 6c564aa408 unix, windows: Use core-provided KeyboardInterrupt exception object. 2017-04-11 13:31:49 +10:00
Damien George 9156c8b460 stmhal: Enable parsing of all Pin constructor args by machine.Signal. 2017-04-11 13:12:54 +10:00
Paul Sokolovsky 605ff91efd extmod/machine_signal: Support all Pin's arguments to the constructor.
This implements the orginal idea is that Signal is a subclass of Pin, and
thus can accept all the same argument as Pin, and additionally, "inverted"
param. On the practical side, it allows to avoid many enclosed parenses for
a typical declararion, e.g. for Zephyr:

Signal(Pin(("GPIO_0", 1))).

Of course, passing a Pin to Signal constructor is still supported and is the
most generic form (e.g. Unix port will only support such form, as it doesn't
have "builtin" Pins), what's introduces here is just practical readability
optimization.

"value" kwarg is treated as applying to a Signal (i.e. accounts for possible
inversion).
2017-04-11 00:12:20 +03:00
Damien George 79ce664952 py/runtime: When init'ing kbd intr exc, use tuple ptr instead of object. 2017-04-10 17:07:26 +10:00
Damien George ee86de1f1a py: Make sure that static emg-exc-buffer is aligned to size of mp_obj_t.
This buffer is used to allocate objects temporarily, and such objects
require that their underlying memory be correctly aligned for their data
type.  Aligning for mp_obj_t should be sufficient for emergency exceptions,
but in general the memory buffer should aligned to the maximum alignment of
the machine (eg on a 32-bit machine with mp_obj_t being 4 bytes, a double
may not be correctly aligned).

This patch fixes a bug for certain nan-boxing builds, where mp_obj_t is 8
bytes and must be aligned to 8 bytes (even though the machine is 32 bit).
2017-04-10 16:02:56 +10:00
Paul Sokolovsky b87432b8fb docs/uhashlib: Deconditionalize.
Notes on WiPy incompatibilities with the standard module API are
moved under "Known issues" to its documentation.
2017-04-09 00:57:54 +03:00
Paul Sokolovsky 2e58474580 docs/usocket: Deconditionalize.
Notes on WiPy incompatibilities with the standard socket module API are
moved under "Known issues" to its documentation.
2017-04-09 00:48:28 +03:00
Paul Sokolovsky 3acace588a docs/utime: Deconditionalize description of sleep(). 2017-04-09 00:42:32 +03:00
Paul Sokolovsky 1d74559b6b docs/library/machine.UART: Remove some conditionals. 2017-04-09 00:25:27 +03:00
Paul Sokolovsky e322b2afbf cc3200/pybuart: Make parity specifications consistent with HW API.
parity=0 means even parity, parity=1 - odd.
2017-04-09 00:19:02 +03:00
Paul Sokolovsky bcf3c8bf17 docs/library/builtins: int: Add notice on byteorder param for to/from_bytes. 2017-04-09 00:06:54 +03:00
Paul Sokolovsky 0a88b44248 zephyr/machine_pin: Implement pin protocol for machine.Signal support. 2017-04-08 14:27:36 +03:00
Paul Sokolovsky e05cb4183a zephyr/modmachine: Add Signal class. 2017-04-08 00:50:19 +03:00
Paul Sokolovsky cf70f9a474 zephyr/mpconfigport.h: Fix build if usocket module is disabled. 2017-04-08 00:38:51 +03:00
Paul Sokolovsky 8ef469f7ca zephyr/modusocket: Implement accept(). 2017-04-08 00:33:09 +03:00
Paul Sokolovsky 96166ec165 zephyr/modusocket: socket_bind: Don't set recv callback on STREAM sockets.
For stream sockets, next exected operation is listen().
2017-04-08 00:30:17 +03:00
Paul Sokolovsky f1c0676a70 zephyr/modusocket: Implement listen(). 2017-04-07 16:47:10 +03:00
Paul Sokolovsky e5278b98fe docs/esp8266/general: Start explicit "Known Issues", mentioned RTC inaccuracy. 2017-04-07 10:52:50 +03:00
Damien George d7310fabc2 drivers/nrf24l01: Update to work on newer ports, using machine, utime.
Changes made are:
- Use the time module in place of the pyb module for delays.
- Use spi.read/spi.write instead of spi.send/spi.receive.
- Drop some non-portable parameters to spi and pin initialization.

Thanks to @deshipu for the original patch.
2017-04-07 15:54:21 +10:00
Paul Sokolovsky 3e1310d6e2 tools/pyboard: Provide more details when expected reply not received.
When trying to execute a command via raw REPL and expected "OK" reply
not received, show what was received instead.
2017-04-07 01:04:47 +03:00
Paul Sokolovsky 1da8404647 modusocket: Handle a case when recv_q is empty when EOF is signaled.
In this case, we can mark socket as closed directly.
2017-04-06 10:12:14 +03:00
Paul Sokolovsky faf333c04f zephyr/modusocket: Factor out "extended k_fifo API".
Internal structure of k_fifo changed between 1.7 and 1.8, so we need
to abstract it away. This adds more functions than currently used, for
future work.
2017-04-05 13:39:16 +03:00
Paul Sokolovsky 390d5a3bf1 docs/machine.Pin: Move wipy-specific methods to its docs. 2017-04-05 13:05:04 +03:00
Paul Sokolovsky 2cbe997834 tools/pyboard: ProcessPtyToTerminal: Add workaround for PySerial bug.
When working with a "virtual" port, like PTY. The issue described in
http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port
2017-04-05 12:30:39 +03:00
Paul Sokolovsky d46899626e docs/machine.Pin: Move wipy-specific details to its own docs. 2017-04-05 12:09:36 +03:00
Paul Sokolovsky 9a38b7afe0 cc3200/modmachine: Return frequency value directly, like other ports. 2017-04-05 11:58:17 +03:00
Paul Sokolovsky 4333b2fb53 docs/machine.SPI: Remove outdated wipy chunk. 2017-04-05 11:47:15 +03:00
Paul Sokolovsky 906d58f6f2 docs/uos: De-conditionalize statvfs() description.
It's a standard function, and it's already described (in the library
intro) that for any given port, any function may be missing.
2017-04-05 11:44:10 +03:00
Paul Sokolovsky 0a861db91c docs/utime: De-conditionalize description of sleep_ms() and friends.
These are basic MicroPython API, and all ports should implement them.
2017-04-05 11:40:47 +03:00
Damien George b6fff4186d tests/basics: Add test for tuple inplace add. 2017-04-05 12:38:18 +10:00
Damien George 81d2ca2b12 py/objtuple: Add support for inplace add (same as normal add). 2017-04-05 12:38:02 +10:00
Damien George dcd8f52766 tests/basics: Add tests for raising ValueError when range() gets 0 step. 2017-04-05 10:52:29 +10:00