Repository navigation
Conversation
mpremote reads a file 256 bytes at a time as print(repr(r(256))) and parses
the line with ast.literal_eval. A P4 DEV-KIT on its native USB sometimes sends
more than it printed: after the closing quote come the zero padding of the
string's memory and, now and then, the 16-byte header of the string object
next to it (a type pointer, hash, length and data pointer), whose first byte
is 0x04 and ends the reply early. Reading a 2.8 MB model failed that way on
three runs out of three ("source code string cannot contain null bytes", and
once with the reply framing lost), at 47 KB, 750 KB and 2.9 MB, with the board
running nothing else. The bytes inside the quotes were right each time.
Serial transports now read a file with an explicit seek per chunk, parse only
the first line, check the length, and read the chunk again (after a clean
return to the raw REPL prompt) when it is wrong.
Collaborator
Author
|
Reopened from a branch with a corrected commit message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A P4 DEV-KIT (ESP32-P4, native USB CDC) sometimes sends more than it printed. mpremote's
fs_readfileasks forprint(repr(r(256)))and parses the reply withast.literal_eval; on this board the reply can carry, after the closing quote, the zero padding of the string's memory and sometimes the 16-byte header of the string object next to it. The header starts with0x04, which ends the reply early.getof a 2.8 MB model failed with "source code string cannot contain null bytes" on three runs in a row (at 47 KB, 750 KB and 2.9 MB). The bytes inside the quotes were right every time.Serial transports now read each chunk after an explicit
seek, parse only the first line, check its length, and ask again after a clean return to the raw REPL prompt when it is wrong. A chunk that never comes right fails with the byte offset.cli/tests/test_read_file_checked.pyfeeds the reader a board that appends zeros, appends the object header with its0x04, and cuts a reply short. mpremote's ownfs_readfilefails the first of these with the same "null bytes" error.