Commit Graph

6053 Commits

Author SHA1 Message Date
Paul Sokolovsky 9d04fec5d9 extmod/modussl: Make more compatible with non-default obj representations.
Still not compatible with nanboxing.
2016-05-26 02:10:35 +03:00
Paul Sokolovsky c76acd8c23 py/moduerrno: Add EEXIST, EISDIR.
Useful to check file/dir operations result, in particular used by upip.
2016-05-25 01:23:57 +03:00
Paul Sokolovsky 2b05b60bbc esp8266/esp_mphal: mp_uos_dupterm_deactivate() may raise exception.
So, keep call to it protected via NLR still.
2016-05-24 15:04:59 +03:00
Paul Sokolovsky 4681b86850 esp8266/esp_mphal: Handle Ctrl+C from dupterm (e.g. WebREPL). 2016-05-24 01:37:56 +03:00
Paul Sokolovsky 116eeee6db esp8266/esp_mphal: Fix NLR buffer leak in call_dupterm_read(). 2016-05-24 01:30:28 +03:00
Paul Sokolovsky bc2ba6b2e3 esp8266/scripts/port_diag: Dump network interface IP settings. 2016-05-24 01:27:16 +03:00
mad474 eaecc4c02e docs/esp8266/general: Grammar fixes. 2016-05-23 23:33:23 +03:00
Antonin ENFRUN ca41dc2750 py/objnamedtuple: Allow passing field names as a tuple.
So the documentation's example works.  Besides, a tuple can be more
memory efficient.
2016-05-23 21:08:07 +01:00
Damien George 2133924e46 unix: Support frozen packages.
To use, put your directory structure with .py files in frozen/ and then:

    make FROZEN_MPY_DIR=frozen
2016-05-23 15:19:53 +01:00
Damien George 202d5acd06 py/makeqstrdata.py: Allow to have double-quote characters in qstrs.
When rendering the qstr for a C header file, the double-quate character
must be escaped.
2016-05-23 15:18:55 +01:00
Damien George 3e03d1b87e stmhal: Support frozen packages using .mpy files.
See issue #1814.
2016-05-23 13:29:56 +01:00
Damien George 25a42fb6ef tools/mpy-tool.py: Don't strip directories from the frozen source name.
Directories are now supported by the frozen import system (to implement
frozen packages) so we should keep them.
2016-05-23 13:29:03 +01:00
Damien George 74fb4e795b mpy-cross: Add -s option to specify the embedded source filename.
.mpy files contain the name of the source file that they were compiled
from.  This patch adds a way to change this name to an arbitrary string,
specified on the command line with the -s option.  The default is to use
the full name of the input filename.

This new -s option is useful to strip off a leading directory name so
that mpy-tool.py can freeze packages.
2016-05-23 13:25:54 +01:00
Damien George 9b4c013823 tools/mpy-tool.py: Include .py extension in frozen filename.
So that it can be correctly stat'd when looking for frozen files.
2016-05-23 12:46:02 +01:00
Damien George 274952a117 py: Allow to stat and import frozen mpy files using new frozen "VFS".
Freezing mpy files using mpy-tool.py now works again.
2016-05-23 12:42:23 +01:00
Paul Sokolovsky 3e33aeb0db docs: esp8266: Include ussl module in the docs. 2016-05-22 23:57:26 +03:00
Paul Sokolovsky bca4c9e465 docs/ussl: Add basic description of axTLS-based modussl.
In particular, disclose the fact that server certificates are not
validated.
2016-05-22 23:56:22 +03:00
Paul Sokolovsky cb7693bab4 esp8266/main: Update _boot module loading for recent frozen modules refactors. 2016-05-22 04:09:15 +03:00
Paul Sokolovsky 9c2217a165 esp8266: Enable collections.OrderedDict. 2016-05-22 02:57:33 +03:00
Paul Sokolovsky 9dde6062cc py/objstr: Fix mix-signed comparison in str.center(). 2016-05-22 02:22:14 +03:00
Dave Hylands 6a60fb3cf4 py/objstr*: Properly ifdef str.center(). 2016-05-22 01:54:41 +03:00
Paul Sokolovsky 53bac8e869 tests: Add testcase for str.center(). 2016-05-22 00:18:53 +03:00
Paul Sokolovsky 1b5abfcaae py/objstr: Implement str.center().
Disabled by default, enabled in unix port. Need for this method easily
pops up when working with text UI/reporting, and coding workalike
manually again and again counter-productive.
2016-05-22 00:13:44 +03:00
Paul Sokolovsky 2c573f00b8 py/builtinimport: Unbreak bare-arm build. 2016-05-21 22:37:58 +03:00
Paul Sokolovsky 8a2970e136 py/builtinimport: Unbreak minimal build.
These are workarounds required until frozen .mpy loading following standard
frozen modules code path.
2016-05-21 22:23:08 +03:00
Paul Sokolovsky daa4793578 tools/make-frozen: Update for latest changes in frozen modules support.
Frozen modules are now stored with extensions and with '/' as path
separator. In other words, frozen modules paths stored as they are
in normal filesystem.
2016-05-21 21:39:27 +03:00
Paul Sokolovsky fb742cdc12 py/{builtinimport,frozenmod}: Rework frozen modules support to support packages.
Now frozen modules is treated just as a kind of VFS, and all operations
performed on it correspond to operations on normal filesystem. This allows
to support packages properly, and potentially also data files.

