This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error accessing Swi_Param / Swi.Params statically defined in .cfg file (xdc.services.intern.xsr.Value$Obj): not an Instance)

I have seen other posts similar to this but am still missing something. I have defined swiParams2 in the .cfg file as such..

Program.global.swiParams2 = new Swi.Params; 

In the .c file ...

extern Swi_Params swiParams2;  

...

swiParams2.arg0 = 5; 

I keep getting the following error at compile time / xds time:

js: "C:/ti/xdctools_3_30_05_60_core/packages/xdc/cfg/Main.xs", line 48: XDC runtime error: Program.global.swiParams2 (of type class xdc.services.intern.xsr.Value$Obj): not an Instance

Not sure what I'm doing wrong here. This seems similar to the following, which is not generating any errors:

var swiParams = new Swi.Params;  // .cfg

Swi_post(swi0);   // .c filea

-Scott

  • Scott,

    I'm not too sure if I'm using the right terminology here, but you can't assign a new Swi.Params to a global variable.  The new Semaphore.Params doesn't actually create a Swi instance by itself. You need to call Swi.create() and assign it to a global variable.

    Have you tried using the graphical interface to create a Semaphore? It will create something like this in your .cfg file:

    .cfg:

    var swi0Params = new Swi.Params();
    swi0Params.instance.name = "swi0";
    swi0Params.priority = -1;
    Program.global.swi0 = Swi.create("&yourSwiFunction", swi0Params);

    .c:

    Then you can call Swi_post() in your .c file if you #include <xdc/cfg/global.h>:

    Swi_post(swi0);
  • Hi Tom,
    Thanks for looking at this.

    I have done exactly (mostly) as shown in your posting:
    .cfg:

    var swi0Params = new Swi.Params();
    swi0Params.instance.name = "swi0";
    swi0Params.priority = 10;
    Program.global.swi0 = Swi.create("&yourSwiFunction", swi0Params);
    .c:

    Then you can call Swi_post() in your .c file if you #include <xdc/cfg/global.h>:

    Swi_post(swi0);

    I CAN do this with no problem, but EACH TIME before I call Swi_post(swi0) I want to pass in an argument to my function "yourSwiFunction" by way of the swi0Params structure. e.g
    swi0Params.arg0 = 2; // this line causes the problem
    Swi_post(swi0);

    The build process error is:

    js: "C:/ti/xdctools_3_30_05_60_core/packages/xdc/cfg/Main.xs", line 48: XDC runtime error: Program.global.swiParams2 (of type class xdc.services.intern.xsr.Value$Obj): not an Instance

    Am I using this incorrectly? I mean is is ok to set the args in swi0Params each time prior to calling Swi_post(swi0)?

    -Scott
  • Scott,
    the error message indicates that your cfg script is still trying to assign a Params structure to Program.global. As Tom said, that can't be done. Program.global supports only instances and some primitive types.
    Also, a variable 'swi0Params' defined in the cfg script is not accessible in your C code. Only properties assigned to Program.global can be accessed in C code.
    I think you'll need to use some combination of Swi_getAttrs and Swi_setAttrs functions to change params of a Swi instance. Something like:
    Swi_post(swi0);
    Swi_getAttrs(swi0, ..., &params);
    params.arg0 = 2;
    Swi_setAttrs(swi0, ..., &params);
    Swi_post(swi0);

  • Thanks Sasha. That makes sense to me now. Only problem is that this is too slow for me to do in my Hwi, so after all that I will just set a global var within my hwi that the swi will inspect.

    -Scott