如何使用OSEK_TP.dll

1. 加载dll

includes
{
 #pragma library("..\dll\osek_tp.dll")
}

2. 设置诊断ID

variables
{
  const dword lrrDiag_TxId = 0x791;
  const dword lrrDiag_RxId = 0x711;
  const byte tpPaddingByte = 0xCC;
  byte diagDataBuff[4096];
  long receLength;
  long tpHandle;
  byte gReceUpdateFlag = 0;
  mstimer mainTimer;
}

使能诊断连接

  tpHandle = CanTpCreateConnection(0);
  CanTpSetTxIdentifier(tpHandle, lrrDiag_TxId); //设置ID
  CanTpSetRxIdentifier(tpHandle, lrrDiag_RxId);  
  OSEKTL_SetRxId(lrrDiag_RxId);
  CanTpSetPadding(tpHandle, tpPaddingByte);//设置填充位
  gReceUpdateFlag =0;
  receLength =0;
  setTimer(mainTimer,10);

3. 实现回调函数

OSEKTL_DataInd( long count) 
{
  OSEKTL_GetRxData( diagDataBuff, elcount( diagDataBuff));
  receLength = count;
}
void CanTp_ReceptionInd( long connHandle, byte data[])
{
  long byteCnt=0;
  for (byteCnt=0; byteCnt<receLength; byteCnt++)
  {
    write("Received Data[%d] is %x", byteCnt, diagDataBuff[byteCnt]);
  }
  gReceUpdateFlag = 1;
}

4. 发送诊断报文

byte rspData[6] = {0x50, 0x03, 0x00, 0x32, 0x01, 0xF4};
  CanTpSendData(handle, rspData, elcount(rspData));
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值