cpp sdk更新

This commit is contained in:
cyy_mac
2026-07-30 19:23:47 +08:00
parent bd07331734
commit 7e4f632268
3 changed files with 303 additions and 61 deletions

View File

@@ -3,6 +3,8 @@ import os
import pytest
from fast_lowcmd import FastLowCmdBuilder, default_state_path
from fast_mcu import FastMCUClient
from go1_fast_lowcmd import FastNativeMCUClient
from go1_pro_sdk import Blowfish, LowCmd, MotorCmd, MotorMode, PowerProtectViolation
from go1_pro_sdk import apply_safety
from go1_pro_sdk.codec.lowcmd_builder import build_low_cmd_encrypted, build_low_cmd_plain
@@ -140,9 +142,30 @@ def test_state_file_is_required():
FastLowCmdBuilder(os.path.join(os.path.dirname(__file__), "missing_state.bin"))
def test_native_mcu_client_empty_recv():
client = FastNativeMCUClient(default_state_path(), "127.0.0.1", 8007, 0, 4096, "little")
try:
assert client.local_port() > 0
assert client.recv_latest_fields() is None
finally:
client.close()
def test_fast_mcu_uses_native_udp_client():
client = FastMCUClient(mcu_ip="127.0.0.1", mcu_port=8007, local_port=0)
try:
assert client.backend == "cpp_lowcmd_cpp_lowstate_cpp_udp"
assert client.local_port > 0
assert client.recv_latest() is None
finally:
client.close()
def test_lowstate_decrypt_matches_python(builder, bf):
root = os.path.dirname(os.path.dirname(__file__))
packet_path = os.path.join(root, "data", "captures", "mcu_response.bin")
if not os.path.exists(packet_path):
pytest.skip("private LowState capture is not available")
with open(packet_path, "rb") as f:
packet = f.read()