ZHDA226 July 2026 AM13E23019 , AM13E232N9
图 5-1 PCAN 帧
图 5-2 TX 控制台日志输出sudo ip link set can0 up
sudo ip link set can0 type can bitrate 250000
图 5-3 DroneCAN 帧
图 5-4 创建新 PCAN 帧
图 5-5 PCAN 帧的属性import time
# Clean state tracker for the incrementing byte
tx_state = {'counter': 0}
def send_classical_can_frame():
try:
# 1. Build your exact 8-byte payload structure
payload_bytes = bytearray([tx_state['counter'] & 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6])
# 2. Modify the ID flags:
# (1 << 31) forces Extended 29-bit ID representation (REQUIRED for 0x1801550A)
# REMOVED: (1 << 30) - This completely disables the CAN FD BRS high-speed bit rate switch
can_id_flags = 0x1801550A | (1 << 31)
# 3. Inject directly into the positional driver hook
can_send(can_id_flags, payload_bytes)
# Print confirmation logs locally inside your Linux window
hex_string = " ".join(f"{b:02X}" for b in payload_bytes)
print(f"[CLASSICAL CAN TX] ID: 0x1801550A | Data: {hex_string}")
# Increment counter stepping up sequentially
tx_state['counter'] = (tx_state['counter'] + 1) % 256
except Exception as err:
print(f"[TX ERROR]: {err}")
# Wipe all old background timers completely
stop()
# Force kill any lingering heartbeat ghosts on the driver instance
try:
__get_node__().heartbeat_publisher.stop()
except:
pass
# Start the new Classical CAN loop executing at a 1-second interval
classical_task = periodic(1.0, send_classical_can_frame)
print("\n>>> ACTIVE: Classical CAN Extended frame loop running at 1Hz! <<<")
#NOTE: The above example sends a CAN frame whose source ID corresponds to node 10(0A), to change this, change the last 2 bytes to the respective source node
图 5-6 RX 串行端口上解码后的节点状态
图 5-7 来自主机的检测信号节点状态