Wykres commitów

1629 Commity (master)

Autor SHA1 Wiadomość Data
Angus Gratton 68e0dfce0a all: Apply Ruff 0.11.6 reformatting changes.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-04-24 16:54:10 +10:00
Angus Gratton d887a021e8 top: Bump the Ruff version to 0.11.6.
With small code fixes to match.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-04-24 16:53:59 +10:00
Angus Gratton f8c8875e25 lora: Fix SNR value in SX126x received packets.
Wasn't being treated as a signed value.

Fixes issue #999.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-04-24 16:20:47 +10:00
Damien George 5b496e944e inspect: Implement iscoroutinefunction and iscoroutine.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-14 10:26:38 +10:00
Damien George 2665047fa7 inspect: Add basic unit tests.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-14 10:26:38 +10:00
Damien George 48bf3a74a8 inspect: Fix isgenerator logic.
Also optimise both `isgenerator()` and `isgeneratorfunction()` so they use
the same lambda, and don't have to create it each time they are called.

Fixes issue #997.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-14 10:26:38 +10:00
Matthias Urlichs 9307e21dfb usb-device-cdc: Optimise writing small data so it doesn't require alloc.
Only allocate a memoryview when the (first) write was partial.

Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
2025-04-13 13:27:47 +10:00
jomas 05a56c3cad aiohttp: Allow headers to be passed to a WebSocketClient.
This commit will make it possible to add headers to a Websocket.

Among other things, this allows making a connection to online MQTT brokers
over websocket, using the header entry "Sec-WebSocket-Protocol":"mqtt" in
the handshake of the upgrade protocol.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-13 00:20:58 +10:00
FuNK3Y 86df723301 aiohttp: Fix header case sensitivity.
According to RFC https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
header names are case-insensitive.

This commit makes sure that the module behaves consistently regardless of
the casing of "Content-type" and "Content-Length" (other headers are not
considered by the module).

Without this fix, the client seems to wait for the connection termination
(~10 seconds) prior to returning any content if the casing of
"Content-Length" is different.

Signed-off-by: FuNK3Y <fun__key@hotmail.com>
2025-04-12 10:51:31 +10:00
黃昕暐 43ad7c58fd requests: Use the host in the redirect url, not the one in headers.
The host in headers extracted from the original url may not be the same as
the host in the redirect url.  Poping out the host in headers force the
code to use the host in the redirect url, otherwise the redirect may fail
due to inconsistence of hosts in the original url and the redirect url.

Signed-off-by: 黃昕暐 <meebox@gmail.com>
2025-04-12 10:47:56 +10:00
Bas van Doren 42caaf14de unix-ffi/machine: Use libc if librt is not present.
Newer implementations of libc integrate the functions from librt, for
example glibc since 2.17 and uClibc-ng.  So if the librt.so cannot be
loaded, it can be assumed that libc contains the expected functions.

Signed-off-by: Bas van Doren <basvdoren@gmail.com>
2025-04-10 22:53:46 +10:00
Dominik Heidler d1a74360a2 unix-ffi/json: Accept both str and bytes as arg for json.loads().
Same as micropython's internal json lib does.

Fixes #985.

Signed-off-by: Dominik Heidler <dheidler@suse.de>
2025-04-10 22:46:28 +10:00
Leonard Techel f72f3f1a39 lora-sx126x: Fix invert_iq_rx / invert_iq_tx behaviour.
This commit fixes a typo and changes a tuple that needs to be mutable to a
list (because other parts of the code change elements of this list).

Signed-off-by: Damien George <damien@micropython.org>
2025-04-10 22:39:40 +10:00
Damien George 221a877f8a nrf24l10: Bump minor version.
Due to the previous three commits.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-10 22:33:53 +10:00
marcsello c7103bb464 nrf24l01: Optimize status reading.
The value of the STATUS register is always transmitted by the chip when
reading any command.  So a R_REGISTER command and the turnaround time can
be spared by issuing a NOP command instead.

This implementation suggested by the datasheet.

This operation is compatible with both nRF24L01 and nRF24L01+.

Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
2025-04-10 22:31:47 +10:00
marcsello bd1ab77324 nrf24l01: Properly handle timeout.
The timeout condition was not handled before.  Upon timeout, this caused
the chip to stay active until another send command changed it's state.

