Commit Graph

8422 Commits

Author SHA1 Message Date
Damien George 507119f4d8 py/sequence: Convert mp_uint_t to size_t where appropriate. 2017-03-23 16:23:20 +11:00
Damien George c88cfe165b py: Use size_t as len argument and return type of mp_get_index.
These values are used to compute memory addresses and so size_t is the
more appropriate type to use.
2017-03-23 16:17:40 +11:00
stijn 3f3df43501 msvc: Remove directory with generated files when cleaning.
This assures after cleaning all build artefacts (qstr related files,
generated version header) have been removed.
2017-03-23 15:49:57 +11:00
stijn c61131380d windows: Make msvc project file support any version from VS2013 to VS2017
Instead of having the PlatformToolset property hardcoded to a specific
version just set it to the value of DefaultPlatformToolset: this gets
defined according to the commandline environment in which the build was
started.
Instead of just supporting VS2015 the project can now be built by any
version from VS2013 to VS2017 and normally future versions as well, without
quirks like VS asking whether you want to upgrade the project to the latest
version (as was the case when opening the project in VS2017) or not being
able to build at all (as was the case when opening the project in VS2013).

Also adjust the .gitignore file to ignore any artefacts from VS2017.
2017-03-23 15:44:27 +11:00
Damien George 92cd000842 minimal/Makefile: Change C standard from gnu99 to c99. 2017-03-23 15:41:38 +11:00
Damien George 4afa782fb4 bare-arm/Makefile: Change C standard from gnu99 to c99. 2017-03-23 15:41:04 +11:00
Krzysztof Blazewicz 75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Glenn Ruben Bakke 8a884de7b9 nrf5/modules/ubluepy: Return BLE peer address as string instead of bytearray. Updated struct in modubluepy.h to use a mp_obj_t to hold a string instead of a fixed 6-byte array. Stripped down ScanEntry print out to only contain class name, peer address available through addr attribute. 2017-03-22 23:18:41 +01:00
Paul Sokolovsky 4a4bb84e92 tests/heapalloc_str: Test no-replacement case for str.replace(). 2017-03-22 22:17:52 +03:00
Damien George 58f23def55 py/bc: Provide better error message for an unexpected keyword argument.
Now, passing a keyword argument that is not expected will correctly report
that fact.  If normal or detailed error messages are enabled then the name
of the unexpected argument will be reported.

This patch decreases the code size of bare-arm and stmhal by 12 bytes, and
cc3200 by 8 bytes.  Other ports (minimal, unix, esp8266) remain the same in
code size.  For terse error message configuration this is because the new
message is shorter than the old one.  For normal (and detailed) error
message configuration this is because the new error message already exists
in py/objnamedtuple.c so there's no extra space in ROM needed for the
string.
2017-03-22 13:40:27 +11:00
Damien George 1110c8873c cc3200/mods/modutime: Use generic sleep_ms and sleep_us implementations. 2017-03-22 12:57:51 +11:00
Damien George 3509e2d307 stmhal/systick: Make mp_hal_delay_ms release the GIL when sleeping. 2017-03-22 12:54:43 +11:00
Damien George 2e3fc77809 extmod/utime_mphal: Don't exit/enter the GIL in generic sleep functions.
GIL behaviour should be handled by the port.  And ports probably want to
define sleep_us so that it doesn't release the GIL, to improve timing
accuracy.
2017-03-22 12:49:21 +11:00
Damien George 96c35d0ac4 stmhal/pybthread: Allow interrupts to work during lock/unlock of mutex.
When locking/unlocking a mutex we only need to protect against a thread
switch, not general interrupts.
2017-03-22 12:44:04 +11:00
Damien George 080210ddc6 stmhal/irq: Shift IRQ priorities of TIM and EXTINT to be above PENDSV.
This way, Timer and ExtInt callbacks can interrupt the low-priority
pendsv handler (for example thread switching).
2017-03-22 12:39:32 +11:00
Damien George 5d05ff1406 esp8266/machine_pin: Fix pin.irq() to work when all args are keywords. 2017-03-21 15:28:31 +11:00
Damien George b16c35486f esp8266/machine_pin: Fix memset size for zeroing of pin_irq_is_hard.
Thanks to @robert-hh.
2017-03-21 15:13:15 +11:00
Damien George ebbaf7ee57 stmhal/pendsv: Disable interrupts during a thread switch.
We can actually handle interrupts during a thread switch (because we always
have a valid stack), but only if those interrupts don't access any of the
thread state (because the state may not correspond to the stack pointer).
So to be on the safe side we disable interrupts during the very short
period of the thread state+stack switch.
2017-03-20 18:56:46 +11:00
Damien George 1a5c8d1053 py/vm: Don't release the GIL if the scheduler is locked.
The scheduler being locked general means we are running a scheduled
function, and switching to another thread violates that, so don't switch in
such a case (even though we technically could).

