Skip to content
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

An alternative way to load peripherals information #8

Merged
merged 2 commits into from
Dec 9, 2023

Conversation

asimgunes
Copy link
Contributor

Hi,

This implementation contains a new ability to extend SVD Viewer to support not only SVD file format but also different formats. With this implementation the retrieving logic of the peripherals information separated from PeripheralTreeProvider class and extracted to a different class. In addition, a new parameter getPeripherals introduced, which enables svd-viewer to load the peripherals information from a different VSCode extension during the debug session by invoking the VSCode command defined in the getPeripherals launch parameter.

We believe this implementation provide a new ability to svd-viewer and we are kindly asking for review for this pull request. We also extend the documentation and provide a basic guideline for users to extend the svd-viewer by implementing their own VSCode plugins.

Kind regards.
Asim Gunes

@thegecko
Copy link
Contributor

@asimgunes this is a great idea!

Please be aware that this extension has now been upstreamed back to the original which has been separated at:

https://github.com/mcu-debug/peripheral-viewer

Both extensions still live in the marketplace, but I intend to deprecate this one once this issue is resolved:

mcu-debug/peripheral-viewer#8

Let me know if you want to keep this PR here, re-open it on peripheral-viewer or open it on both. I'm keen to not review it twice :)

Thanks!

@asimgunes
Copy link
Contributor Author

Hi @thegecko,

I am preparing a new pull request for https://github.com/mcu-debug/peripheral-viewer and planning to send it soon.

You can ignore this one.

Kind regards.

@thegecko
Copy link
Contributor

@asimgunes

I've re-opened this to get it merged here.

Did you consider exposing an API in this extension to hook into rather than accepting a command? That feels more structured, but I can see how your approach allows more control by the user (e.g. per-project)

@asimgunes
Copy link
Contributor Author

Hi @thegecko,

Thanks for returning me back, I think I didnot get the idea of providing an API here. Actually when I started I was trying somehow registering a loader and then try to use that loader here, however I wasn't successful then return back to command invocation as implemented here. But I am open for suggestions and changes here if you can explain a little bit more about your idea.

Some notes while this request was closed:

  1. I remember I optimised/fixed some parts of the code in peripheral-viewer request which are not reflected to this pull request, if you plan to merge this, let me change that part too.
  2. I think you are also moving this project to eclipse cdt, if you want I can provide the update to cdt project too. I can also provcide some sample code and after the migration we wouldnt need to make changes of the sample code too.

@thegecko
Copy link
Contributor

... if you can explain a little bit more about your idea.

For example, this extension returns an API you can interact with already:

https://github.com/eclipse-cdt-cloud/vscode-svd-viewer/blob/main/src/browser/extension.ts#L26

One approach could be to offer an extension point in that API for other file types and write an extension for your file type. e.g. expose in the API:

    ...
    registerFileParser(fileExtension: string, (filePath: Uri) => Promise<PeripheralNode[]>)),
    ...

which can be called with:

    ...
    <svdViewerApi>.registerFileParser('myEsvdExtension', async uri => {
        // do something with contents or uri and return node array
    });
    ...

I remember I optimised/fixed some parts of the code in peripheral-viewer request which are not reflected to this pull request, if you plan to merge this, let me change that part too.

yes please

I think you are also moving this project to eclipse cdt, if you want I can provide the update to cdt project too. I can also provcide some sample code and after the migration we wouldnt need to make changes of the sample code too.

already done (check the URL above!)

@asimgunes
Copy link
Contributor Author

Hi @thegecko,

Ok, let me check the api suggestion while checking the pull request again. it seems a better solution.

@asimgunes asimgunes closed this Oct 25, 2023
@asimgunes asimgunes reopened this Oct 26, 2023
@asimgunes asimgunes changed the title An alternative way to load peripherals information (with getPeripherals) An alternative way to load peripherals information Oct 26, 2023
@asimgunes
Copy link
Contributor Author

