Repository navigation
fix: preserve TP-7 MTP mode across commands - #4
Open
worm-emoji wants to merge 3 commits into
Open
worm-emoji wants to merge 3 commits into
worm-emoji wants to merge 3 commits into
Conversation
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.
What this PR does
The TP-7 has two USB personalities:
0x80190x0019File commands need to work across that boundary. With
--auto-connect, the CLI detects either personality, switches the recorder to MTP when necessary, opens its storage, performs the requested operation, and leaves it ready for the next command.The TP-7 also keeps its device-side MTP session alive after a short-lived CLI process exits. A later process can therefore receive
SessionAlreadyOpen, while sendingCloseSessionafter every command makes the recorder return to audio/MIDI mode. This PR gives the TP-7 a stable session ID throughmtp-rs0.32.0and usesreuse_existing_sessionso separate CLI processes can continue the same device-side session.Ordinary commands—including
connect,status,ls,tree,stat,pull,push,mkdir,rename, andrm—release their host USB handles without sendingCloseSession.tp7 ejectis the explicit operation that closes the MTP session and returns the recorder to audio/MIDI mode.On macOS,
ptpcameradcan claim the MTP interface before the CLI.tp7 ls --take-overnow retries after terminating a process only when IORegistry identifies that process as the exclusiveptpcameradowner of the TP-7 interface. It does not terminate FieldKit, OpenMTP, or unknown owners.The file-operation code uses the backend-neutral
mtp-rsobject, storage, transfer, and error APIs. MTP object and storage IDs are represented as opaqueu64values. The existing JSON keysvendor_extensionandfree_space_objectsremain present but arenull, because those protocol-specific values are not exposed by the high-level API.Result
tp7 ejectcleanly closes the session and returns the device to audio/MIDI modeptpcameradmtp-rs0.32.0Verification
cargo fmt -- --checkcargo checkcargo clippy -- -D warningscargo test— 44 tests passedcargo run -- ls --helpcargo run -- mkdir --helpcargo tree -i mtp-rs— resolvesmtp-rs v0.32.0A real TP-7 running firmware
2.5.7completed the generated-file hardware sequence in/library: recursive-push preflight, a 19-byte upload, overwrite to 31 bytes, two 25-byte directory uploads, metadata checks, and a cleanejectback to audio/MIDI mode. The three generated files were then explicitly removed. No existing recordings were read, rewritten, or deleted.