优化无线/有线CAN,以及控制指令解析
This commit is contained in:
@@ -12,7 +12,10 @@ from cognitive_agent.infrastructure.can.gateway import (
|
||||
ZlgCanBridgeProcess,
|
||||
ZlgChannelConfig,
|
||||
)
|
||||
from cognitive_agent.infrastructure.can.hardware import VehicleCanSettings
|
||||
from cognitive_agent.infrastructure.can.hardware import (
|
||||
SeatHardwareSettings,
|
||||
VehicleCanSettings,
|
||||
)
|
||||
from cognitive_agent.infrastructure.can.zlgcan_linux_bridge import (
|
||||
EXPECTED_ABI_SIZES,
|
||||
Driver,
|
||||
@@ -113,6 +116,34 @@ class LinuxZlgBridgeTests(unittest.TestCase):
|
||||
self.assertTrue(settings.bridge_script.name.endswith("linux_bridge.py"))
|
||||
self.assertTrue(settings.public_info()["state_configured"])
|
||||
|
||||
def test_linux_wired_vehicle_enables_native_passenger_can0_profile(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
library = Path(directory) / "libusbcanfd.so"
|
||||
library.write_bytes(b"test")
|
||||
environment = {
|
||||
"COGNITIVE_AGENT_VEHICLE_CAN_ENABLED": "true",
|
||||
"COGNITIVE_AGENT_VEHICLE_CAN_BACKEND": "zlgcan-linux",
|
||||
"COGNITIVE_AGENT_WIRED_PASSENGER_CAN_ENABLED": "true",
|
||||
"COGNITIVE_AGENT_SEAT_CAN_CHANNEL": "0",
|
||||
"COGNITIVE_AGENT_HARDWARE_APPROVAL_TOKEN_REQUIRED": "false",
|
||||
"COGNITIVE_AGENT_ZLGCAN_PYTHON": sys.executable,
|
||||
"COGNITIVE_AGENT_ZLGCAN_LINUX_LIBRARY": str(library),
|
||||
}
|
||||
with patch.dict(os.environ, environment, clear=True):
|
||||
settings = SeatHardwareSettings.from_env(REPOSITORY_ROOT)
|
||||
self.assertTrue(settings.native_passenger_can0)
|
||||
self.assertTrue(settings.configured)
|
||||
self.assertEqual(settings.backend, "zlgcan-linux")
|
||||
self.assertEqual(settings.channel, "0")
|
||||
self.assertEqual(settings.device_type, 33)
|
||||
self.assertFalse(settings.termination_enabled)
|
||||
self.assertFalse(settings.auto_flash_enabled)
|
||||
self.assertFalse(settings.position_sync_enabled)
|
||||
self.assertEqual(
|
||||
settings.public_info()["protocol_profile"],
|
||||
"passenger-seat-native-can0-v1",
|
||||
)
|
||||
|
||||
def test_process_passes_monitor_and_trace_flags_to_bridge(self) -> None:
|
||||
process = Mock()
|
||||
process.stdout = io.StringIO('{"ok":true,"event":"ready"}\n')
|
||||
|
||||
Reference in New Issue
Block a user