Commit Graph

500 Commits

Author SHA1 Message Date
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00
Damien George 1c6b442d32 extmod/modubinascii: Don't post-increment variable that won't be used. 2017-08-21 22:05:39 +10:00
Damien George 4c736ea8fc extmod,unix: For uos.stat interpret st_size member as an unsigned int.
This prevents large files (eg larger than 2gb on a 32-bit arch) from
showing up as having a negative size.  Fixes issue #3227.
2017-08-21 20:47:22 +10:00
Alex Robbins c89254fd0f extmod/modubinascii: Rewrite mod_binascii_a2b_base64.
This implementation ignores invalid characters in the input. This allows
it to decode the output of b2a_base64, and also mimics the behavior of
CPython.
2017-08-17 09:25:51 +03:00
Eric Poulsen d5191edf7f extmod/modussl_mbedtls.c: Add ussl.getpeercert() method.
Behaviour is as per CPython but only the binary form is implemented here.
A test is included.
2017-08-16 15:01:00 +10:00
Javier Candeira 35a1fea90b all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError
  - OSError invocations unchanged, because the corresponding utility
    function takes ints, not strings like the long form invocation.
  - OverflowError, IndexError and RuntimeError etc. not changed for now
    until we decide whether to add new utility functions.
2017-08-13 22:52:33 +10:00
Damien George 0f12082f5b py,extmod,stmhal: Use "static inline" for funcs that should be inline.
"STATIC inline" can expand to "inline" if STATIC is defined to nothing, and
this case can lead to link errors.
2017-08-02 13:42:34 +10:00
Paul Sokolovsky ee04525097 extmod/modlwip: Implement setsockopt(IP_ADD_MEMBERSHIP).
Allows to join multicast groups.
2017-07-31 22:38:37 +03:00
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Damien George bbced3b4bb extmod: Use MP_ROM_INT for int values in an mp_rom_map_elem_t. 2017-07-31 13:00:34 +10:00
Paul Sokolovsky f2140f9446 extmod/mod{lwip,onewire,webrepl}: Convert to mp_rom_map_elem_t. 2017-07-29 18:24:16 +03:00
Paul Sokolovsky 036b58228c extmod/modframebuf: Use correct initialization for .locals_dict. 2017-07-29 10:26:41 +03:00
Damien George 653a0c2d71 extmod/machine_signal: Fix parsing of invert arg when Pin is first arg. 2017-07-26 12:51:46 +10:00
Eric Poulsen 6b4d4a25ce extmod/modussl_mbedtls: Implement non-blocking SSL sockets. 2017-07-26 11:34:33 +10:00
Damien George f3687109d5 extmod/modframebuf: Consistently use "col" as name for colour variables.
Thanks to @kamikaze, aka Oleg Korsak, for the original idea and patch.
2017-07-25 14:06:44 +10:00
Damien George 0893b273b9 extmod/modussl_mbedtls: Make socket.close() free all TLS resources.
Also, use mp_stream_close() helper to close the underlying socket.
2017-07-25 14:00:45 +10:00
Radomir Dopieralski 363087aa11 extmod/modframebuf: Fix invalid stride for odd widths in GS4_HMSB fmt.
Since the stride is specified in pixels, in a 4-bit horizontal format it
has to always be even, otherwise the computation is wrong and we can
write outside of the buffer sometimes.
2017-07-25 12:29:02 +10:00
Damien George a10467b58a extmod/modussl_mbedtls: When reading and peer wants to close, return 0.
If this particular code is returned then there's no more data, it's not
really an error.
2017-07-25 11:53:26 +10:00
Damien George aa7be82a4d all: Don't include system errno.h when it's not needed. 2017-07-24 18:43:14 +10:00
Damien George 513dfcf4fe extmod/modussl_mbedtls: Support server_side mode.
To use server_side mode one must pass valid values in the "key" and "cert"
parameters.
2017-07-24 15:08:59 +10:00
Paul Sokolovsky 4368ae3142 extmod/modussl_axtls: Allow to close ssl stream multiple times.
Make sure that 2nd close has no effect and operations on closed streams
are handled properly.
2017-07-20 00:20:53 +03:00
Damien George 761e4c7ff6 all: Remove trailing spaces, per coding conventions. 2017-07-19 13:12:10 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
Tom Collins 145796f037 py,extmod: Some casts and minor refactors to quiet compiler warnings. 2017-07-07 11:32:22 +10:00
Damien George f110dbd795 extmod/modujson: Properly initialise temporary StringIO object. 2017-07-05 10:38:20 +10:00
Damien George b86c65d31c extmod/modubinascii: Add check for empty buffer passed to hexlify.
Previous to this patch hexlify(b'', b':') would lead to a bad crash due to
the computed length of the result being -1=0xffffffff.
2017-07-03 14:52:00 +10:00
Paul Sokolovsky 58b7b01cb5 extmod/modure: If input string is bytes, return bytes results too.
This applies to match.group() and split().

