| 1 |
import unittest |
| 2 |
|
| 3 |
import numpy as np |
| 4 |
|
| 5 |
from asammdf.blocks import bus_logging_utils as blu |
| 6 |
|
| 7 |
|
| 8 |
class TestCANTP(unittest.TestCase): |
| 9 |
tempdir = None |
| 10 |
|
| 11 |
payload = np.vstack( |
| 12 |
[ |
| 13 |
np.frombuffer(b"\x10\x0b\x52\x49\x47\x20\x20\x39", dtype="uint8"), # Initial part |
| 14 |
np.frombuffer(b"\x30\xff\x00\x4c\x40\x00\xd5\x54", dtype="uint8"), # Flow control |
| 15 |
np.frombuffer(b"\x21\x30\x30\x30\x38\x33\x00\x00", dtype="uint8"), # Final (second) part |
| 16 |
np.frombuffer(b"\x10\x0b\x52\x49\x47\x20\x20\x39", dtype="uint8"), # Initial part of next frame... |
| 17 |
] |
| 18 |
) |
| 19 |
ts = np.array([0.112, 0.113, 0.116, 0.201]) |
| 20 |
|
| 21 |
def test_merge_cantp(self) -> None: |
| 22 |
merged, t = blu.merge_cantp(TestCANTP.payload, TestCANTP.ts) |
| 23 |
|
| 24 |
assert merged.shape == (1, 11) |
| 25 |
assert merged[0, -1] == 0x33 |
| 26 |
assert t.shape == (1,) |
| 27 |
assert t[0] == 0.116 |