def test_frame_raw_encoding_out_of_range(): signal1 = LinSignal('Signal_1', 8, 0) signal2 = LinSignal('Signal_2', 4, 0) signal3 = LinSignal('Signal_3', 1, 0) frame = LinFrame(1, 'Frame_1', 2, {0: signal1, 8: signal2, 15: signal3}) with pytest.raises(Exception): frame.raw({ 'Signal_1': 100, 'Signal_2': 30, 'Signal_3': 1 })
def test_frame_raw_encoding_array(): signal1 = LinSignal('Signal_1', 16, [0, 0]) frame = LinFrame(1, 'Frame_1', 2, {0: signal1}) content = frame.raw({ 'Signal_1': [1, 2] }) assert list(content) == [1, 2]
def test_frame_raw_encoding_array2(): signal1 = LinSignal('Signal_1', 16, [0, 0]) signal2 = LinSignal('Signal_2', 8, 0) frame = LinFrame(1, 'Frame_1', 3, {0: signal1, 16: signal2}) content = frame.raw({ 'Signal_1': [1, 2], 'Signal_2': 3 }) assert list(content) == [1, 2, 3]
def test_frame_raw_encoding_no_signal(): signal1 = LinSignal('Signal_1', 8, 255) signal2 = LinSignal('Signal_2', 4, 255) signal3 = LinSignal('Signal_3', 1, 255) frame = LinFrame(1, 'Frame_1', 2, {0: signal1, 8: signal2, 15: signal3}) content = frame.raw({ 'Signal_2': 10, 'Signal_3': 1 }) assert list(content) == [255, 10 | 1 << 7]