Sometimes when it was unable to transmit the data, it got stuck in the tx
fifo causing it to fill up over time, which set the TX_FULL flag in the
STATUS register.

Since there was no exceptions raised, the user code could not differentiate
a successful send or a timeout condition.

Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
2025-04-10 22:29:46 +10:00
marcsello 3e859d2118 nrf24l01: Increase startup delay.
According to the datasheet of the NRF240L1 chip, 150 μs startup time is
only acceptable when the chip is clocked externally.  Most modules use a
crystal, which require 1.5 ms to settle.  It should be okay to wait more in
both cases, for a reliable startup.

Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
2025-04-10 22:25:40 +10:00
Damien George 98d0a2b69a umqtt.simple: Restore legacy ssl/ssl_params arguments.
Commit 35d41dbb0e changed the API for using
SSL with umqtt, but only did a minor version increase.  This broke various
uses of this library, eg
https://github.com/aws-samples/aws-iot-core-getting-started-micropython

Reinstate the original API for specifying an SSL connection.  This library
now supports the following:
- default, ssl=None or ssl=False: no SSL
- ssl=True and optional ssl_params specified: use ssl.wrap_socket
- ssl=<SSLContext instance>: use provided SSL context to wrap socket

Signed-off-by: Damien George <damien@micropython.org>
2025-04-10 21:10:01 +10:00
Damien George 96e17b65d1 mip: Make mip.install() skip /rom*/lib directories.
If a ROMFS is mounted then "/rom/lib" is usually in `sys.path` before the
writable filesystem's "lib" entry.  The ROMFS directory cannot be installed
to, so skip it if found.

Signed-off-by: Damien George <damien@micropython.org>
2025-03-11 16:27:09 +11:00
Damien George 7337e0802a github/workflows: Update actions/upload-artifact to v4.
Because v3 is now deprecated.

Signed-off-by: Damien George <damien@micropython.org>
2025-02-24 14:28:14 +11:00
Glenn Moloney b379e4fb4c mip: Allow relative URLs in package.json.
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in https://github.com/micropython/micropython/pull/12477.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-24 14:23:06 +11:00
Damien George 7a32df3d13 requests: Bump version to 0.10.1.
The previous commit fixed a bug.

Signed-off-by: Damien George <damien@micropython.org>
2025-02-24 14:20:16 +11:00
Richard Weickelt 65a14116d5 requests: Do not leak header modifications when calling request.
The requests() function takes a headers dict argument
(call-by-reference). This object is then modified in the function. For
instance the host is added and authentication information. Such behavior
is not expected. It is also problematic:

- Modifications of the header dictionary will be visible on the caller
  site.
- When reusing the same (supposedly read-only) headers object for
  differenct calls, the second call will apparently re-use wrong headers
  from the previous call and may fail.

This patch should also fix #839. Unfortunately the copy operation does
not preserve the key order and we have to touch the existing test cases.

Signed-off-by: Richard Weickelt <richard@weickelt.de>
2024-12-12 00:27:39 +01:00
Damien George e4cf09527b unittest: Always use "raise" with an argument.
So this code can be compiled with the MicroPython native emitter, which
does not support "raise" without any arguments.

Signed-off-by: Damien George <damien@micropython.org>
2024-11-18 12:00:38 +11:00
Damien George 01047889eb unittest: Allow SkipTest to work within a subTest.
Signed-off-by: Damien George <damien@micropython.org>
2024-11-07 12:50:46 +11:00
Damien George 0827a31c07 tools/ci.sh: Enable unittest tests.
Signed-off-by: Damien George <damien@micropython.org>
2024-11-07 12:50:46 +11:00
Angus Gratton a0ceed8269 aioespnow,webrepl: Use recommended network.WLAN.IF_[AP|STA] constants.
Removes the deprecated network.[AP|STA]_IF form.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-07 12:48:55 +11:00
Prabhu Ullagaddi d6faaf8472 umqtt.simple: Add optional socket timeout to connect method.
If there are any network issues, mqtt will block on the socket
non-deterministically.  This commit introduces a `timeout` option which
can be used to set a finite timeout on the socket.  Upon any issue, mqtth
lib will throw exception.
2024-11-07 11:51:33 +11:00
Joris van der Wel 68e3e07bc7 aioble: Pass additional connection arguments to gap_connect.
This allows the following arguments to be passed to `device.connect()`:

