Wykres commitów

10 Commity (master)

Autor SHA1 Wiadomość Data
Maarten van der Schrieck 3bca93b2d0 ports: Fix sys.stdout.buffer.write() return value.
MicroPython code may rely on the return value of sys.stdout.buffer.write()
to reflect the number of bytes actually written. While in most scenarios a
write() operation is successful, there are cases where it fails, leading to
data loss. This problem arises because, currently, write() merely returns
the number of bytes it was supposed to write, without indication of
failure.

One scenario where write() might fail, is where USB is used and the
receiving end doesn't read quickly enough to empty the receive buffer. In
that case, write() on the MicroPython side can timeout, resulting in the
loss of data without any indication, a behavior observed notably in
communication between a Pi Pico as a client and a Linux host using the ACM
driver.

A complex issue arises with mp_hal_stdout_tx_strn() when it involves
multiple outputs, such as USB, dupterm and hardware UART. The challenge is
in handling cases where writing to one output is successful, but another
fails, either fully or partially. This patch implements the following
solution:

mp_hal_stdout_tx_strn() attempts to write len bytes to all of the possible
destinations for that data, and returns the minimum successful write
length.

The implementation of this is complicated by several factors:
- multiple outputs may be enabled or disabled at compiled time
- multiple outputs may be enabled or disabled at runtime
- mp_os_dupterm_tx_strn() is one such output, optionally containing
  multiple additional outputs
- each of these outputs may or may not be able to report success
- each of these outputs may or may not be able to report partial writes

As a result, there's no single strategy that fits all ports, necessitating
unique logic for each instance of mp_hal_stdout_tx_strn().

Note that addressing sys.stdout.write() is more complex due to its data
modification process ("cooked" output), and it remains unchanged in this
patch. Developers who are concerned about accurate return values from
write operations should use sys.stdout.buffer.write().

This patch might disrupt some existing code, but it's also expected to
resolve issues, considering that the peculiar return value behavior of
sys.stdout.buffer.write() is not well-documented and likely not widely
known. Therefore, it's improbable that much existing code relies on the
previous behavior.

Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
2023-12-22 10:32:46 +11:00
Maureen Helm 4fd54a4756 zephyr: Update include paths to use the zephyr namespace.
Zephyr v3.1.0 moved all public headers to include/zephyr.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-06-17 16:44:30 +10:00
Maureen Helm 1e5df0982a zephyr: Get UART console device from devicetree instead of Kconfig.
Updates the Zephyr port to get the UART console device from devicetree
instead of Kconfig. The Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME
was removed in Zephyr v2.7.0.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-06 14:09:39 +11:00
Maureen Helm f842e32155 zephyr: Const-ify struct device instance pointers.
Zephyr v2.4.0 added a const qualifier to usages of struct device to
allow storing device driver instances exclusively in flash and thereby
reduce ram footprint.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-09-30 23:21:53 +10:00
Maureen Helm 6aff27ac3c zephyr: Update to new zephyr timeout API.
Updates the zephyr port to use the new timeout api introduced in zephyr
2.3.
2020-06-12 10:24:54 +10:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Maureen Helm c25e12d0dd zephyr: Update include paths for Zephyr v2.0.
Zephyr restructured its includes in v2.0 and removed compatibility shims
after two releases in commit 1342dadc365ee22199e51779185899ddf7478686.
Updates include paths in MicroPython accordingly to fix build errors in
the zephyr port.

These changes are compatible with Zephyr v2.0 and later.
2020-02-04 17:09:19 +11:00
Damien George 05e0103e9e zephyr: Rename CONFIG_CONSOLE_PULL to CONFIG_CONSOLE_SUBSYS.
Following a similar change in the Zephyr Project.
2018-06-27 15:33:59 +10:00
Paul Sokolovsky 4514f073c1 zephyr: Switch to interrupt-driven pull-style console.
While this console API improves handling on real hardware boards
(e.g. clipboard paste is much more reliable, as well as programmatic
communication), it vice-versa poses problems under QEMU, apparently
because it doesn't emulate UART interrupt handling faithfully. That
leads to inability to run the testsuite on QEMU at all. To work that
around, we have to suuport both old and new console routines, and use
the old ones under QEMU.
2017-10-07 17:36:16 +03:00
Damien George 01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00