Is is possible to read vector signals with the XIL API?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 27 Sep. 2023
Bearbeitet: MathWorks Support Team
am 20 Mär. 2025
I'm using the "Simulink Test Support Package for ASAM XIL Standard" and the "Simulink Real-Time Support Package for ASAM XIL Standard". And I want to read an array from my Simulink model with the XiL API.
When I list my testbench variables, I get the following output.
>> frm = sltest.xil.framework.Framework;
>> frm.Configuration.addModelAccessPort('MAPort', 'asamxil.v2_1', 'VendorName','MathWorks', 'ProductName','XIL API', 'ProductVersion','1.0', 'PortConfigFile',fullfile(pwd,'ConfigureFile.xml'));
>> frm.init
>> frm.displayAllTestbenchVariables
Listing variables for port: MAPort
( 1) id: 'TestModel/Subsystem:1(1,1)', category: generic, data type: eUINT, readable: 1, writable: 0, xsize: 1, ysize: 1
( 2) id: 'TestModel/Subsystem:1(2,1)', category: generic, data type: eUINT, readable: 1, writable: 0, xsize: 1, ysize: 1
( 3) id: 'TestModel/Subsystem:1(3,1)', category: generic, data type: eUINT, readable: 1, writable: 0, xsize: 1, ysize: 1
( 4) id: 'TestModel/Subsystem:1(4,1)', category: generic, data type: eUINT, readable: 1, writable: 0, xsize: 1, ysize: 1
( 5) id: 'TestModel/Constant/Value', category: generic, data type: eUINT_VECTOR, readable: 1, writable: 1, xsize: 1, ysize: 4
>> frm.shutdown
With the XIL API I can read the value 'TestModel/Constant/Value' as an eUINT_VECTOR, but this is not possible with 'TestModel/Subsystem:1'. Upon using MAPort.Read, I get this error:
2025-03-19 06:23:56.555 MainThread EXAM Caught Exception in loop.py
Error type LibraryException
Error code e_SIM_0009
Error message Reading simulation variable 'TestModel/Subsystem:1' of SimModelID 'TestModel' failed.
Error was caused by:
Cause error type ExternalToolException
Cause error code e_SIM_2008
Cause error message A XIL-API call has thrown an exception: MAPort.Read
Cause tool error code 0
Cause tool error message Exception is not a TestBenchPortException. Exception information: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at MathWorks.ASAM.XIL.Server.MAPort.MAPort.Read(String variableName)
Traceback exception-traceback: File "E:\EXAM_sync\_6\_2\_c7d1fdea_b712_4ec0_86c7_4e79a5118226V1009_12\modules\Platform\SimulationModel\MAPortController.py", line 191, in _rawRead
command: value = maPort.Read(exam_unicode(sPath))
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at MathWorks.ASAM.XIL.Server.MAPort.MAPort.Read(String variableName)
With the XiL API it is only possible to read the entries 'TestModel/Subsystem:1(1,1)',... successively.
On the other hand, the SLRT Explorer displays the signal 'TestModel/Subsystem:1' as one vector.
Is it possible to change the model in a way, that the signal 'TestModel/Subsystem:1' can be read as an eUINT_VECTOR by the XIL API?
Akzeptierte Antwort
MathWorks Support Team
am 20 Mär. 2025
Bearbeitet: MathWorks Support Team
am 20 Mär. 2025
This is the expected behavior as this is a limitation of the XIL standard. XIL does not allow users to record non-scalar signal data by using capture objects. When we designed our XIL implementation, we either prevented users from recording non-scalar signals, or we could break up non-scalar signals into a group of scalar signals, but you need to call "read" multiple times to get all the element values for a non-scalar signal.
MAPort and ECU ports have a "Variables" property which returns all the available variables based on xil standard. It takes a while to return since it gives all the variables in a model.
MA port and ECU ports also have a function "CheckVariableNames" in which you can provide a list of variable names and it returns invalid ones.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!