Vector - CAPL - 加入LIN检测事件

        其实对于LIN的加入事件来说,如果看过前面的等待获取不同类型的LIN帧的获取LIN帧数据和等待不同LIN帧类型的函数对比的话,就非常简单了,主要就是将不同的事件加入到事件集中,然后通过等待函数函数检测LIN总线上出现该事件的情况;如果找个例子来说的话,加入的事件就像一道道闸门,LIN总线的报文就像不同身份的人,只有符合通过闸门条件的情况下,才能够通过,然后等待函数将被触发。这部分主要根据大家实际工作中的需求来将事件加入事件集中,然后获取大家需要的信息。

目录

TestJoinLinCSErrorEvent 

代码示例

TestJoinLinETFSingleResponseEvent 

代码示例

TestJoinLinLongDominantSignal

代码示例

TestJoinLinSpike 

代码示例

TestJoinLinSyncErrorEvent 

代码示例

TestJoinLinHeaderEvent & TestJoinLinWakeupEvent 

代码示例

TestJoinLinReceiveErrorEvent &TestJoinLinTransmErrorEvent 

代码示例


TestJoinLinCSErrorEvent 

功能:将事件添加到已联接的事件集中。

事件:校验和错误、LIN事件触发的帧单响应、同步错误

说明:将校验和错误类型的事件添加到已联接的事件集中。这是一个非阻塞函数。

注意:根据所使用的参数类型,如果相应的数据库对象不明确,则只需在调用函数之前设置多总线环境中的适当总线上下文。

apDBMsg:定义报文类消息

aFrameId:LIN报文ID

返回值:

        -3:将指定的事件添加到已联接的事件集时出错

        -1:一般错误,例如功能不可用

        >0:新加入事件的编号

代码示例

testcase tcTFS_waitForLINResponse(int frameId)
{
   long eventIndex;

   testJoinMessageEvent(frameId);
   testJoinLinReceiveErrorEvent(frameId);
   testJoinLinCSErrorEvent(frameId);
   testJoinLinTransmErrorEvent(frameId);

   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1: // valid frame
         testStepPass("Validation", "IUT has responded correctly");
      break;

      case 2: // receive error
         testStepFail("Validation", "IUT has responded with wrong number of data bytes");
      break;

      case 3: // checksum error
         testStepFail("Validation", "IUT has responded with wrong checksum");
      break;

      case 4: // transmission error
         testStepFail("Validation", "IUT has not responded");
      break;

      default:
      testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for response", eventIndex);
   }
}

TestJoinLinETFSingleResponseEvent 

功能:将LIN事件触发的帧单一响应类型的事件添加到已加入的事件集。

aETFFrameId:LIN事件触发的待等待帧的帧标识符。

aAssocFrameId:与等待的事件触发帧相关联的LIN无条件帧的帧标识符。

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLinETFSingleResponse(int etfFrameId)
{
   long eventIndex;
   testJoinLinETFSingleResponseEvent(etfFrameId, linGetProtectedID(0x36));
   testJoinLinETFSingleResponseEvent(etfFrameId, linGetProtectedID(0x34));

   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1:
         testStepPass("Validation", "ETF single frame response occurred. FrameId=0x36");
      break;

      case 2:
         testStepPass("Validation", "ETF single frame response occurred. FrameId=0x34");
      break;

      default:
         testStepFail("Validation", "ETF single frame response not occurred");
   }
}

TestJoinLinLongDominantSignal

功能:用传输的事件完成当前一组已加入的事件。

说明:

此函数不等待。

在调用函数之前,请考虑始终在多总线环境中设置适当的总线上下文。

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLINHeader(int frameId)
{
   long eventIndex;
   testJoinLinHeaderEvent(frameId);
   testJoinLinLongDominantSignal();
   testJoinLinSyncErrorEvent();
   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1:
      testStepPass("Validation", "LIN Header for FrameId=0x%X occurred", frameId);
      break;
      case 2:
      testStepFail("Validation", "LIN long dominant signal occurred");
      break;
      case 3:
      testStepFail("Validation", "LIN Sync error occurred");
      break;
      default:
      testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for any LIN event", eventIndex);
   }
}

TestJoinLinSpike 

功能:用传输的事件完成当前一组已加入的事件。

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLINHeader(int frameId)
{
   long eventIndex;
   testJoinLinHeaderEvent(frameId);
   testJoinLinSpike();
   testJoinLinSyncErrorEvent();
   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1:
      testStepPass("Validation", "LIN Header for FrameId=0x%X occurred", frameId);
      break;

      case 2:
      testStepFail("Validation", "LIN Spike occurred");
      break;

      case 3:
      testStepFail("Validation", "LIN Sync error occurred");
      break;

      default:
      testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for any LIN event", eventIndex);
   }
}

TestJoinLinSyncErrorEvent 

功能:将类型为同步错误的事件添加到已联接的事件集中。

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLINHeader(int frameId)
{
   long eventIndex;

   testJoinLinHeaderEvent(frameId);
   testJoinLinWakeupEvent();
   testJoinLinSyncErrorEvent();

   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1:
         testStepPass("Validation", "LIN Header for FrameId=0x%X occurred", frameId);
      break;

      case 2:
         testStepFail("Validation", "LIN Wakeup signal occurred");
      break;

      case 3:
         testStepFail("Validation", "LIN Sync error occurred");
      break;

      default:
         testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for any LIN event", eventIndex);
   }
}

TestJoinLinHeaderEvent & TestJoinLinWakeupEvent 

功能:加入待等待帧的帧头Header信息到当前事件中

aFrame:加入待等待帧的帧头
 
aFrameId:加入待等待帧的ID

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLINHeader(int frameId)
{
   long eventIndex;

   testJoinLinHeaderEvent(frameId);
   testJoinLinWakeupEvent();
   testJoinLinSyncErrorEvent();

   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1:
         testStepPass("Validation", "LIN Header for FrameId=0x%X occurred", frameId);
      break;

      case 2:
         testStepFail("Validation", "LIN Wakeup signal occurred");
      break;

      case 3:
         testStepFail("Validation", "LIN Sync error occurred");
      break;

      default:
         testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for any LIN event", eventIndex);
   }
}

TestJoinLinReceiveErrorEvent &TestJoinLinTransmErrorEvent 

功能:加入待等待接收/传输帧的错误事件

aFrameId:待加入待等待接收/传输错误帧的ID

返回值:

-3:加入事件失败

-1:一般错误,例如,功能不可用

>0:已加入事件的编号

代码示例

testcase tcTFS_waitForLINResponse(int frameId)
{
   long eventIndex;

   testJoinMessageEvent(frameId);
   testJoinLinReceiveErrorEvent(frameId);
   testJoinLinCSErrorEvent(frameId);
   testJoinLinTransmErrorEvent(frameId);

   eventIndex = testWaitForAnyJoinedEvent(5000);
   switch (eventIndex)
   {
      case 1: // valid frame
         testStepPass("Validation", "IUT has responded correctly");
      break;

      case 2: // receive error
         testStepFail("Validation", "IUT has responded with wrong number of data bytes");
      break;

      case 3: // checksum error
         testStepFail("Validation", "IUT has responded with wrong checksum");
      break;

      case 4: // transmission error
         testStepFail("Validation", "IUT has not responded");
break;
      default:
         testStepFail("Validation", "Internal error! Unexpected event (return code %d) on waiting for response", eventIndex);
   }
}


 

        

猜你喜欢

转载自blog.csdn.net/weixin_54581097/article/details/129847842