User code unable to read data dictionary

I have a user.c code which is trying to read some data dictionary variables as follows:

// Global
tDDictEntry *Park, *Ax, *Ay, *WheelSpd_FL, *WheelSpd_FR, *WheelSpd_RL, *WheelSpd_RR;
tDDictEntry *YawRate, *EngineLoad, *Gas, *SelectorCtrl, *Trq;
tDDictEntry *GearNoTrg, *Rotv, *GearNo, *SteerAng, *SteerVel;
tDDictEntry *SteerAngleFr, *SteerAngleFL, *Brk

double park, selectorctrl, gearnotrg, gearno;
double ax, ay, wheelspdFL, wheelspdFR, wheelspdRL, wheelspdRR;
double yawrate, engineload, gas, trq;
double rotv, steerang, steervel;
double steerangleFR, steerangleFL,;

        EngineLoad = DDictGetEntry("PowerTrain.ControlIF.EngineOut.Load");
	Gas = DDictGetEntry("DrivMan.Gas");
	SelectorCtrl = DDictGetEntry("DrivMan.SelectorCtrl");
	Trq = DDictGetEntry("Engine.Trq");
	GearNoTrg = DDictGetEntry("PT.Control.GB.GearNoTrg");
	Rotv = DDictGetEntry("Vehicle.Engine_Rotv");
	GearNo = DDictGetEntry("Vehicle.GearNo");
	SteerAng = DDictGetEntry("Vehicle.Steering.Ang");
	SteerVel = DDictGetEntry("Vehicle.Steering.AngVel");

	SteerAngleFr = DDictGetEntry("Car.SteerAngleFR");
	SteerAngleFL = DDictGetEntry("Car.SteerAngleFL");
        //engineload = EngineLoad->GetFunc(EngineLoad->Var);
	//gas = Gas->GetFunc(Gas->Var);
	//selectorctrl = SelectorCtrl->GetFunc(SelectorCtrl->Var);
	//trq = Trq->GetFunc(Trq->Var);
	//gearnotrg = GearNoTrg->GetFunc(GearNoTrg->Var);
	//rotv = Rotv->GetFunc(Rotv->Var);
	//gearno = GearNo->GetFunc(GearNo->Var);
	//steerang = SteerAng->GetFunc(SteerAng->Var);
	//steervel = SteerVel->GetFunc(SteerVel->Var);

In the User_Calc() function above, if I uncomment the commented lines, the compiled CarMaker executable doesnt load and times out. If I Log the EngineLoad or any of the other variables, I get an ERROR “Caught signal SIGSEGV(11)”

I am able to get other data dictionary variables using the same method such as, Car.Yaw.

What can be causing this?

Welcome to the forum Omkar.

I think the problem might be the UAQ name you are using. I don’t think PowerTrain.ControlIF.EngineOut.Load is a valid name. I suspect the UAQ you might be looking for is PT.Control.Engine.Load. The reference manual is a good place to check for names.

Note that as well as DDictGetEntry there is also DDictGetEntryOrFake. The former will error if the name does not exist whereas the latter will return a dummy handle if the name doesn’t exist.

User_TestRun_Start_atEnd (void)
#if defined(XENO)
    EngineLoad = DDictGetEntryOrFake("PT.Control.Engine.Load");
    return 0;

It’s also worth noting that User_Calc is invoked on every simulation state. If you only want to fetch values when the simulation is running you can query the simulation state.

User_Calc (double dt)
    if (SimCore.State == SCState_Simulate) {
        double engineload;
        engineload = EngineLoad->GetFunc(EngineLoad->Var);
        Log("The value of engineload is %f \n", engineload);
    } else {
        Log("The simulation is not running yet \n");
    return 0;

Hi David. Thanks for the reply. I did try PT.Control.Engine.Load. But this also errors out. I am going acc to the Referencemanual that comes with the installation (CM ver 10.0.1). In section 24.12.2 it specifies .EngineOut.Load … the PreIF is specified as PowerTrain.ControlIF for C-code name.
I managed to find alternates to most of the above list except for two (the ones commented out here)

	//EngineLoad = DDictGetEntry("PT.Control.Engine.Load");
	Gas = DDictGetEntry("DM.Gas"); //Verified
	SelectorCtrl = DDictGetEntry("VC.SelectorCtrl"); //Doesnt crash - not sure what this does
	//Trq = DDictGetEntry("PT.Engine.Trq");
	GearNoTrg = DDictGetEntry("DM.GearNo.Trgt"); //Verified
	Rotv = DDictGetEntry("PT.Engine.rotv"); //Verified
	GearNo = DDictGetEntry("DM.GearNo"); //Verified
	SteerAng = DDictGetEntry("DM.Steer.Ang"); //Verified
	SteerVel = DDictGetEntry("DM.Steer.AngVel"); //Verified

May I also ask … why are some of the names in reference manual throwing an error? Is there a data dictionary add on I need to install for all names to be made available for C-code access?

I tested with PT.Control.Engine.Load in CM10 and it works fine here. I think it might be best if you share your Project with me so I can take a look at the code in full. I’ll send you a DM so you can share the project.

It’s also worth pointing out not to confuse the c-code variable name with the data dictionary name. To access a quantity using DDictGetEntry you should pass the data dictionary UAQ name, not the c-code variable name. Both are listed in the table in the reference manual.

The DDictGetEntry function is described in the programmers guide.

As per David’s suggestions, following variable names worked for me and I was able to run a compiled Carmaker.exe

	EngineLoad = DDictGetEntryOrFake("PT.Control.Engine.Load");
	Gas = DDictGetEntryOrFake("Driver.Gas");
	SelectorCtrl = DDictGetEntryOrFake("Driver.SelectorCtrl");
	Trq = DDictGetEntryOrFake("PT.Engine.Trq");
	GearNoTrg = DDictGetEntryOrFake("PT.Control.GB.GearNoTrg");
	Rotv = DDictGetEntryOrFake("PT.Engine.rotv");
	GearNo = DDictGetEntryOrFake("PT.GearBox.GearNo");
	SteerAng = DDictGetEntryOrFake("DM.Steer.Ang");
	SteerVel = DDictGetEntryOrFake("DM.Steer.AngVel");