Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » DSDP - Real-Time Software Components (RTSC) » Recipe for abstract instances
Recipe for abstract instances [message #722521] Tue, 06 September 2011 03:18 Go to next message
Naoki Kawada is currently offline Naoki KawadaFriend
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: Wed, 07 September 2011 01:50]

Report message to a moderator

Re: Recipe for abstract instances [message #722839 is a reply to message #722521] Tue, 06 September 2011 21:32 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 115
Registered: July 2009
Senior 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] Wed, 07 September 2011 01:40 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki KawadaFriend
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: Wed, 07 September 2011 01:45]

Report message to a moderator

Re: Recipe for abstract instances [message #724291 is a reply to message #722862] Mon, 12 September 2011 00:21 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki KawadaFriend
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 06:05 Go to previous messageGo to next message
Naoki Kawada is currently offline Naoki KawadaFriend
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] Thu, 20 October 2011 02:18 Go to previous message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 115
Registered: July 2009
Senior 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: Thu Oct 10 08:11:36 GMT 2024

Powered by FUDForum. Page generated in 0.04269 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top