371 views
in System Integration by

Dear all,

we are developing a control panel based on STM32F767 microcontroller. In our board we have a QSPI flash memory to store the resources, menu Structure and menu Strings. We placed the menu Structure and menu String at specif addresses, so it is possible to replace or upgrade the menu when necessary (using a the bootloader). 

We realized a tool that generate the strings coded on Unicode characters. In this control panel we realized programmatically menu, so when the user hits a button, our function provides the rows count and the strings for each rows of the menu. This is the ShowMenu method implemented in Embedded Wizard Studio:

  method void ShowMenu( arg int32 MenuLevel, arg int32 MenuId )
  {
    tmrOnExit.Enabled = false;
    sthClose.Enabled = false;

    //to avoid warning
    MenuLevel;
    MenuId;

    if ( MenuView.GetCurrentMenu() != null )
    {
      trace "There is already a menu visible.";
      return;
    }

    RectEffect.Reversed = false;
    RectEffect.Enabled = true;
     
    //necessary to place on top MenuView since Menu Button are created dinamically
    RestackTop( MenuView );

    var Menu::Menu         menu  = new Menu::Menu;
    //var Menu::ExitItem   item4 = new Menu::ExitItem;

    $if $prototyper == true
    var Menu::BigSlideItem item1 = new Menu::BigSlideItem;
    var Menu::BigSlideItem item2 = new Menu::BigSlideItem;
    var Menu::BigSlideItem item3 = new Menu::BigSlideItem;
    menu.Caption = "Test";
    item1.Caption = "Caption 1";
    item2.Caption = "Caption 2";
    item3.Caption = "Caption 3";
    //item4.Caption = "EXIT"; 
    menu.AppendItem( item1 );
    menu.AppendItem( item2 );
    menu.AppendItem( item3 );
    //menu2.AppendItem( item4 );
    $else
    //get the current menu
    var int32 listItem = 0;
    var int32 i;
    var string RowCaption = "";

    native (MenuLevel, listItem) {
      Start_menu(MenuLevel);
      listItem = GetMenuCurrentListCount();
    }

    for (i = 0; i < listItem; i = i + 1)
    {
      native (RowCaption, i)
      {
        RowCaption = GetMenuStringByListOrdinal(i);
      }

      //test
      //RowCaption = "Test";

      if (i == 0)
      {
        //first caption is menu caption
        menu.Caption = RowCaption;
      }
      else
      {
        var Menu::BigSlideItem item1 = new Menu::BigSlideItem;
        item1.Caption = RowCaption;
        menu.AppendItem( item1 );
       }
    }
    $endif

    MenuView.exitMenu = sltCloseMenu;

    MenuView.OpenMenu( menu );
  }

The Ansi C function GetMenuStringByListOrdinal(i) is our function that provides a XString type (retrieve the memory address of Unicode string)... When the code is runnig and excute the menu.Caption = RowCaption instuction, the target fall in EwPanic function... 

More specifically, the previous instruction has translated in MenuMenu_OnSetCaption( menu, RowCaption ) on the target device and this function is like this:

/* 'C' function for method : 'Menu::Menu.OnSetCaption()' */
void MenuMenu_OnSetCaption( MenuMenu _this, XString value )
{
  if ( !EwCompString( _this->Caption, value ))
    return;

  EwRetainString( &_this->Caption, value );
  EwNotifyObjObservers((XObject)_this, 0 );
}

So when the code call EwRetainString fall in EwPanic... If we set RowCaption = "Test" in the Embedded Wizard Studio everything works perfectly.

We understand that if we use a memory address of constant string array created by Emebedded Wizard studio everythings works perfectly, otherwise no.

We use a debug serial port to read all the GUI message. The error before panic is as follow:

[FATAL ERROR in ewstring.c:1300] Unmanaged string 'Combustion Management'
PANIC: System halted

Could you help us please?

Waiting for your kind reply

Best regards

Gianni Perugini

by
Dear all,

just to inform you that we find the solution. We use EwNewString() in this way:

  native (RowCaption, i)
  {
    RowCaption = EwNewString(GetMenuStringByListOrdinal(i));
  }

and everything works fine

Thanks anyway.

Best regards

Gianni Perugini

1 Answer

+1 vote
by

Hi Gianni,

great that you already found the solution - just for others having similar issues: Please have a look to the section Be careful when exchanging strings.

Best regards,

Manfred.

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

...