And if we are running a scheduled function then we want to finish it ASAP,
so we shouldn't switch to another thread.

Furthermore, ports with threading enabled will lock the scheduler during a
hard IRQ, and this patch to the VM will make sure that threads are not
switched during a hard IRQ (which would crash the VM).
2017-03-20 18:42:27 +11:00
Peter Hinch 231cfc84a7 extmod/modframebuf: Add support for monochrome horizontal format.
MHLSB and MHMSB formats are added to the framebuf module, which have 8
adjacent horizontal pixels represented in a single byte.
2017-03-20 16:21:47 +11:00
transistortim fb981107eb docs/library/machine.I2C: Fix scan() doc to match implementation.
Since eaef6b5324 writes are used instead of
reads.
2017-03-20 15:30:41 +11:00
Damien George 74faf4c5fc unix/coverage: Enable scheduler and add tests for it. 2017-03-20 15:20:26 +11:00
Damien George c772817dee tests/micropython: Add tests for micropython.schedule(). 2017-03-20 15:20:26 +11:00
Damien George 9ee4641850 esp8266/machine_pin: Make pin.irq arguments positional.
All arguments to pin.irq are converted from keyword-only to positional, and
can still be specified by keyword so it's a backwards compatible change.

The default value for the "trigger" arg is changed from 0 (no trigger)
to rising+falling edge.
2017-03-20 15:20:26 +11:00
Damien George 2507c83b0e esp8266/machine_pin: Add "hard" parameter to pin.irq, soft by default. 2017-03-20 15:20:26 +11:00
Damien George 31ea158557 esp8266: Change machine.Timer callback to soft callback. 2017-03-20 15:20:26 +11:00
Damien George 1b7d67266d esp8266: Enable micropython.schedule() with locking in pin callback. 2017-03-20 15:20:26 +11:00
Damien George a5159edc20 stmhal: Enable micropython.schedule().
ExtInt, Timer and CAN IRQ callbacks are made to work with the scheduler.
They are still hard IRQs by default, but one can now call
micropython.schedule within the hard IRQ to schedule a soft callback.
2017-03-20 15:20:26 +11:00
Damien George c138b21ceb unix: Use mp_handle_pending() in time.sleep(). 2017-03-20 15:20:26 +11:00
Damien George 6e74d24f30 py: Add micropython.schedule() function and associated runtime code. 2017-03-20 15:20:26 +11:00
stijn bf29fe2e13 py/objstr: Use better msg in bad implicit str/bytes conversion exception
Instead of always reporting some object cannot be implicitly be converted
to a 'str', even when it is a 'bytes' object, adjust the logic so that
when trying to convert str to bytes it is shown like that.
This will still report bad implicit conversion from e.g. 'int to bytes'
as 'int to str' but it will not result in the confusing
'can't convert 'str' object to str implicitly' anymore for calls like
b'somestring'.count('a').
2017-03-20 15:11:45 +11:00
Christopher Arndt 9b80a1e3e9 utime module documentation fixes and cleanup:
* Fix mis-spelling of `ticks_add` in code examples.
* Be consistent about parentheses after function names.
* Be consistent about formatting of function, variable and constant names.
* Be consistent about spaces and punctuation.
* Fix some language errors (missing or wrong words, wrong word order).
* Keep line length under 90 chars.

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
2017-03-17 20:45:08 +03:00
Damien George 5640e6dacd py: Provide mp_decode_uint_value to help optimise stack usage.
This has a noticeable improvement on x86-64 and Thumb2 archs, where stack
usage is reduced by 2 machine words in the VM.
2017-03-17 16:50:19 +11:00
Damien George 71a3d6ec3b py: Reduce size of mp_code_state_t structure.
Instead of caching data that is constant (code_info, const_table and
n_state), store just a pointer to the underlying function object from which
this data can be derived.

