-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
OS Target information for shared frameworks #414
OS Target information for shared frameworks #414
Comments
All that is pretty much available today. You can find it here. Having said that, one of the major mantras in nanoFramework is "write once run everywhere".
How this works?
I understand what you are trying to accomplish here. Despite theoretically it won't hurt to add more details (such as CPU, etc) to the Am I making sense to you? 😄 |
I can see the need for targeting the correct io pins etc. it would be incredibly useful to have a "model" field for each type of board so that pins could be mapped correctly without creating a different app for each board |
@networkfusion I guess you can always abstract that pin mapping... But, ultimately, this will be hardware dependent and you either 1) always use the same pins for that feature 2) end up having to map that somehow... An example of kind-of-standard is the BLUE push button for STM32 boards. It's connected to PA0 on 100% of the boards (as far as I remember/know). BUT for the LED's that's a totally different matter!! Those bump into differente packaging making the pin name being mapped into different hardware pin (and vice-versa), the fact that a particular pheripheral is taking precedence over a simple GPIO (e.g. SPI1 has to use that pin) so the LED moves to the next now, etc... hard to accomplish if you ask me.... |
I guess I am used to using the existing .NET Framwork/UWP classes for the information and did not look at non-framework API's.
That almost never happens. Even in the .NET Framework that MS has spent YEARS on, you still have cases where app code has to work around subtly differences that are out of the control of the framework vendors,
The issue may not be at the low level that the native code can fix. It could be that to correctly use a certain feature in a certain way, you have to do things in a specific order. Ir one board has a 12 bit ADC and another has a 10 bit. Its not up to the board to conform to the lowest setting. But a driver may know how to correct for it. But, as long as you have the ability already in the firmware someplace, thats all that is needed. I would just suggest to try and map the functionality to existing .NET Framework classes and expand from them. Roy |
Hi all, why not use the DeviceCode from the Device_Block for this (maybe expand with a couple of vals). This is by Device anyhow. Leaves the question where that enum is populated from. Plus the board name is known and even populated. All I want to say is that most info is already there, duplicating stuff and try to keep it in sync and being dynamic too will be challenging. So I suggest to use the already available basics and expand on it. |
There are 3 parts to this problem:
The answers, as far as I understand are:
Given that we have flash and RAM constraints, it is not a good idea to pack code for multiple different processors within the same assembly. At best, the assembly/library implementor can put checks on which platform the library is designed to run on. |
I agree with @piwi1263 the best way is to expand on the existing SystemInfo class. But this method can only be used for nanoframework targets it can't be used for different frameworks as suggested by @RoySalisbury. As soon as you put something in that's is not supported on a particular framework it will no longer compile on all frameworks. You would have to create dummy versions of missing functions to just get it to compile. The only way for different frameworks is to use #if / #else / #endif in your code. |
At the moment I'm using below kind of generic code to cover some basics, so it is already avail in a limited way:
We have to convince the ESP32 side to follow the STM side or agree on something.... Or are we looking at the re-birth of the HardwareProvider ? |
Being able to differentiate one target from another has always to "start" from the image, at build time. I very much doubt that we could/should keep an enum with all possible targets. I mean we can force others to "register" their targets on a central registry. Or if this is tosed to the manged side, we'll end up with a even most awkward situation of having different assemblies (nanoFramework.Native possibly) with different enums. This is because we have our reference targets, we have to add the community targets, I would want to add the targets that my company will work on, Roy theirs and so on. Pretty quick this will become unmanageable!! 😓 The various properties that are in the SystemInfo class, which I started to point out and that @piwi1263 detailed seem to be the place for this. It seems to me that there are plenty of properties there to be the placeholders for all this. Most of those are empty today. An OEM is free to use them as it sees fit. Taking a step furhter I even suggest that using string data and parse those in the C# app is the most straightforward approach. If people think that's important to access detail such CPU type we can look into adding that. |
I would suggest, that whatever gets exposed publicly, should be implemented in the classnames of the already existing .NET Framework. I would take a look at both the "RuntimeInformation" and "Environment" classes. These have a lot of the properties being discussed here and it's where someone would naturally look if already familiar with the .NET Framework. Its not an exact one-to-one match, But some of its there. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
If there is already a mechanism in place for this, please let me know. I did not see one, so am proposing this.
If within my own library I want to support multiple target devices (ESP32 and NetDuino) because each might have just a bit different way of doing something, I have no way of knowing what target I am running on.
Following the classes written in the .NET Framework, but modified for the smaller scale, I have implemented the "System.Runtime.InteropServices.RuntimeInformation" class. I removed the OSProcessor and OSArchitecture properties, and added a simpler OSTarget enum.
Each target platform would need to implement 2 native calls:
string NativeOSDescription()
int NativeOSTarget()
The OSTarget would be the following
I just took these values form the target list on the home page for the project. They could actually be anything. But using something that the target is commonly known by would be best.
Then within my shared library I could write (this is just a made up example)
Anything in the "NativeMethods" would need to be available in the core firmware. However, something like this needs nothing extra from the firmware.
Now I can deploy a single NuGet package that can support multiple targets.
I have the initial code here if you want to take a look at what it would take.
https://github.com/RoySalisbury/lib-CoreLibrary/tree/develop/source/System/Runtime/InteropServices/RuntimeInformation
Could even add the Processor and Architecture back if you want. So you could have:
Processor: RISC ARM
Archecurre: Cortex-M7F
Or whatever.
The text was updated successfully, but these errors were encountered: