该命令将加密密钥写入适配器。该密钥是 PassThruSecurityConnect 函数正常工作所必需的。如果密钥填充为 0xFF 或 0x00,则 PassThruSecurityConnect 命令将无法工作。此命令由程序制造商在适配器出售准备阶段执行。重复执行该命令可能会覆盖新的密钥。
long SetKey(unsigned long DeviceID, unsigned char* pKey )
| 定义 | 说明 |
|---|---|
| STATUS_NOERROR | 函数执行成功 |
| ERR_DEVICE_NOT_CONNECTED | 未与适配器建立连接。可能的原因:适配器已关闭、无网络,或 IP 地址设置不正确。 |
| ERR_INVALID_DEVICE_ID | 指定了不存在的适配器标识符 DeviceID |
#include "j2534_lib.hpp"
unsigned long DeviceID;
unsigned long Ret;
unsigned char Key[176];
Ret = SetKey(DeviceID, Key);
if (Ret != STATUS_NOERROR)
{ // 错误处理
}