Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Sauci/pydbc
An AST generator for dbc format
https://github.com/Sauci/pydbc
ast automotive dbc parser
Last synced: 3 months ago
JSON representation
An AST generator for dbc format
- Host: GitHub
- URL: https://github.com/Sauci/pydbc
- Owner: Sauci
- License: bsd-3-clause
- Created: 2020-03-12T08:22:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-16T12:45:35.000Z (over 4 years ago)
- Last Synced: 2024-07-02T11:20:49.327Z (4 months ago)
- Topics: ast, automotive, dbc, parser
- Language: Python
- Size: 137 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-canbus - pydbc - AST generator for dbc format. (CAN Database / DBC only)
README
# pydbc
## Status
![Test Python package](https://github.com/Sauci/pydbc/workflows/Test%20Python%20package/badge.svg)## Package description
The purpose of this package is to generate an AST based on the content of DBC-formatted string. Bellow a short example:
```python
from pydbc.parser import DbcParserdbc_data = """
VERSION "my_version"NS_ :
BU_EV_REL_
BU_BO_REL_BO_ 1234 my_message_name: 2 my_transmitter
SG_ my_first_signal_name : 56|8@1+ (16,0) [0|4000] "my_first_signal_unit" my_first_signal_transmitter
SG_ my_second_signal_name : 48|8@1+ (1,0) [0|250] "my_second_signal_unit" my_first_signal_transmitter
"""if __name__ == '__main__':
p = DbcParser(dbc_data)
assert p.ast.version == 'my_version'
assert p.ast.messages[0].identifier == 1234
first_signal = p.ast.messages[0].signals[0]
assert first_signal.name == 'my_first_signal_name'
assert first_signal.signal_size == 8
assert first_signal.start_bit == 56
assert first_signal.value_type == '+'
assert first_signal.factor == 16
assert first_signal.offset == 0
assert first_signal.minimum == 0
assert first_signal.maximum == 4000```
## Installation
### Using pip
run ```python -m pip install sauci-pydbc```