For ARM Thumb2, this increased code size by 12 bytes.
2017-07-01 01:25:45 +03:00
Scott Shawcroft 778e975936 Split uos module into os and storage.
os is a subset of CPython's os. storage contains additional
file system mounting functionality based on UNIX's mount
management.

Fixes #140
2017-06-27 15:17:30 -07:00
Paul Sokolovsky 91e93a9684 extmod/moduzlib: decompress: Remove stale "(void)n_args".
n_args is now actually used in this function.
2017-06-24 16:36:05 +03:00
Damien George eeaab1897b extmmod/modonewire: Rename public module to mp_module_onewire.
This follows naming scheme of other modules in extmod.
2017-06-22 16:17:46 +10:00
Damien George 6cc4da4cb8 extmod: Move modonewire.c from esp8266 to extmod directory.
It's now generic enough to be used by any port.
2017-06-22 16:06:00 +10:00
Scott Shawcroft 30ee7019ca Merge tag 'v1.9.1'
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions

This release provides an important fix for the USB mass storage device in
the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which
is now require by some Operating Systems.  There are also fixes for the
lwIP bindings to improve non-blocking sockets and error codes.  The VFS has
some regressions fixed including the ability to statvfs the root.

All changes are listed below.

py core:
- modbuiltins: add core-provided version of input() function
- objstr: catch case of negative "maxsplit" arg to str.rsplit()
- persistentcode: allow to compile with complex numbers disabled
- objstr: allow to compile with obj-repr D, and unicode disabled
- modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled
- provide mp_decode_uint_skip() to help reduce stack usage
- makeqstrdefs.py: make script run correctly with Python 2.6
- objstringio: if created from immutable object, follow copy on write policy

extmod:
- modlwip: connect: for non-blocking mode, return EINPROGRESS
- modlwip: fix error codes for duplicate calls to connect()
- modlwip: accept: fix error code for non-blocking mode
- vfs: allow to statvfs the root directory
- vfs: allow "buffering" and "encoding" args to VFS's open()
- modframebuf: fix signed/unsigned comparison pendantic warning

lib:
- libm: use isfinite instead of finitef, for C99 compatibility
- utils/interrupt_char: remove support for KBD_EXCEPTION disabled

tests:
- basics/string_rsplit: add tests for negative "maxsplit" argument
- float: convert "sys.exit()" to "raise SystemExit"
- float/builtin_float_minmax: PEP8 fixes
- basics: convert "sys.exit()" to "raise SystemExit"
- convert remaining "sys.exit()" to "raise SystemExit"

unix port:
- convert to use core-provided version of built-in import()
- Makefile: replace references to make with $(MAKE)

windows port:
- convert to use core-provided version of built-in import()

qemu-arm port:
- Makefile: adjust object-file lists to get correct dependencies
- enable micropython.mem_*() functions to allow more tests

stmhal port:
- boards: enable DAC for NUCLEO_F767ZI board
- add support for NUCLEO_F446RE board
- pass USB handler as parameter to allow more than one USB handler
- usb: use local USB handler variable in Start-of-Frame handler
- usb: make state for USB device private to top-level USB driver
- usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command
- convert from using stmhal's input() to core provided version

cc3200 port:
- convert from using stmhal's input() to core provided version

teensy port:
- convert from using stmhal's input() to core provided version

esp8266 port:
- Makefile: replace references to make with $(MAKE)
- Makefile: add clean-modules target
- convert from using stmhal's input() to core provided version

zephyr port:
- modusocket: getaddrinfo: Fix mp_obj_len() usage
- define MICROPY_PY_SYS_PLATFORM (to "zephyr")
- machine_pin: use native Zephyr types for Zephyr API calls

docs:
- machine.Pin: remove out_value() method
- machine.Pin: add on() and off() methods
- esp8266: consistently replace Pin.high/low methods with .on/off
- esp8266/quickref: polish Pin.on()/off() examples
- network: move confusingly-named cc3200 Server class to its reference
- uos: deconditionalize, remove minor port-specific details
- uos: move cc3200 port legacy VFS mounting functions to its ref doc
- machine: sort machine classes in logical order, not alphabetically
- network: first step to describe standard network class interface

