Support for String Type in `.sym` Files
See original GitHub issueWhen parsing the following .sym
file:
FormatVersion=6.0 // Do not edit this line!
Title="Untitled"
{ENUMS}
Enum=Enum1()
{SIGNALS}
Sig=Signed_Int_Char char
Sig=Enum_Signal Enum1 8
{SENDRECEIVE}
[PDM_HeartBeat]
ID=001h
Len=8
Var=Variable2 string 0,64 /d:rDefaultS
where the PDM_HeartBeat
symbol has a 64 bit “string” variable with default value “DefaultS”, the following error is produced:
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\textparser.py", line 839, in parse
return Grammar(self.grammar()).parse(tokens, token_tree)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\textparser.py", line 640, in parse
raise GrammarError(tokens.peek_max().offset)
textparser.GrammarError: Invalid syntax at offset 218.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "src\shared\CanMsgs\generate_c_code_from_sym.py", line 77, in <module>
generate_code_from_sym_file(sym_filename)
File "src\shared\CanMsgs\generate_c_code_from_sym.py", line 47, in generate_code_from_sym_file
dbase = load_file(database_name + ".sym", database_format="sym")
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\__init__.py", line 170, in load_file
strict)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\__init__.py", line 238, in load
strict)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\__init__.py", line 305, in load_string
return load_can_database('sym')
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\__init__.py", line 287, in load_can_database
db.add_sym_string(string)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\can\database.py", line 198, in add_sym_string
database = sym.load_string(string, self._strict)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\cantools\database\can\formats\sym.py", line 578, in load_string
tokens = Parser60().parse(string)
File "C:\Users\Gareth\.virtualenvs\Consolidated-Firmware-74Z7PhuA\lib\site-packages\textparser.py", line 841, in parse
raise ParseError(text, e.offset)
textparser.ParseError: Invalid syntax at line 16, column 30: "Var=Variable2 string 0,64 /d:>>!<<rDefaultS"
Please let me know if you need anything else! Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Working with sym files | kdb+ and q documentation
The type of each of the files is obtained by using keyword get to extract the data to perform the type call. The...
Read more >File Format (Linker and Libraries Guide) - Oracle Help Center
The symbol specifies a thread-local storage entity. When defined, it gives the assigned offset for the symbol, not the actual address. Symbols of...
Read more >How to convert strings to symbolic expressions without sym()?
To create symbolic expressions, first create symbolic variables and then use operations on them.
Read more >Tool to help process SYM files · Issue #5 · diasurgical/scalpel
The last few days I've been playing with the idea of processing SYM files to output scripts which will add all symbol information...
Read more >Documentation - Symbols - TypeScript
Starting with ECMAScript 2015, symbol is a primitive data type, just like number and string . symbol values are created by calling the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Today the type system in cantools only handles signed, unsinged and float. The type system should probably be improved, say with a
type
-attribute in the signal class, but as a first step I suggest representing astring
with an unsigned value of a multiple of 8 bits andchar
as an unsigned value of length 8.Confirmed that 32.6.1 produces the following:
Thanks!