Hi @thegecko,

I re-visit my previous implementation and changed the integration points to work over the extension api. Could you please re-check the implementation when you are available?

@thegecko
Copy link
Contributor

thegecko commented Oct 30, 2023

Thanks @asimgunes let me check it out!

Do you have an example non-svd file I can test?

Copy link
Contributor

@thegecko thegecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well for me, nothing seems broken!

I've added a few comments about structure and exposing the API and a few styling nits.

Could you also check your formatting and indentation for the new/modified files?

docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docs/appendix-types.md Outdated Show resolved Hide resolved
src/desktop/extension.ts Outdated Show resolved Hide resolved
src/export.ts Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
src/views/peripheral.ts Outdated Show resolved Hide resolved
src/views/peripheral.ts Outdated Show resolved Hide resolved
@asimgunes
Copy link
Contributor Author

Hi @thegecko,

I made changed related to your suggestions. There could be slight differences related to implementation details. Could you check the latest implementation in your suitable time?

This is what Arm do for the cmsis extension:

https://www.npmjs.com/package/@arm-software/vscode-cmsis-csolution

Also, example about the "cmsis extension" is interesting and I can contribute for similar approach for this extension, but we need a new repository for this implementation. Additonally, it might be logical to move the type definitions and some utility functions might be useful for users, and then reference the package in svd-viewer to avoid duplication as you mentioned in this code review. But I also prefer merging the changes up to now and leaving that work for another pull request. Is it suitable for you?

@asimgunes asimgunes requested a review from thegecko November 8, 2023 15:48
Copy link
Contributor

@thegecko thegecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started renaming SVD Viewer and svd-viewer to their new equivalents but gave up after so many comments. Can you do this in the PR? :)

Please also rebase on main and check all still compiles and works for you

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
docs/extending-svd-viewer.md Outdated Show resolved Hide resolved
@asimgunes asimgunes force-pushed the NonSVD branch 9 times, most recently from ae31f61 to 31d5899 Compare November 24, 2023 15:22
@asimgunes
Copy link
Contributor Author

Hi @thegecko,

I rebased and update the request as the name of the package changed. Could you please review again in your suitable time?

You may observe that I have additional updates. There is an additional api.ts at the root folder and types are now imported from 'peripheral-inspector/api' as you can also see in the documentation. This change comes because previously I missed the scenario that if the package installed directly from Github, there is no dist folder in it, which is causing import problem. For a workaround, I added api.ts file into the root, but still keep the actual definition file under the src folder. In long term, I think we need a separate package that includes API information like you previously mentioned about the ARM cmsis extension, but I like to leave this work to another (follow-up) update, and if you agree, merge this with the current state. Please let me know your thoughts, I am looking forward to hear them.

@asimgunes asimgunes requested a review from thegecko November 24, 2023 15:50
Copy link
Contributor

@thegecko thegecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some indentations are wrong, but that's a minor niggle which can be addressed separately.
I also think we can make the API better by using GitHubs own npm registry. I'll craft a follow on PR to discuss that.
I'll merge this once I've done a final test locally.

src/api-types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@thegecko thegecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so this fails to run with svd files. please accept the suggestions and all should be well. You could also check the indentation in the api-types file ;)

src/api-types.ts Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@asimgunes
Copy link
Contributor Author

asimgunes commented Dec 7, 2023

Hi @thegecko, thanks for your comments, I am going to check the suggestions soon and planning to return you by tomorrow. Kind regards.

@asimgunes
Copy link
Contributor Author

Hi @thegecko,

I made the changes, could you please check it again when you are suitable?

Thanks.

@asimgunes asimgunes requested a review from thegecko December 8, 2023 09:54
Copy link
Contributor

@thegecko thegecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thegecko thegecko merged commit 34fb39b into eclipse-cdt-cloud:main Dec 9, 2023
4 checks passed
@thegecko
Copy link
Contributor

thegecko commented Dec 9, 2023

Released in v1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants