0

I have a string that stores a signal name extracted from an excel file. I want to dynamically assign the name of the signal using the string, if I have many such signals.

For example, if I have a signal called 'speed' in my dbc file, and I have a string that stores 'speed', I need to set the value of signal 'speed' as 100.

variable
{
    message BCM BCM;
    char signal[100]= "speed";
}

on message * 
{
    $signal= 100;
}

The error I get is:
Error: Identifier 'signal' does not have a signal type.

Is there a workaround to this problem, such that I can convert the string into a signal name by some means?

VIyer
  • 3
  • 1
  • 2

1 Answers1

0

You are mixing the variable formats like this. The only object on which you can use $ is dbSignal type. What you would need is a function like getSignal(dbSignal name);, but with char[] parameter. Sadly, Vector did not implement such workaround, leaving you the only option to pass your signal strings by testcase parameters (if you are using XML Test nodes).

Since, I presume you have too many, I suggest you write a script in another scripting language constructing the text of the .can file itself, filling the place of dbsignals with the strings from the excel, then use the .can file for testing/simulation.

VioletVynil
  • 502
  • 5
  • 11
  • Can you please elaborate on passing signal strings by testcase parameters? – VIyer Dec 27 '18 at 09:14
  • I don't have CANoe installed right now, next year I can elaborate if you don't find it. I cannot provide you screenshots. But you need to read the CANoe help for guide on the XML test node. In any case,you have to fill either way somehow the string by a script in your xml file too. Your xml capltestcase definition will have param dbsignal="YOURSTRING", then your testcase will be defined as testcasename (dbsignal SigReferencefromParameter). – VioletVynil Dec 27 '18 at 09:27
  • Hi VioletVynil, I found a function: setSignal(char sigName[], float sigValue);. The problem is that this function does not work as intended at all, and throws an error like: "System 01-0083 SetSignal was called for signal , but no signal driver is available." When I try setting signal value using the format MessageName.SignalName = int value; for an individual signal, it works, but doing the same using the SetSignal function for the same individual signal does not work. Can you please assist? – VIyer Dec 31 '18 at 11:17
  • Yes. The signal driver is usually a dll. What dll are you using for simulating the cyclic message? – VioletVynil Dec 31 '18 at 13:04
  • We are not using any ILs or DLLs currently. I am digging out more information on DLLs from the internet as well, but I would like your help here. Can you please elaborate about DLLs and how they're used in CANoe? – VIyer Jan 02 '19 at 07:03
  • In order to have automatic control of cyclic messages defined in dbc databases, Simulation Nodes need a dll dictating IL simulation. For example, CANoeILNLVector.dll is the dll CANoe provides in its exec32 folder for CAN simulation. If you have a dbc with proper message attributes, it will automatically send the cyclic messages and will set dynamically your message content (signals) with SetSignal(), amongst many functionalities. – VioletVynil Jan 02 '19 at 07:08
  • But you must assign the dll by hand in Simulation Node configuration Components (if the automatic configuration Wizard did not add it already). The dll dependencies can also be found (if existent) in the dbc. – VioletVynil Jan 02 '19 at 07:10
  • 1
    Hi VioletVynil, I assigned the ILs to a node. The messages and signals that were part of the added IL did not throw an error and I successfully transmitted the desired signal values. The only problem remains addition of all nodes, which will be countered in the full version of CANoe. I finally have desired results. Thank you for your guidance. I will connect with you here if I face any issues again. :) – VIyer Jan 02 '19 at 12:50