Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » Recipe for abstract instances
Recipe for abstract instances [message #722521] Mon, 05 September 2011 23:18 Go to next message
Naoki Kawada is currently offline Naoki Kawada
Messages: 10
Registered: June 2010
Junior Member
Hi,

I would like to use abstract instance, just like xdc.runtime.Memory module.
As you know xdc.runtime.Memory module can use abstract instance inheriting IHeap interface. I would like to do same thing with my modules.

As for me, I have tried the following.
I have my.audio.decoder.Dec module which has a proxy for actual decoder instance and some actual decoder implementations in my.audio.decoder.impls package(e.g. .Mp3/.DecNull) inheriting my.audio.decoder.IDecProvider interface.

Each module looks below.
=== Dec.xdc ===
module Dec {
    config IDecProvider.Handle defaultInstance = null;

    UInt decode(IDecProvider.Handle hdl, Void *inBufp, Void *outBufp, ....);
    Void reset(IDecProvider.Handle hdl);
    ...
    ...

 internal:
    proxy DecProxy inherits IDecProvider;
}


== Dec.c ===
...

Void Dec_reset(IDecProvider_Handle hdl)
{
    Dec_DecProxy_reset(hdl);
}

...


=== IDecProvider.xdc ===
interface IDecProvider {
instance:
    create();
    UInt decode(Void *inBufp, Void *outBufp, ....);
    Void reset ();
    ...
    ...
}


=== Mp3.xdc ===
@InstanceInitError
@InstanceFinalize
module Mp3 inherits IDecProvider {
    ...
 instance:
    create();
    config UInt format;
    ...
 
 internal:
    struct Instance_State {
       ....
       ....
    };
}


=== DecNull.xdc ===
@InstanceInitError
@InstanceFinalize
module DecNull inherits IDecProvider {
    ...
 instance:
    create();
    ...
 
 internal:
    struct Instance_State {
       Uint dummy;
    };
}


During the configuration, Dec.DecProxy is bound to DecNull moudle in package.xs:
==== package.xs ====
function close()
{
    var Dec = this.Dec;
    if (Dec.$used) {
        if (Dec.defaultInstance == null) {
            var DecNull = xdc.useModule ("my.audio.decoder.impls.DecNull");
            var decNullParams = new DecNull.Params();
            Dec.defaultInstance = DecNull.create(decNullParams);
            print ("Dec proxy has been bound to DecNull");
        }
        Dec.DecProxy = Dec.defaultInstance.$module;
        Dec.DecProxy.abstractInstance$ = true;
}


In .cfg, common$.fxntab is being enabled explicitly.
==== .cfg =====
Defautls = xdc.useModule ("xdc.runtime.Defaults");
Defaults.common$.fxntab = true;


Now, I saw a runtime error (Exception abort) at the following code.
==== test.c =====
Mp3_Handle mp3Dec;
IDecProvider idec;

mp3Dec = Mp3_create (&my3Params, NULL);
idec = Mp3_Handle_upCast (mp3Dec);
if (idec != NULL) {
    Dec_reset (idec); <===== at this point, exception happened.
    ....
}


According to my debug, exception itself was caused by the reference to NULL pointer.

Please note, idec itself is not NULL, but idec contents looks incorrect with my scheme... Could you show me the recipe/suggestions for abstract instance ?






[Updated on: Tue, 06 September 2011 21:50]

Report message to a moderator

Re: Recipe for abstract instances [message #722839 is a reply to message #722521] Tue, 06 September 2011 17:32 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha Slijepcevic
Messages: 86
Registered: July 2009
Member
I am looking into replicating your problem, but could you just verify first if the functions reset() and decode() are declared correctly in IDecProvider? The code from IDecProvider.xdc seems wrong, as if you switched reset() and decode(). Dec_reset() calls Dec_DecProxy_reset() with one parameter, while IDecProvider declares reset() with two buffer parameters in addition to the handle parameter, which is assumed.
Re: Recipe for abstract instances [message #722862 is a reply to message #722839] Tue, 06 September 2011 21:40 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki Kawada
Messages: 10
Registered: June 2010
Junior Member
Hello Sasha,

Thank you for your help !
That was just my typo... I have fixed it at my original message.
Now my code looks like this, but the problem is still there.
Do you have any other suspicions about the issue ?
Any suggestions will be helpful for me.

Please note I'm using xdctools v3.22.01.21

Best Regards,
Kawada

[Updated on: Tue, 06 September 2011 21:45]

Report message to a moderator

Re: Recipe for abstract instances [message #724291 is a reply to message #722862] Sun, 11 September 2011 20:21 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki Kawada
Messages: 10
Registered: June 2010
Junior Member
Anybody, Any updates on this ?
Re: Recipe for abstract instances [message #724764 is a reply to message #724291] Tue, 13 September 2011 02:05 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki Kawada
Messages: 10
Registered: June 2010
Junior Member
Hi,

I finally overcame the issue.
The root cause was clearing Mp3_Object in Int Mp3_Instance_init function:

Int Mp3_Instance_init
(
    Mp3_Object *obj,
    const Mp3_Params *params,
    Error_Block *eb
)
{
    /* Clear object for fail safe */
    memset (obj, 0, sizeof(Mp3_Object)); <====== THIS CAN CAUSE ERROR !!!

    /* Initialize members ... */
    obj->objMember1 = ...;
    obj->objMember2 = ...;
    obj->objMember3 = ...;
    ...

}


The above code can clear function pointer for abstract function call because the pointer is being embedded into Mp3_Object...
My code got worked just by removing memset call.

I think the same problem can happen at other module providers...Please take care.

Thank you for all your support!

Regards,
Kawada
Re: Recipe for abstract instances [message #741908 is a reply to message #724764] Wed, 19 October 2011 22:18 Go to previous message
Sasha Slijepcevic is currently offline Sasha Slijepcevic
Messages: 86
Registered: July 2009
Member
Kawada,
sorry for not responding. I was on a long vacation, but I am back and the response time should be better now.
Previous Topic:ARM cortex a8 and cortex A15 support
Next Topic:Math functions for c28_float target
Goto Forum:
  


Current Time: Sun Aug 31 04:28:20 EDT 2014

Powered by FUDForum. Page generated in 0.01897 seconds