Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » instance$static$init not getting called(XDCscript:)
instance$static$init not getting called [message #494024] Wed, 28 October 2009 15:57 Go to next message
Brian Cruickshank is currently offline Brian Cruickshank
Messages: 19
Registered: September 2009
Junior Member
I'd like to use XDCScript to statically initialize some target data structures that are associated with an instance of a module, but for some reason the .xs file's instance$static$init function is not getting called.

I've added print statements to the module's .xs script and can see both module$use() and module$static$init(obj) being called, but don't see instance$static$init,(obj, prms) being called.

I've tried setting the module's .common$.memoryPolicy = xdc.runtime.Types.STATIC_POLICY in both module$use and the application's .cfg file, and even tried setting the Defaults.common$.memoryPolicy = xdc.runtime.Types.STATIC_POLICY as well without any success.

My .xdc file has the following structure:

@InstanceFinalize /* this mod has cleanup fxn when instances are deleted */
@InstanceInitError /* instance create can fail */
...
module MsgQueue {
...
instance:
create();
... // instance config and function declarations

internal:

struct Instance_State {
... // instance state variables
};
}

I've tried adding @ModuleStartup to the .xdc file as well.

The module's .c code contains a <Mod>_Instance_Init function declaration.

I'm currently using xdctools 3.15.02.62

Any advice on what I should do to get the instance$static$init function in the module's .xs script to be called would be much appreciated.

Regards,
Brian
Re: instance$static$init not getting called [message #494033 is a reply to message #494024] Wed, 28 October 2009 16:50 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha Slijepcevic
Messages: 86
Registered: July 2009
Member
Brian,
normally instance$static$init is NOT called if the module is metaonly, or it's not being used, or there are no instances in the array of instances.
Since you already verified that module$use is being called, and your module is not declared metaonly in its XDC file, you should verify that the array of instances is not empty.

Here you can see that each module has a property $instances:
http://rtsc.eclipse.org/docs-tip/XDCscript_Language_Referenc e#Modules

That property is an array of instances, and you can check its size as Mod.$instances.length. Print that value right before and after calling Mod.create(), and also somewhere in module$static$init. In module$static$init, 'this' is a reference to the module.
Re: instance$static$init not getting called [message #494236 is a reply to message #494033] Thu, 29 October 2009 12:54 Go to previous message
Brian Cruickshank is currently offline Brian Cruickshank
Messages: 19
Registered: September 2009
Junior Member
Sasha ,
Your reply made me realize that I hadn't added a call to create the module instance to the application's .cfg file. Once I did that, everything worked.

Thanks for all your help!

Regards,
Brian

[Updated on: Thu, 29 October 2009 12:55]

Report message to a moderator

Previous Topic:Best way to inline target-specific code?
Next Topic:XDCtools 3.16.01 is available
Goto Forum:
  


Current Time: Wed Jul 23 06:03:23 EDT 2014

Powered by FUDForum. Page generated in 0.02388 seconds