examples:
- embedding: use core-provided KeyboardInterrupt object
2017-06-20 10:56:05 -07:00
Damien George 48d867b4a6 all: Make more use of mp_raise_{msg,TypeError,ValueError} helpers. 2017-06-15 11:54:41 +10:00
Paul Sokolovsky 82b9915b34 extmod/modussl_axtls: Implement server_hostname arg to wrap_socket().
As enabled by SNI support in axTLS v2+.
2017-06-14 01:01:12 +03:00
Paul Sokolovsky 75c3f2a7ab extmod/modussl_axtls: Update for axTLS 2.1.3.
ssl_client_new() accepts new SSL_EXTENSIONS* argument.
2017-06-13 17:41:46 +03:00
Paul Sokolovsky 0a7735f1a6 extmod/modframebuf: Fix signed/unsigned comparison pendantic warning.
Happened with 32-bit gcc 4.8.4.
2017-06-10 20:34:38 +03:00
Damien George 7ecfbb8267 extmod/vfs: Allow "buffering" and "encoding" args to VFS's open().
These args are currently ignored but are parsed to make it easier to
write portable scripts between CPython and MicroPython.
2017-06-07 15:29:53 +10:00
Damien George f6ef8e3f17 extmod/vfs: Allow to statvfs the root directory. 2017-06-07 15:17:45 +10:00
Paul Sokolovsky 50de6d2fab extmod/modlwip: accept: Fix error code for non-blocking mode.
In non-blocking mode, if no pending connection available, should return
EAGAIN, not ETIMEDOUT.
2017-06-04 13:45:37 +03:00
Paul Sokolovsky 5da8de2b66 extmod/modlwip: Fix error codes for duplicate calls to connect().
If socket is already connected, POSIX requires returning EISCONN. If
connection was requested, but not yet complete (for non-blocking
socket), error code is EALREADY.

http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
2017-06-04 12:30:41 +03:00
Paul Sokolovsky a0dbbbebb8 extmod/modlwip: connect: For non-blocking mode, return EINPROGRESS.
Instead of ETIMEDOUT. This is consistent with POSIX:
http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
2017-06-03 22:48:31 +03:00
Ville Skyttä ca16c38210 various: Spelling fixes 2017-05-29 11:36:05 +03:00
Damien George f95e4e7782 extmod/vfs_fat_misc: Remove dot-dirs filter since FatFS already does it. 2017-05-13 18:58:46 +10:00
Scott Shawcroft 790c38e18c atmel-samd: Rework boot, main and REPL order.
Boot will only run once now before USB is started. Its output goes to
boot_out.txt. After main and REPL will run with VM and hardware resets
between each.
2017-05-12 18:26:14 -07:00
Damien George d70f688f25 extmod/vfs: Use MP_S_IFDIR, MP_S_IFREG consts instead of magic numbers. 2017-05-10 12:30:34 +10:00
Damien George d4cd4831b0 extmod/vfs_fat: Replace listdir() with implementation of ilistdir().
VfsFat no longer has the listdir() method.  Rather, if listdir()
functionality is needed then one should use uos.listdir() which will call
VfsFat.ilistdir().
2017-05-10 11:39:28 +10:00
Damien George 87283c1974 extmod/vfs: Implement mp_vfs_ilistdir().
uos.ilistdir() is the core function, returning an iterator that yields
3-tuples.  uos.listdir() is implemented in terms of ilistdir().
2017-05-10 11:39:28 +10:00
Damien George c9a3a68a49 extmod/vfs: Allow a VFS to be mounted at the root dir.
This patch allows mounting of VFS objects right at the root directory, eg
os.mount(vfs, '/').  It still allows VFS's to be mounted at a path within
the root, eg os.mount(vfs, '/flash'), and such mount points will override
any paths within a VFS that is mounted at the root.
2017-05-05 20:15:10 +10:00
Scott Shawcroft 58b9789d0c atmel-samd: Introduce audio sample playback via audioio.AudioOut. 2017-05-01 13:10:03 -07:00
Paul Sokolovsky 5db55e63f3 extmod/modlwip: ioctl POLL: Fix handling of peer closed socket.
Peer-closed socket is both readable and writable: read will return EOF,
write - error. Without this poll will hang on such socket.

Note that we don't return POLLHUP, based on argumentation in
http://www.greenend.org.uk/rjk/tech/poll.html that it should apply to
deeper disconnects, for example for networking, that would be link layer
disconnect (e.g. WiFi went down).
2017-05-01 18:20:09 +03:00