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.

Getting pointer value of cfg script var

Hello,

In one of my driver modules, I define a struct HW_Params_s. I would like to pass this in to my bind call through DEV.params. As ussual I am coming across my type checking issues.

var HWParams = new Driver.HW_Params_s;

var dev_Params = new DEV.Params();
   dev_Params.devid = 0;
   dev_Params.instance.name = DeviceName;
   dev_Params.initFxn = Driver.DriverInit;
   dev_Params.deviceParams = HWParams; <------- offending line
   Program.global.mDevEth0 = DEV.create("/" + DeviceName, "&Driver_DriverFunctions", dev_Params);

Thanks!

  • norton256,
    deviceParams is declared as 'Ptr', an address type, which is used when you need to capture the address of an object that exists at runtime. Your HWParams structure is a JavaScript object that will disappear as soon as the script exits, and it's not possible to get a runtime address of such an object. The objects that exist at runtime are module config parameters, instances, module and instance states, and whatever is defined in your C source files.
    I am not sure what's the error message you are seeing, but before fixing any type related issues you'll have to use a runtime object. As we found out in previous threads, the module DEV is using Fxn and Ptr types in such a way that's very difficult to pass to it objects declared in XDCspec files. You might be better off defining a structure in your C file and then passing its name using '&' notation:
    dev_Params.deviceParams = "&Driver_myParamsStruct"; 

  • Thanks for clearing that up. It looks like I should familiarize myself with template code a little more. I could probably implement quite a bit with that method.

    Thanks