473 views
in System Integration by

Dear all,

We are implementing a UI who have a lot of things to be set based on parameters coming from the Device.
As an example the Gauges need to set it's value, it's background color and view-state (enabled or disabled) based on some information coming from the Device directly. 

We have see the examples of the integration (DeviceDrivers) which uses standard method with integer parameters. Doing this for every single gauge we have on the project will results in having a lot of method per each single gauge.
We was looking at an optimized way to pass parameters to the update method, like by using structs.


Is it possible to pass a struct (with all the data) instead of a list of parameter? 

We tried to add a Chora Class and pass it as parameter but when wen we instance a variable of the struct that has been translated from Chora to C, seems it need to be initialized (but we don't know how).

 

ApplicationProvaDavide tst;
uint8_t workerQueue_GUISide(void)
{
    osStatus_t retQueue ;
    mw_update_message msg;

    retQueue = osMessageQueueGet( queueGUI, &msg, NULL, 0U);
    if ( retQueue == osOK )
    {
      ApplicationMiddlewareClass  homepage = EwGetAutoObject( &ApplicationaoMiddleware,  ApplicationMiddlewareClass );
      
      if ( homepage != NULL )
      {
        switch ( msg.subject )
        {
          case UPDATE_GAUGE :
          {

            
            
            tst->Variable = 30;
            tst->Variable1 = 40;
            tst->Variable2 = 50;
            
              
            
            ApplicationMiddlewareClass__MethodDAVIDE( homepage, tst );
            testVAL++;
            if ( testVAL == 100 )
              testVAL = 0;
          }
          break;
          
 
        }
      }
      return 1;
    }
    return 0;
}

 

basically the tst variable have wrong addresses in memory due to a missing initialization at our side (in my opinion), and when we try to change the "Variable" fields, the value is not updated.
The queue , de-queue the message and trigger the operations at the EwProcess function side so it's within the same thread. Other thread just enqueue messages.

Is there any good way to do what we're trying to do? Is it safe?

 

Thanks
Davide

1 Answer

0 votes
by

Hallo Davide,

We have see the examples of the integration (DeviceDrivers) which uses standard method with integer parameters. Doing this for every single gauge we have on the project will results in having a lot of method per each single gauge.
We was looking at an optimized way to pass parameters to the update method, like by using structs.

Passing complete C structs to a Chora method as parameter is not possible. You can, however, adapt the respective Update method so that it accepts more than one parameter. For example, you could implement in the Device Driver class some UpdateGauge() method with three parameters: Value, BackgroundColor and State. Then the method can be invoked from C code providing to it all the three values at once.

We tried to add a Chora Class and pass it as parameter but when wen we instance a variable of the struct that has been translated from Chora to C, seems it need to be initialized (but we don't know how).

This is a possible approach to implement a Chora class serving as data container and pass an object of this class in the invocation of a method. In Chora objects are passed via reference. Usually, you would implement such class to contain variables and arrays only. In the variables/arrays you store all the data you want to pass. In the C code you create an instance of the class, initialize its variables/arrays and then you pass this instance in the parameter when invoking an Update method of the Device Driver object. The declaration of the Update method need to be adapted so that it accepts instances of the of the data class.

This approach, however, expects some deeper understanding of how Chora objects are working and consequently it is officially not documented. Anyway, if you prefer this approach, the best would to implement the respective code in Chora, then analyze the resulting generated code. In this way you learn how to create/initialize Chora objects in C code.

Does it help you?

Best regards

Paul Banach

by
Hi Paul

 

Thanks for your answer.
Well, my concern was that function with more than 2 parameters, usually (depending on the compilers) allocate the address of the variables in the Rx register of the ARM Mcu, while if you exceed the others goes into stack (which is more easily corruptible).

I think we'll follow your first suggestion, i don't want to be in a situation with future updated which my prevent me to keep the code maintaniable.

Maybe as a suggestion for future versions we can work out a sort of Chora object which can be adapted as the above mentioned discussion we had.

 

Thanks again for your support

Davide

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...