question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for String Type in `.sym` Files

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eerimoqcommented, Jan 12, 2019

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 a string with an unsigned value of a multiple of 8 bits and char as an unsigned value of length 8.

0reactions
garethellis0commented, Jan 16, 2019

Confirmed that 32.6.1 produces the following:

struct CanMsgs_pdm_heart_beat_t {
    /**
     * Range: -
     * Scale: 1
     * Offset: 0
     */
    uint64_t variable2;
};

Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found