This change also have changes to rework frozen bytecode modules support to
use the same framework, but it's not finished (and actually may not work,
as older adhox handling of any type of frozen modules is removed).
2016-05-21 21:38:50 +03:00
Paul Sokolovsky b580958216 unix/unix_mphal: Implement mp_hal_ticks_us().
Similar to existing mp_hal_ticks_ms().
2016-05-21 02:16:35 +03:00
Paul Sokolovsky 5a2a4e9452 py/mphal.h: Provide default prototypes for mp_hal_delay_us/mp_hal_ticks_us.
Similar to existing mp_hal_delay_ms/mp_hal_ticks_ms.
2016-05-21 02:13:50 +03:00
Paul Sokolovsky 0ab372585f extmod/moduos_dupterm: Dumpterm subsystem is responsible for closing stream.
Make dupterm subsystem close a term stream object when EOF or error occurs.
There's no other party than dupterm itself in a better position to do this,
and this is required to properly reclaim stream resources, especially if
multiple dupterm sessions may be established (e.g. as networking
connections).
2016-05-20 22:20:37 +03:00
Paul Sokolovsky 3a29db8e58 extmod/modwebrepl: Add close() method. 2016-05-20 21:32:41 +03:00
Paul Sokolovsky ccf4e5ab7b extmod/modwebsocket: Add close() method. 2016-05-20 21:18:49 +03:00
Paul Sokolovsky 497660fcda py/stream: Add mp_stream_close() helper function. 2016-05-20 21:18:49 +03:00
Damien George f9dc644017 extmod: When including extmod headers, prefix path with extmod/. 2016-05-20 12:46:20 +01:00
Damien George 3ff16ff52e py: Declare constant data as properly constant.
Otherwise some compilers (eg without optimisation) will put this read-only
data in RAM instead of ROM.
2016-05-20 12:46:20 +01:00
misterdanb a0a08b4be1 esp8266: Add APA102 serial individually controllable LEDs support.
APA102 is a new "smart LED", similar to WS2812 aka "Neopixel".
2016-05-19 22:29:11 +03:00
Torwag 6fa60153ea esp8266/README: Add a very first start section.
Adding a very first start section to get people going after flashing.
I tried to condense it to  a minimum to avoid as much as possible
redundancy and bloating.
2016-05-19 21:10:35 +03:00
Paul Sokolovsky 7f7c84b10a py/stream: Support both "exact size" and "one underlying call" operations.
Both read and write operations support variants where either a) a single
call is made to the undelying stream implementation and returned buffer
length may be less than requested, or b) calls are repeated until requested
amount of data is collected, shorter amount is returned only in case of
EOF or error.

These operations are available from the level of C support functions to be
used by other C modules to implementations of Python methods to be used in
user-facing objects.

