lancaster-university / codal-microbit-v2

CODAL target for the micro:bit v2.x series of devices
MIT License
43 stars 52 forks source link

How can a program get the CODAL version? #138

Closed martinwork closed 2 months ago

martinwork commented 3 years ago

microbit_dal_version() is declared but not implemented. MICROBIT_DAL_VERSION is given a default value in config.h but not set to a useful version in the build.

martinwork commented 3 years ago

There's CodalDevice::getVersion() which returns DEVICE_DAL_VERSION, but that also seems to be "unknown".

microbit-carlos commented 1 year ago

This is needed for the next firmata release, so we need to prioritise it.

microbit-carlos commented 1 year ago

@JohnVidler once this is implemented we need to add it to test it in the firmata project:

microbit-carlos commented 6 months ago

Should be fixed with these two PRs:

The only disadvantage is that this would not work when the codal.json file has target.dev set.

This will also be useful to be able to check on MakeCode tests deployments what CODAL version the cloud compiler is using.


As a side note, these lines in codal-core CMakeLists.txt are pretty much useless as nothing in any of the CODAL repos use CODAL_VERSION_STRING or CODAL_VERSION. It's likely something brought over from Yotta that was never really used: https://github.com/lancaster-university/codal-core/blob/992c0b11a0eb2a1edca9c2f76821f89a99a3acec/CMakeLists.txt#L9-L17

JohnVidler commented 6 months ago

I've prototyped a better CODALVERSION* definition set over in feature/versionable in codal-core: https://github.com/lancaster-university/codal-core/compare/master...feature/versionable

This should check the tag/branch/hash version of the target rather than core itself, so we should get sensible values back.

If this is merged into master, we can then use the generated definitions in microbit_dal_version() and friends and have this fixed everywhere.

Comments welcome.

JohnVidler commented 5 months ago

Created a PR for this over in https://github.com/lancaster-university/codal-core/pull/169 - which adds better version symbol handling.

microbit-carlos commented 2 months ago

These two PRs has been merged and this issue can be closed as "completed":

These get the provided defines and function outputs:

CODAL_VERSION_MAJOR: 0
CODAL_VERSION_MINOR: 2
CODAL_VERSION_PATCH: 66
CODAL_VERSION_HASH: 8c8db00
CODAL_TARGET_NAME: codal-microbit-v2
CODAL_VERSION: 0.2.66
CODAL_VERSION_LONG: 0.2.66+codal-microbit-v2-8c8db00
DEVICE_DAL_VERSION: 0.2.66
MICROBIT_DAL_VERSION: 0.2.66
microbit_dal_version(): 0.2.66
uBit.getVersion(): 0.2.66