220 views
in Embedded Wizard Studio by
Hi,

1)We have a structure variable in C file (from device) which needs to be passed to device interface in EmbeddedWizard as an object. The structure has multiple uint8 variables and arrays.
Please suggest if any solution to pass the structure or array to GUI.

2)While converting from ASCII to string using EwNewStringUtf8 or EwNewStringAnsi, if any zero occurs inbetween it terminates as null character and hence getting incorrect output.

Best regards,

Nizam

1 Answer

0 votes
by

Hello Nizam,

concerning your first question, passing pointers is not possible. Few ideas how to transfer array data contents can be found in the section Exchange array contents and in diverse threads in this Ask forum. Concerning the second question, the 'zero' character terminates the strings. If you plan to use a string as data buffer to transfer data, you would need to encode the data so the value zero is omitted.

I hope it helps you further.

Best regards

Paul Banach

by
1) Encoding the data means what kind encoding to be done. Is it like replacing the zero character with some other?

2)As per the example in the link, the extern variable is getting declared inside the method in generated .C file. Hence getting error while accessing the variable in C code to assign values.

Thanks

Best regards

Nizam
by

Hello Nizam,

1) Encoding the data means what kind encoding to be done. Is it like replacing the zero character with some other?

yes, this is the idea.

2)As per the example in the link, the extern variable is getting declared inside the method in generated .C file. Hence getting error while accessing the variable in C code to assign values.

In the examples an externally defined variable is used:

Best regards

Paul

by
Hi Paul,

Thanks for the solution..

On replacing the 0 with some other like FF, and then sending the string data buffer to GUI it worked.

To decode the same the in EW is there any solution? i.e., to find replace the specific character in the string and replace back to 0 ?

Best regards
Nizam
by
Hello Nizam,

replacing the value back with 0 (zero) will truncate the string at the given position. This is not the solution.

I would recommend to perform the replacement (decoding) on the fly just in the moment when the string is evaluated. Please note that each character in the string is 16-bit large. Assuming you want to pass an array of uint8 values in range 0x00..0xFF, the simplest would be to store the values +1 and when evaluating the values subtract 1 again. The so encoded string will contain characters in range 0x0001 .. 0x0100. The value 0 (zero) is not used to encode the data anymore.

Does it help you further?

Best regards

Paul Banach

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

...