* scan_duration_ms
* min_conn_interval_us
* max_conn_interval_us

These are passed as-is to `gap_connect()`.  The default value for all of
these is `None`, which causes gap_connect to use its own defaults.

Signed-off-by: Joris van der Wel <joris@jorisvanderwel.com>
2024-10-18 13:03:39 +11:00
Felix Dörre a7cd740b64 usb-device: Allow signaling capability of remote_wakeup.
To use this feature you need to create a usb device signaling remote wakeup
and then enable remote wakeup on the host (on linux write enabled to
/sys/bus/usb/devices/<device>/power/wakeup). Then you can wake up the host
when is on standby using USBDevice.remote_wakeup.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-10-18 12:54:48 +11:00
Jatty Andriean 7f5ac83865 lora-sx127x: Fix configuring the implicit header option in the _SX127x.
The `_reg_update` method must be called after updating the implicit header
option's bit.

Signed-off-by: Jatty Andriean <jandriea@outlook.com>
2024-10-18 12:33:23 +11:00
Damien George 394cbfc98a base64: Remove struct dependency from manifest.
This base64 library only uses `struct.unpack` which is available in the
built-in `struct` module, so no need for the micropython-lib extras.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-23 11:27:36 +10:00
Angus Gratton c61ca51c67 usb: Tidy up the description of TinyUSB callbacks.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-17 11:20:00 +10:00
Angus Gratton 01f45c118f usb: Add a note about buffer thread safety.
This is to replace a commit which added locking here but caused some other
problems. The idea behind the Buffer class is that a single producer can
call pend_write() more than once and it's idempotent, however this is very
complex to extend across multiple threads.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-11 17:13:53 +10:00
Angus Gratton 1d3c722b7d usb: Fix race if transfers are submitted by a thread.
The USB pending transfer flag was cleared before calling the completion
callback, to allow the callback code to call submit_xfer() again.

Unfortunately this isn't safe in a multi-threaded environment, as another
thread may see the endpoint is available before the callback is done
executing and submit a new transfer.

Rather than adding extra locking, specifically treat the transfer as still
pending if checked from another thread while the callback is executing.

Closes #874

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-11 17:13:53 +10:00
Angus Gratton 27e4d73bc2 umqtt.robust: Remove reference to missing example.
It looks like this example file was not added to the original commit back
in 6190cec14a.

Fixes issue #320.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-08 22:48:33 +10:00
Angus Gratton 1effa11c77 CONTRIBUTING: Add extra explanation of "Publish packages for branch".
I hadn't used this feature for a while, and realised there's one confusing
element of it not previously mentioned in the docs.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-08 16:02:22 +10:00
Damien George 66fa62bda1 tools/ci.sh: Add sqlite3 tests to CI.
Signed-off-by: Damien George <damien@micropython.org>
2024-08-22 13:10:35 +10:00
Damien George bea5367ce2 unix-ffi/sqlite3: Bump version to 0.3.0.
The previous commits fixed bugs and added new features.

Signed-off-by: Damien George <damien@micropython.org>
2024-08-22 13:10:35 +10:00
Robert Klink b77f67bd7c unix-ffi/sqlite3: Add commit and rollback functionality like CPython.
To increase the similarity between this module and CPythons sqlite3 module
the commit() and rollback() as defined in CPythons version have been
added, along with the different (auto)commit behaviors present there.
The defaults are also set to the same as in CPython, and can be changed
with the same parameters in connect(), as is showcased in the new test.

Signed-off-by: Robert Klink <rhermanklink@ripe.net>
2024-08-22 13:10:33 +10:00
Robert Klink 83598cdb3c unix-ffi/sqlite3: Change to use close and prepare v2 versions, clean-up.
The sqlite3_prepare and sqlite3_close have been changed to use the v2
version. For the prepare this was done as the v1 version is "legacy",
and for close the documentation describes the v2 version to be used for
"host languages that are garbage collected, and where the order in
which destructors are called is arbitrary", which fits here.