This helps reduce stack usage for the case when the mp_code_state_t
structure is stored on the stack, as well as heap usage when it's stored
on the heap.

The downside is that the VM becomes a little more complex because it now
needs to derive the data from the underlying function object.  But this
doesn't impact the performance by much (if at all) because most of the
decoding of data is done outside the main opcode loop.  Measurements using
pystone show that little to no performance is lost.

This patch also fixes a nasty bug whereby the bytecode can be reclaimed by
the GC during execution.  With this patch there is always a pointer to the
function object held by the VM during execution, since it's stored in the
mp_code_state_t structure.
2017-03-17 16:39:13 +11:00
Glenn Ruben Bakke 23163154b9 Merge branch 'master' into nrf5_no_sdk 2017-03-16 22:50:59 +01:00
Glenn Ruben Bakke 327754a953 nrf5/bluetooth: capture address type in addition to advertisment type in bluetooth advertisment reports. 2017-03-16 22:46:26 +01:00
Damien George eeff0c3528 tests/basics/bytes_add: Add tests for optimised bytes addition. 2017-03-16 14:31:03 +11:00
Damien George d279bcff8a py/objstr: Fix eager optimisation of str/bytes addition.
The RHS can only be returned if it is the same type as the LHS.
2017-03-16 14:30:04 +11:00
Damien George 7b7ff60f91 travis: Change an stmhal rule to build PYBV11 instead of default PYBV10.
This allows to test the PYBV11 target as well as the network drivers
without adding another rule.  It also removes the need to use -B,
side-stepping the issue of whether or not -B works with qstr auto
generation.
2017-03-15 22:20:30 +11:00
Damien George fcab435607 docs/library/framebuf: Fix typo in bit-width for MVLSB description. 2017-03-15 21:54:56 +11:00
Damien George 23a693ec2d py/mkrules.mk: Remove special check for "-B" in qstr auto generation.
When make is passed "-B" it seems that everything is considered out-of-date
and so $? expands to all prerequisites.  Thus there is no need for a
special check to see if $? is emtpy.
2017-03-15 21:50:48 +11:00
Damien George ecb4357fe1 tests/basics: Move string-modulo-format int tests to dedicated file. 2017-03-15 17:34:47 +11:00
Damien George b154468b08 tests/basics: Add test for string module formatting with int argument. 2017-03-15 17:31:17 +11:00
Damien George 3a0b2be6e2 tests/basics/string_format2: Adjust comment now that tests succeed. 2017-03-15 17:25:46 +11:00
Damien George d65371538d py/mpprint: Fix int formatting so "+" is printed for 0-valued integer. 2017-03-15 17:25:12 +11:00
Damien George 8cd4911e63 py/emitnative: Remove obsolete commented out code. 2017-03-15 10:03:22 +11:00
Glenn Ruben Bakke 3468972299 nrf5/modules/ubluepy: Correcting rssi member in scan_entry object to be int instead of uint. 2017-03-14 23:18:51 +01:00
Glenn Ruben Bakke 442e46f4be nrf5/modules/ubluepy: Adding attribute to ScanEntry object for getting address (returning bytearray), type (returning int) and rssi (returning int). 2017-03-14 23:14:55 +01:00
Glenn Ruben Bakke 609a174f8d nrf5/modules/ubluepy: Copy address type and rssi to the ScanEntry object upon reception of an advertisment report callback. 2017-03-14 23:13:13 +01:00
Glenn Ruben Bakke cbfba08ae7 nrf5/bluetooth: Adding address type to bluetooth stack driver advertisment structure, and fill the member when advertisment report is received. 2017-03-14 23:12:24 +01:00