コード例 #1
0
def test_load_valid_lin22():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin22.ldf")
    ldf = ldfparser.parseLDF(path)

    assert ldf.protocol_version == 2.2
    assert ldf.language_version == 2.2
    assert ldf.baudrate == 19200
    assert ldf.channel == 'DB'

    internalLightRequest = ldf.signal('InternalLightsRequest')
    assert internalLightRequest is not None
    assert internalLightRequest.publisher.name == 'CEM'
    assert len(internalLightRequest.subscribers) == 2
    assert internalLightRequest in ldf.master.publishes

    assert ldf.frame('LSM_Frm2') is not None
    assert ldf.frame(0x03) is not None

    LSM = ldf.slave('LSM')
    assert LSM is not None
    assert LSM.product_id.supplier_id == 0x4A4F
    assert LSM.product_id.function_id == 0x4841

    converter = ldf.converters['InternalLightsRequest']
    assert converter.name == 'Dig2Bit'
    assert isinstance(converter._converters[0], LogicalValue)
コード例 #2
0
def test_no_signal_subscribers():
    path = os.path.join(os.path.dirname(__file__), "ldf",
                        "no_signal_subscribers.ldf")
    ldf = ldfparser.parseLDF(path)

    assert ldf.protocol_version == 2.2
    assert ldf.language_version == 2.2
    assert ldf.baudrate == 19200

    assert ldf.signal('DummySignal_0') is not None
    assert ldf.frame('DummyFrame') is not None
コード例 #3
0
def test_load_valid_lin20():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin20.ldf")
    ldf = ldfparser.parseLDF(path)

    assert ldf.protocol_version == 2.0
    assert ldf.language_version == 2.0
    assert ldf.baudrate == 19200

    assert ldf.signal('InternalLightsRequest') is not None
    assert ldf.frame('VL1_CEM_Frm1') is not None
    assert ldf.slave('LSM') is not None
コード例 #4
0
def test_load_valid_lin13():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin13.ldf")
    ldf = ldfparser.parseLDF(path)

    assert ldf.protocol_version == 1.3
    assert ldf.language_version == 1.3
    assert ldf.baudrate == 19200

    assert ldf.master.timebase == 0.005
    assert ldf.master.jitter == 0.0001

    assert ldf.signal('StartHeater') is not None
    assert ldf.frame('VL1_CEM_Frm1') is not None
    assert ldf.slave('LSM') is not None
コード例 #5
0
def test_load_valid_lin21():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin21.ldf")
    ldf = ldfparser.parseLDF(path)

    assert ldf.protocol_version == 2.1
    assert ldf.language_version == 2.1
    assert ldf.baudrate == 19200
    assert ldf.channel == 'DB'

    internalLightRequest = ldf.signal('InternalLightsRequest')
    assert internalLightRequest is not None
    assert internalLightRequest.publisher.name == 'CEM'
    assert len(internalLightRequest.subscribers) == 2
    assert internalLightRequest in ldf.master.publishes

    assert ldf.frame('LSM_Frm2') is not None
    assert ldf.frame(0x03) is not None
    assert ldf.slave('LSM') is not None
コード例 #6
0
ファイル: test_comment.py プロジェクト: sdiricco1/ldf-parser
def test_comment_collection_lin13():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin13.ldf")
    ldf = ldfparser.parseLDF(path, captureComments=True)
    assert len(ldf.comments) >= 0
    assert '// This is a LIN description example file' in ldf.comments
コード例 #7
0
ファイル: test_comment.py プロジェクト: sdiricco1/ldf-parser
def test_comment_collection_lin22():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin22.ldf")
    ldf = ldfparser.parseLDF(path, captureComments=True)
    assert len(ldf.comments) >= 0
    assert "// Source: https://lin-cia.org/fileadmin/microsites/lin-cia.org/resources/documents/LIN_2.2A.pdf" in ldf.comments
コード例 #8
0
ファイル: test_comment.py プロジェクト: sdiricco1/ldf-parser
def test_comment_collection_lin20():
    path = os.path.join(os.path.dirname(__file__), "ldf", "lin20.ldf")
    ldf = ldfparser.parseLDF(path, captureComments=True)
    assert len(ldf.comments) >= 0
コード例 #9
0
ファイル: communication.py プロジェクト: sdiricco1/ldf-parser
import os
import ldfparser


class LinMaster:
    def send_frame(self, baudrate: int, frame_id: int, data: bytearray):
        # LIN Tool specific functionality
        pass


if __name__ == "__main__":
    path = os.path.join(os.path.dirname(__file__), 'lin22.ldf')
    ldf = ldfparser.parseLDF(path)
    lin_master = LinMaster()
    requestFrame = ldf.frame('CEM_Frm1')
    requestData = requestFrame.data({"InternalLightsRequest": 'on'},
                                    ldf.converters)

    lin_master.send_frame(ldf.baudrate, requestFrame.frame_id, requestData)
コード例 #10
0
ファイル: read_comments.py プロジェクト: sdiricco1/ldf-parser
import os
import ldfparser

if __name__ == "__main__":
    path = os.path.join(os.path.dirname(__file__), 'lin22.ldf')
    ldf = ldfparser.parseLDF(path, captureComments=True)
    print(ldf.comments)