Some clean-up to comments has also be done, and the tests now also
close the Cursor and Connections.

Signed-off-by: Robert Klink <rhermanklink@ripe.net>
2024-08-22 13:09:33 +10:00
Robert Klink ab9c5a01b0 unix-ffi/sqlite3: Add optional parameter for URI support.
This commit adds the ability to enable URI on the connect, as can be done
in the cpython sqlite3 module. URI allows, among other things, to create
a shared named in-memory database, which non URI filenames cannot create.

Signed-off-by: Robert Klink <rhermanklink@ripe.net>
2024-08-22 13:09:33 +10:00
Robert Klink 0a65c3d34a unix-ffi/sqlite3: Fix statements not being finalized.
Currently, statements are only finalized upon a call to Cursor.close().
However, in Cursor.execute() new statements get created without the
previous statements being finalized, causing those to get leaked,
preventing the database from being closed. The fix addresses this by
finalizing the previous statement if it exists.

Signed-off-by: Robert Klink <rhermanklink@ripe.net>
2024-08-22 13:09:33 +10:00
Robert Klink 8d6ebf57a2 unix-ffi/sqlite3: Fix bytes to accommodate for different pointer sizes.
Currently, the bytes object used to store the sqlite3 database pointer
is always 4 bytes, which causes segfaults on 64 bit platforms with 8
byte pointers. To address this, the size is now dynamically determined
using the uctypes modules pointer size.

Signed-off-by: Robert Klink <rhermanklink@ripe.net>
2024-08-22 13:09:33 +10:00
Damien George 910af1889c tools/build.py: Add "path" entry to index.json.
This points to the package's base directory of the within the
micropython-lib directory structure.

Signed-off-by: Damien George <damien@micropython.org>
2024-08-20 16:35:25 +10:00
Max Holliday 60d137029f lora-sx126x: Change to class-level memoryview for _cmd buf.
Currently, the LoRa SX126x driver dynamically creates at least one,
sometimes two, memoryview objects with each call to `_cmd`.  This commit
simply provides the class with a long-lived memoryview object for `_cmd` to
easily slice as necessary.

Unlike the SX127x chips, Semtech unfortunately designed the SX126x modems
to be more command-centric (as opposed to directly setting registers).
Given the amount `_cmd` is called during normal device operation, even a
minor improvement here should have a decent impact.

Basic TX and RX tests pass on hardware.

Signed-off-by: Max Holliday <maholli@stanford.edu>
2024-07-23 15:12:50 +10:00
Damien George fbf7e120c6 usb-device-keyboard: Fix ; and ` keycode names.
They should be named as the un-shifted version.

Signed-off-by: Damien George <damien@micropython.org>
2024-07-03 17:21:55 +10:00
Angus Gratton 0a91a37563 usb-device-cdc: Fix lost data in read() path if short reads happened.
If the CDC receive buffer was full and some code read less than 64 bytes
(wMaxTransferSize), the CDC code would submit an OUT transfer with N<64
bytes length to fill the buffer back up.

However if the host had more than N bytes to send then it would still send
the full 64 bytes (correctly) in the transfer. The remaining (64-N) bytes
would be lost.

Adds the restriction that CDCInterface rxbuf has to be at least 64 bytes.

Fixes issue #885.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-07-03 17:17:38 +10:00
Jared Hancock b5aa5f0d1b logging: Fix StreamHandler to call parent constructor.
Otherwise there's a crash on line 70 where level is not a property of the
class unless explicitly set with `setLevel()`.
2024-07-03 17:04:39 +10:00
Andrew Leech 50ac49c42b unittest-discover: Avoid adding test parent dir to sys.path.
When running tests from subfolders, import by "full dotted path" rather
than just module name, removing the need to add the test parent folder to
`sys.path`.

This matches CPython more closely, which places `abspath(top)` at the start
of `sys.path` but doesn't include the test file parent dir at all.

It fixes issues where projects may include a `test_xxx.py` file in their
distribution which would (prior to this change) be unintentionally found by
unittest-discover.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-07-03 16:53:49 +10:00