Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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 DbcParser

dbc_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```