Effacer les filtres
Effacer les filtres

Invalid MATLAB variable name specified - Error while importing ARXML

8 vues (au cours des 30 derniers jours)
Why is MATLAB restricting function names to 63 characters, when AUTOSAR allows upto 128 characters?
Is there an option to increase namelength in MATLAB? Any work around other than chnaging the variable name?
Getting this error, when importing arxml :

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Sep 2021
For C and C++, the limit on internal identifiers is unlimited, and external identifiers is implementation defined and "often unlimited" http://gcc.gnu.org/onlinedocs/gcc/Identifiers-implementation.html#Identifiers-implementation (but historically it was common to see a limit of 31 or 32 for external identifiers in linkers.)
So why is AUTOSAR restricting to 128 when at least one other programming language permits indefinite length? Aren't all programming languages the same?? Must be a bug in AUTOSAR that it limits identifier lengths!!
Sigh.
MATLAB has to keep a dynamic symbol table. Unlike C or C++, every reference to a variable has to be looked up in the symbol table. Symbol table management is important for that to be efficient.
A symbol table can either have fixed maximum-length identifiers or it can have variable length identifiers.
If it has fixed maximum length, then each symbol table entry can be exactly the same size, and memory management for that becomes easy: you can use simple array indexing. With fixed maximum length variables, you do not want the maximum to be too short or else users do not have sufficient creative expression; if you make the maximum large, then you can end up wasting a lot of space for name sizes that are rarely used.
If the identifiers are variable length in the symbol table, then you need to do memory management about them, doing dynamic memory allocation, complete with issues about making sure you do not lose track of the space, and complete with having to hunt for slots with enough available free space, and possibly having to allocate more memory (but not knowing that until you have hunted through the free space chain.) The amount of memory required is unpredictable, and the time required is unpredictable, and you might run out of memory because it is fragmented even though enough total free memory might be available.
AUTOSAR deals with real-time systems. Real-Time systems cannot afford variable length searches and unpredictable memory use and the possibility of running out of usable memory because of fragmentation. So AUTOSAR realistically needs fixed maximum lengths too.
AUTOSAR happened to choose a different maximum length than MATLAB choose. AUTOSAR standardization started in 2004; MATLAB first commecial release was 1984, which was a time when memory resources were considerably more expensive and more limited than in 2004.
Also, AUTOSAR is expected to be used in environments where variable names are mechanically generated from specification files -- which tends to lead to longer variable names.
Could Mathworks expand the variable name limit? Probably. But it would require changing the .mat file format for "small" files (the -v7.0 format). It would probably be easier for -v7.3 files (which are implemented as HDF5). Unfortunately the -v7.3 file format is often notably slower than the -v7.0 file format for files that fit within the -v7.0 limits. Not so bad for plain numeric arrays, but HDF5 is not wonderful for arrays of composite data types.
  1 commentaire
Suryakiran Menachery George
Thank you for the comprehensive answer. I got the point! Since MATLAB & Simulink supports AUTOSAR standards; I was wondering why the max_length is capped at 63 and not 128 or higher.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur AUTOSAR Blockset dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by