Coder Social home page Coder Social logo

Comments (15)

ReinhardKeil avatar ReinhardKeil commented on June 9, 2024

This is actually possible. You can use both API's at the same time in one project and migrate overtime to API2. You just need to select both CMSIS:RTOS:Keil RTX5 and CMSIS:RTOS2:Keil RTX5 in the project.

We will explain this better in the documentation

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

You can use both API's at the same time

I did not try this in a project, but visually inspecting the header files does not confirm your statement, it looks like you use functions with the same name but with different prototypes in the two headers, which, in a language without namespaces, like C, is not possible.

for example, in RTOSv1 you have:

osStatus osThreadYield (void);

and in RTOSv2 you have:

osStatus_t osThreadYield (void);

with osStatus completely different from osStatus_t.

ideally, for an easy migration, you should be able to include both headers in a file, work on the changes, and remove the legacy header when ready, but with different prototypes, the compiler should complain.

the second choice would be to be able to include the old header in one file and the new header in another file, but having functions with the same name in the two implementations will make the linker complain.

I'm afraid your design does not provide a convenient migration path from cmsis_os.h to cmsis_os2.h.

the label DONE attached to this ticket is not accurate.

from cmsis_5.

RobertRostohar avatar RobertRostohar commented on June 9, 2024

with osStatus completely different from osStatus_t

Not completely different:
osStatus is defined as int32_t and osStatus_t as enum.

This allows mixing old and new API if needed during migration.

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

did you manage to include both versions in the same project?

from cmsis_5.

RobertRostohar avatar RobertRostohar commented on June 9, 2024

Yes,. a simple example which shows just compilation (no functionality):

#include "cmsis_os.h"

static osStatus    Status0;     // Old API
static osStatus_t  Status;      // New API

void test (void) {

  Status  = osThreadYield();
  Status0 = osThreadYield();
  switch (Status0) {            // Old API
    case osOK:
    case osEventSignal:
    case osEventMessage:
    case osEventMail:
    case osEventTimeout:
    case osErrorOS:
    case osErrorTimeoutResource:
    case osErrorResource:
    case osErrorParameter:
    case osErrorNoMemory:
    case osErrorISR:
    case osErrorISRRecursive:
    case osErrorPriority:
    case osErrorValue:
      break;
    default:
      break;
  }
  switch (Status) {             // New API
    case osOK:
    case osError:
    case osErrorTimeout:
    case osErrorResource:
    case osErrorParameter:
    case osErrorNoMemory:
    case osErrorISR:
      break;
    default:
      break;
  }
}

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

sorry, but I'm not able to follow you. how can you have two version of the osThreadYield() function in the same project, one from v1 and one from v2?

from cmsis_5.

RobertRostohar avatar RobertRostohar commented on June 9, 2024

Function and it's implementation is the same (V2) however it can be used with V1 user code.

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

Function and it's implementation is the same

are you sure? how can it be the same if each version returns different values? for example the v1 version returns 0x82 if called from an ISR, and the v2 version returns -6 in the same case.

or, in my case, I have a C wrapper that defines all v1 functions on top of CMSIS++, and apparently I have to add a separate wrapper for the v2 functions; I don't see how it can be the same if functions with the same name behave differently in the two versions.

from cmsis_5.

RobertRostohar avatar RobertRostohar commented on June 9, 2024

osErrorISR is defined in cmsis_o2.h as -6. Updated cmsis_os.h does not define it at all when using it in V2 environment. While osErrorISR value has changed between implementations the user code which uses the define should have no issues unless the value was used directly as a number.

Updated cmsis_os.h only defines incompatible values (osEventXxx) and maps different names (ex: osErrorOS vs osError). This insures the compatibility for majority of cases. There are however minor incompatibilities (ex: V2 implementation will return osErrorParameter when V1 returned osErrorValue).

Compatibility module handles the incompatible functions (Create, functions that returned osEvent …)

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

While osErrorISR value has changed between implementations the user code which uses the define should have no issues unless the value was used directly as a number.

hmmm...

in #1 we had a dispute on priority numbers, and you justified the design by the need to preserve compatibility with binary libraries.

now I debate your new solution exactly with your own arguments: how can you use binary libraries based on v1 in a project migrated to v2?

from cmsis_5.

RobertRostohar avatar RobertRostohar commented on June 9, 2024

#1 was about binary compatibility between different implementations for the same API version.

There is no binary compatibility between V1 and V2 project. Code needs to be recompiled when migrating.

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

For completeness, I think that mandating for binary compatibility between different implementations for the same API version is too limiting and should be avoided; source code compatibility should be enough and binary distributions should be accompanied by a source file to be compiled with the actual implementation header.

from cmsis_5.

ReinhardKeil avatar ReinhardKeil commented on June 9, 2024

we have verified that migration works in practice and the process is described here:
http://arm-software.github.io/CMSIS_5/RTOS2/html/os2MigrationGuide.html#MigL2

CMSIS-RTOS1 was not binary compatible and we never claimed that as every implementation could have a different cmsis_os.h.

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

ok, if you handled all details, it should be ok.

from cmsis_5.

ReinhardKeil avatar ReinhardKeil commented on June 9, 2024

no further activity

from cmsis_5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.