The rationale of these changes is to allow to write concise and robust
code to work with *blocking* streams of types prone to short reads, like
serial interfaces and sockets. Particular object types may select "exact"
vs "once" types of methods depending on their needs. E.g., for sockets,
revc() and send() methods continue to be "once", while read() and write()
thus converted to "exactly" versions.

These changes don't affect non-blocking handling, e.g. trying "exact"
method on the non-blocking socket will return as much data as available
without blocking. No data available is continued to be signaled as None
return value to read() and write().

From the point of view of CPython compatibility, this model is a cross
between its io.RawIOBase and io.BufferedIOBase abstract classes. For
blocking streams, it works as io.BufferedIOBase model (guaranteeing
lack of short reads/writes), while for non-blocking - as io.RawIOBase,
returning None in case of lack of data (instead of raising expensive
exception, as required by io.BufferedIOBase). Such a cross-behavior
should be optimal for MicroPython needs.
2016-05-18 02:41:45 +03:00
Paul Sokolovsky 92a342a011 unix/mpconfigport_coverage.h: Add dedicated config file for coverage build.
This allows to enable the options which aren't enabled in the normal unix
config (as unix port is no longer an enable-all port).
2016-05-18 00:58:32 +03:00
Paul Sokolovsky 418faae8f7 esp8266/scripts/webrepl_setup: Add max password length check.
modwebrepl truncates password to 9 chars, and that led people to confusion.
2016-05-17 02:21:45 +03:00
Damien George 1e024de7be unix: Add ability to include frozen bytecode in the build.
To use frozen bytecode make a subdirectory under the unix/ directory
(eg frozen/), put .py files there, then run:

    make FROZEN_MPY_DIR=frozen

Be sure to build from scratch.  The .py files will then be available for
importing.
2016-05-16 23:17:11 +01:00
Damien George 99b4719357 tools/mpy-tool.py: Add checks for critical configuration vars.
When an mpy file is frozen it must know the values of certain
configuration variables.  This patch provides an explicit check in the
generated C file that the configuration variables are what they are
supposed to be.
2016-05-16 23:13:30 +01:00
Paul Sokolovsky 21ec1fd850 esp8266/scripts/webrepl_setup: Show password placeholder char.
That was the intent for the initial user setup, but didn't work before
due to lwIP issues. Enable now that they're fixed.
2016-05-17 00:01:41 +03:00
Paul Sokolovsky 7327d5f6f7 esp8266/scripts/port_diag: Add network diagnostic output. 2016-05-16 23:52:58 +03:00
Robert HH a676a41cb7 esp8266/moduos.c: Addition of the rename method to module uos.
That one was missing in the module, even if it was available in the
vfs object. The change consist of adding the name and preparing the
call to the underlying vfs module, similar to what was already
implemented e.g. for remove.

Rename is useful by itself, or for instance for a safe file replace,
consisting of the sequence:

    write to a temp file
    delete the original file
    rename the temp file to the original file's name
2016-05-16 13:19:13 +02:00
Paul Sokolovsky afce978aca extmod/modlwip: Rework how Python accept callback is called.
Calling it from lwIP accept callback will lead incorrect functioning
and/or packet leaks if Python callback has any networking calls, due
to lwIP non-reentrancy. So, instead schedule "poll" callback to do
that, which will be called by lwIP when it does not perform networking
activities. "Poll" callback is called infrequently though (docs say
every 0.5s by default), so for better performance, lwIP needs to be
patched to call poll callback soon after accept callback, but when
current packet is already processed.
2016-05-15 22:42:12 +03:00
Paul Sokolovsky ca63c77073 docs/ustruct: Describe supported type codes. 2016-05-14 20:48:43 +03:00
Paul Sokolovsky 7b1bf0c308 tools/make-frozen.py: Quick fix to support package-modules.
It allows to "import foo.bar", but not "from foo import bar".
2016-05-14 16:30:02 +03:00
Paul Sokolovsky 719f8c044a tests/struct1: Add testcase for an unknown type char. 2016-05-14 15:54:09 +03:00
Paul Sokolovsky e53fb1bf03 py/modstruct: Raise ValueError on unsupported format char. 2016-05-14 15:47:08 +03:00