跳转到内容

XCP ​

EcuBus-Pro 包含一个 ASAM MCD-1 XCP 主站,用于通过 CAN / CAN-FD、UDP 和 TCP 连接到 XCP 从站。您可以在 GUI 中配置连接、查看从站能力和 DAQ 事件通道、在 Trace 窗口中监控解码后的 XCP 流量,并通过 TypeScript 脚本自动化测量、标定和编程。

XCP 配置窗口 ​

通过菜单栏中的 诊断 → XCP 打开 XCP 配置窗口。

  1. 在连接树中点击 添加 以创建新的 XCP 连接。
  2. 为连接指定唯一的 名称(该名称可通过 XcpCreateConnection('name') 从用户脚本中直接引用)。
  3. 选择 传输层 并填写传输参数,然后保存。
  4. 使用 连接 / 探测 发送 CONNECT、读取从站属性(MAX_CTO、MAX_DTO、字节序、地址粒度、资源),并可选择查询 DAQ 事件通道(GET_DAQ_EVENT_INFO)。

支持的传输层 ​

传输层关键设置备注
CAN / CAN-FDCAN 设备、canIdCmd(主站 → 从站)、canIdResp(从站 → 主站)、11 位/29 位扩展 ID、CAN-FD / BRS、填充字节和 DLC支持经典 CAN(最多 8 字节)和 CAN-FD(最多 64 字节),可选帧填充。
UDP远程 IP / 主机名、远程端口、超时使用标准的 4 字节 XCP-on-Ethernet 帧格式(LEN + CTR)。
TCP远程 IP / 主机名、远程端口、超时在持久 TCP 流上使用标准的 4 字节 XCP-on-Ethernet 帧格式。

网络视图 ​

已保存的 XCP 连接会显示在 网络 视图中,并链接到其配置的 CAN 或以太网硬件节点。 While a user script holds an XCP connection open, the Network view displays its live open status.

Trace Window ​

All XCP packets transmitted and received by EcuBus-Pro are logged to the Trace window with decoded symbols prefixed by the connection name:

  • Commands (Master → Slave): <conn>.CONNECT, <conn>.SHORT_UPLOAD, <conn>.DOWNLOAD, <conn>.GET_VERSION, etc.
  • Responses & Errors (Slave → Master): <conn>.RES, <conn>.ERR_ACCESS_LOCKED, <conn>.ERR_OUT_OF_RANGE, etc.
  • Events & Service Requests: <conn>.EV_DAQ_OVERLOAD, <conn>.EV_CMD_PENDING, <conn>.SERV_TEXT, etc.
  • DAQ / STIM DTOs: <conn>.DAQ<list>.ODT<odt> (decoded according to the slave's DAQ_KEY_BYTE identification field and byte order).

Use the Trace filter to isolate XCP traffic (xcpSent, xcpRecv, xcpErr, xcpEvent, xcpDaq).

Script API ​

User scripts import XCP helpers from 'ECB'. You can open either a saved connection by name or an inline CAN / UDP / TCP address. Any unclosed handles are automatically cleaned up when the project stops.

ts
import {
  Util,
  XcpCreateConnection,
  XcpCloseConnection,
  XcpConnect,
  XcpDisconnect,
  XcpSetMta,
  XcpUploadBytes,
  XcpShortUpload,
  XcpDownload
} from 'ECB'

Util.Init(async () => {
  // Open a connection saved in Diagnostics -> XCP (or pass an inline CAN/UDP/TCP object)
  const handle = await XcpCreateConnection('ecu')
  // Inline UDP example:
  // const handle = await XcpCreateConnection({ transport: 'udp', ip: '127.0.0.1', port: 5555 })

  try {
    const info = await XcpConnect(handle)
    console.log(
      `Connected: MAX_CTO=${info.maxCto}, MAX_DTO=${info.maxDto}, byteOrder=${info.commModeBasic.byteOrder}`
    )

    // Read 4 bytes directly with SHORT_UPLOAD
    const sample = await XcpShortUpload(handle, 4, 0x1000)
    console.log('SHORT_UPLOAD:', sample)

    // Read a larger block automatically split across MAX_CTO chunks
    await XcpSetMta(handle, 0x1000)
    const block = await XcpUploadBytes(handle, 32)
    console.log('UPLOAD_BYTES:', block.length)

    // Write calibration bytes (accepts number[], Uint8Array, or Buffer)
    await XcpSetMta(handle, 0x2000)
    await XcpDownload(handle, Buffer.from([0x01, 0x02, 0x03, 0x04]))

    await XcpDisconnect(handle)
  } finally {
    await XcpCloseConnection(handle)
  }
})

Available Worker Helpers ​

  • Session & Identification: XcpCreateConnection, XcpCloseConnection, XcpConnect, XcpDisconnect, XcpGetStatus, XcpSynch, XcpGetCommModeInfo, XcpGetVersion, XcpGetId, XcpReadId, XcpSetRequest, XcpGetSeed, XcpUnlock
  • Memory Transfer & Calibration: XcpSetMta, XcpUpload, XcpUploadBytes, XcpShortUpload, XcpBuildChecksum, XcpDownload, XcpDownloadNext, XcpShortDownload, XcpModifyBits, XcpSetCalPage, XcpGetCalPage, XcpCopyCalPage, XcpGetPagProcessorInfo
  • DAQ: XcpGetDaqProcessorInfo, XcpGetDaqResolutionInfo, XcpGetDaqEventInfo, XcpGetDaqClock, XcpFreeDaq, XcpAllocDaq, XcpAllocOdt, XcpAllocOdtEntry, XcpClearDaqList, XcpSetDaqPtr, XcpWriteDaq, XcpSetDaqListMode, XcpStartStopDaqList, XcpStartStopSynch, XcpReadIndication
  • Programming (PGM): XcpProgramStart, XcpProgramClear, XcpProgram, XcpProgramNext, XcpProgramReset, XcpProgramVerify