On slow machines, udev rules may not have finished processing by the time
we try to open the USB device. This causes a SecurityError, so we add a
retry loop to handle this case.
Closes: https://github.com/pybricks/support/issues/2372
This operation does not work on Windows, and does not appear to be
crucial on other platforms either. The browser seems to already handle
resetting the endpoints as needed when connecting or closing the browser
(at least on Linux)
Add a function to pad EV3 firmware size to avoid potentially triggering
bugs in the EV3 bootloader. When we do a download command with too small
of a payload, the bootloader can send a bad response. We can work around
this by ensuring that the firmware size is such that the last chunk is
the maximum size. This way we never send a small chunk that could
trigger the bug.
Add an extra progress between erasing and writing. This makes the
progress not stall for quite as long before progressing when flashing
smaller firmwares.
Change from erasing 1 sector at a time to erasing 2 sectors at a time.
This works around a USB issue where commands that don't take long to
execute can receive an incorrect response.
The point of erasing 2 sectors at a time is that when we write the data
to the sectors that we just erased, the last (partial) chunk of data is
now twice as large, which makes it take twice as long to write. This
seems to be long enough to avoid the USB issue.
Add a hack to not fail if the EV3 bootloader sends an echo of the request
instead of the expected response. There is a known compatibility issue
with the EV3 bootloader USB and, e.g. Windows with USB 3.0 ports. This
apparently causes a race condition where commands that don't take long
to process before sending a response will have the request echoed back
instead of receiving the actual response. If this happens, we can
ignore it and assume the command was successful. It just won't work, e.g.
for the version command since that has a payload in the response.
This hasn't been used for a long time in Pybricks Code. We're only keeping it in the firmware because Pybricks Code raises an error otherwise.
Disabling it saves about +400 bytes on Move Hub and Technic Hub and helps simplify the firmware. By removing it we don't run untested code if someone connects to the advertised NUS service.
Remove didStart and didFinish actions from firmware flashing sagas as
they are not used for anything.
didFailToFinish is not so easily removed as it is used to trigger error
toasts.
Add some calls to hide the progress toasts when an error occurs during
firmware flashing. Without this, the toasts would remain visible even
after the error alert was shown.
For some reason, the type checker doesn't catch this, but
FailToFinishReasonType.Unknown requires an error argument, otherwise
we get an unhandled exception.
Dispatch an error in case there is no firmware URL. Normally this should
never happen, but currently it does because we don't have EV3 firmware
yet. The error is more useful than just spinning forever.
Basic support for restoring the official EV3 firmware. Is missing a video
and needs a bunch of helpful error messages, but basic functionality
is working.
This is just the UI bits (new file template, Pybricks firmware install,
official firmware restore).
The Pybricks firmware flashing hangs because we don't have a EV3 firmware
yet in @pybricks/firmware. Official firmware restore has an alert()
placeholder so at least it does something.
Rename the requested program ID from slot to progId and the running
program ID to runningProgId. These can also have the value of built-in
programs, not just slot numbers, so it doesn't make sense to call them
slots.
I meant to change this before merging the previous commit, but missed it.
The mismatch test was hard to understand and didn't increase coverage,
so let's leave it out.
* Update for changed StartUserProgram command semantics
* Added new capability flags and fixed-purpose slot definitions
* Update for new start REPL command
* Updated StartUserProgram command and Status event for slots
* Added new AppData command and event
---------
Co-authored-by: David Lechner <david@pybricks.com>
Enable the stream option on the text decode for the stdout and uart
stream handlers that pipe data to the terminal. This fixes improperly
printing multibyte unicode characters that get split across multiple
data packets.
A new decode is added for each different stream in case both are used
at the same time.
Fixes: https://github.com/pybricks/support/issues/1743