279 views
in System Integration by
How to convert XString passed from DeviceDriver.c to String.

 

When I pass XString from DeviceDriver.c to UI It will not show, it shows blank. When I pass int then it will work fine.

1 Answer

0 votes
by

Hi unais,

If you work with a "String" in the GUI (Chora, within Embedded Wizard Studio) and you generate the code for C, it will create an XString as a representation of the String.

That means also (the other way around), if you pass an XString to GUI, it should end up with in a String.

Usually there are two use cases:

1. Function in DeviceDriver / C: Create XString in DeviceDriver and pass it to GUI:

void UpdateValue( char* aValue )
{
  XString valStr = EwNewStringAnsi( (char*)aValue );
  DeviceDeviceClass__UpdateString( DeviceObject, valStr );
}

Within the GUI, inside the DeviceClass there is a function UpdateString( string ), which is called via DeviceDriver.

 

2. Function in DeviceClass / Chora: Get String from device (e.g. middleware) and pass it to UI component:

GetStatus()
{
  // The variable should receive some device status information.
  var string status = "";

  $if !$prototyper
    native ( status )
    {
      char buf[256];
      int  voltage;
      int  current;
      
      /* Call some functions to get the status information of the device */
      voltage     = device_get_voltage();
      current     = device_get_current();
      
      /* Format a status message in the temporary buffer 'buf' */
      sprintf( buf, "STATUS: %d Centigrade, %d Volt, %d Ampere", voltage, current );
      
      /* From the ANSI string in 'buf' create Embedded Wizard string and
         return it in the variable 'status'.  */
      status = EwNewStringAnsi( buf );
    }
  $endif

  // 'status' contains now the message as a correct string.
  return status;
}

Within the GUI, inside the DeviceClass there is a function GetStatus(), which is called via GUI and grabs the strings from C, creates and returns an XString .

 

See also: https://doc.embedded-wizard.de/integrating-with-the-device?v=11.00#6

 

Hope this helps,
Chris

by
it worked ...

thanks for your help...

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

...