in System Integration by

In our application we use an EmbeddedWizard class

It contains 5 variable, 4 of an autogenerated Enum Type and a bool. Also an Init, copy and compare methods are built.

Now we want to use an object of this class to transfer data from the device to the GUI. So in device autoobject we use:

We saw, that in EmbeddedWizard objects are transfered by reference. Using the ‘=’ operator for objects of type class EventItem, the reference (pointer to memory) is copied. Therefore EventMessage property is initialized with the VariableEventItem to offer memory storage, the UpdateEventMessage is implemented like this, using CopyFrom and IsEqual methods, which compare resp. copy the internal variables:

Using this UpdateEventMessage method from device code looks like this, getting data from a cpp class (rEventItem) which also has enum typed members:

DeviceEventItem device_event_item;

device_event_item->Source            = (EmWiUidListAutoGeneratedUidListEnum)rEventItem.mEventSource;

device_event_item->Type              = (EmWiUidListAutoGeneratedUidListEnum)rEventItem.mEventType;

device_event_item->Classification    = (EmWiUidListAutoGeneratedUidListEnum)rEventItem.mEventClassification;

device_event_item->Instruction       = (EmWiUidListAutoGeneratedUidListEnum)rEventItem.mEventInstruction;

device_event_item->CreateOpenedPanel = false;

DeviceDeviceClass_UpdateEventMessage( mDeviceObject, device_event_item );

Using this construct leads to a segmentation fault at the first assignment (Source).

Is this the right way to construct an object from EmbeddedWizard defined class DeviceEventItem? Is there a garbage collector problem? What happens here?

1 Answer

0 votes
Problem is solved by changing the interface of UpdateEventMessage() to receive the enum values as seperated parameters.
Mistake in the first crashing version is, that a chora object is only declarated, but no definition was made allocating necessary memory. I learned from embedded wizard support, that using chora objects in own C code is not advised, because handling memory tasks is not easy to perform in a correct way.

Embedded Wizard Website | Privacy Policy | Imprint