forked from tock/tockloader-rs
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: reshuffle_apps #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
addrian-77
wants to merge
8
commits into
main
Choose a base branch
from
add/reorder-apps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: reshuffle_apps #103
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ed89811
feat: reshuffle apps + generalizaiton
addrian-77 d9c0012
refactor: separated IO Commands
addrian-77 a289e61
wip: restructure reshuffle_apps
eva-cosma 66965d1
wip: refactored reshuffle
addrian-77 285bd61
refactor: remove read_binary
addrian-77 26e5438
refactor: move settings inside connection
addrian-77 42fbaf8
refactor: change vec to slice inside write function
addrian-77 8b608af
wip
addrian-77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| use async_trait::async_trait; | ||
|
|
||
| use crate::connection::{Connection, TockloaderConnection}; | ||
| use crate::errors::TockloaderError; | ||
| use crate::{CommandEraseApps, IO}; | ||
|
|
||
| #[async_trait] | ||
| impl CommandEraseApps for TockloaderConnection { | ||
| async fn erase_apps(&mut self) -> Result<(), TockloaderError> { | ||
| self.write(self.get_settings().start_address, &[0u8]) | ||
| .await | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,41 @@ | ||
| use async_trait::async_trait; | ||
|
|
||
| use crate::attributes::app_attributes::AppAttributes; | ||
| use crate::attributes::general_attributes::GeneralAttributes; | ||
| use crate::board_settings::BoardSettings; | ||
| use crate::attributes::system_attributes::SystemAttributes; | ||
| use crate::connection::TockloaderConnection; | ||
| use crate::errors::TockloaderError; | ||
| use crate::tabs::tab::Tab; | ||
| use crate::{CommandEraseApps, CommandInfo, CommandInstall, CommandList}; | ||
| use crate::{IOCommands, IO}; | ||
|
|
||
| #[async_trait] | ||
| impl CommandList for TockloaderConnection { | ||
| async fn list( | ||
| &mut self, | ||
| settings: &BoardSettings, | ||
| ) -> Result<Vec<AppAttributes>, TockloaderError> { | ||
| impl IO for TockloaderConnection { | ||
| async fn read(&mut self, address: u64, size: usize) -> Result<Vec<u8>, TockloaderError> { | ||
| match self { | ||
| TockloaderConnection::ProbeRS(conn) => conn.list(settings).await, | ||
| TockloaderConnection::Serial(conn) => conn.list(settings).await, | ||
| TockloaderConnection::ProbeRS(conn) => conn.read(address, size).await, | ||
| TockloaderConnection::Serial(conn) => conn.read(address, size).await, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl CommandInfo for TockloaderConnection { | ||
| async fn info( | ||
| &mut self, | ||
| settings: &BoardSettings, | ||
| ) -> Result<GeneralAttributes, TockloaderError> { | ||
| async fn write(&mut self, address: u64, pkt: &[u8]) -> Result<(), TockloaderError> { | ||
| match self { | ||
| TockloaderConnection::ProbeRS(conn) => conn.info(settings).await, | ||
| TockloaderConnection::Serial(conn) => conn.info(settings).await, | ||
| TockloaderConnection::ProbeRS(conn) => conn.write(address, pkt).await, | ||
| TockloaderConnection::Serial(conn) => conn.write(address, pkt).await, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl CommandInstall for TockloaderConnection { | ||
| async fn install_app( | ||
| &mut self, | ||
| settings: &BoardSettings, | ||
| tab_file: Tab, | ||
| ) -> Result<(), TockloaderError> { | ||
| impl IOCommands for TockloaderConnection { | ||
| async fn read_installed_apps(&mut self) -> Result<Vec<AppAttributes>, TockloaderError> { | ||
| match self { | ||
| TockloaderConnection::ProbeRS(conn) => conn.install_app(settings, tab_file).await, | ||
| TockloaderConnection::Serial(conn) => conn.install_app(settings, tab_file).await, | ||
| TockloaderConnection::ProbeRS(conn) => conn.read_installed_apps().await, | ||
| TockloaderConnection::Serial(conn) => conn.read_installed_apps().await, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl CommandEraseApps for TockloaderConnection { | ||
| async fn erase_apps(&mut self, settings: &BoardSettings) -> Result<(), TockloaderError> { | ||
| async fn read_system_attributes(&mut self) -> Result<SystemAttributes, TockloaderError> { | ||
| match self { | ||
| TockloaderConnection::ProbeRS(conn) => conn.erase_apps(settings).await, | ||
| TockloaderConnection::Serial(conn) => conn.erase_apps(settings).await, | ||
| TockloaderConnection::ProbeRS(conn) => conn.read_system_attributes().await, | ||
| TockloaderConnection::Serial(conn) => conn.read_system_attributes().await, | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| use async_trait::async_trait; | ||
|
|
||
| use crate::attributes::general_attributes::GeneralAttributes; | ||
| use crate::connection::TockloaderConnection; | ||
| use crate::errors::TockloaderError; | ||
| use crate::{CommandInfo, IOCommands}; | ||
|
|
||
| #[async_trait] | ||
| impl CommandInfo for TockloaderConnection { | ||
| async fn info(&mut self) -> Result<GeneralAttributes, TockloaderError> { | ||
| let installed_apps = self.read_installed_apps().await.unwrap(); | ||
| let system_atributes = self.read_system_attributes().await.unwrap(); | ||
| Ok(GeneralAttributes::new(system_atributes, installed_apps)) | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| use async_trait::async_trait; | ||
|
|
||
| use crate::attributes::app_attributes::AppAttributes; | ||
| use crate::command_impl::reshuffle_apps::{create_pkt, reshuffle_apps, TockApp}; | ||
| use crate::connection::{Connection, TockloaderConnection}; | ||
| use crate::errors::TockloaderError; | ||
| use crate::tabs::tab::Tab; | ||
| use crate::{CommandInstall, CommandList, IO}; | ||
|
|
||
| #[async_trait] | ||
| impl CommandInstall for TockloaderConnection { | ||
| async fn install_app(&mut self, tab: Tab) -> Result<(), TockloaderError> { | ||
| let settings = self.get_settings(); | ||
| let app_attributes_list: Vec<AppAttributes> = self.list().await.unwrap(); | ||
| let mut tock_app_list = app_attributes_list | ||
| .iter() | ||
| .map(TockApp::from_app_attributes) | ||
| .collect::<Vec<TockApp>>(); | ||
|
|
||
| // obtain the binaries in a vector | ||
| let mut app_binaries: Vec<Vec<u8>> = Vec::new(); | ||
|
|
||
| let mut address = settings.start_address; | ||
| for app in app_attributes_list.iter() { | ||
| app_binaries.push( | ||
| self.read(address, app.tbf_header.total_size() as usize) | ||
| .await | ||
| .unwrap(), | ||
| ); | ||
| address += app.tbf_header.total_size() as u64; | ||
| } | ||
|
|
||
| let mut app = TockApp::from_tab(&tab, &settings).unwrap(); | ||
|
|
||
| app.replace_idx(tock_app_list.len()); | ||
| tock_app_list.push(app.clone()); | ||
|
|
||
| app_binaries.push(tab.extract_binary(settings.arch.clone().unwrap()).unwrap()); | ||
|
|
||
| let configuration = reshuffle_apps(&settings, tock_app_list).unwrap(); | ||
|
|
||
| // create the pkt, this contains all the binaries in a vec | ||
| let pkt = create_pkt(configuration, app_binaries); | ||
|
|
||
| // write the pkt | ||
| let _ = self.write(settings.start_address, &pkt).await; | ||
| Ok(()) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.