【CAPL入门知识】

CAPL常识

这是我经常要回顾的CAPL知识。

  • Event事件

    • Start of Measurement
      	  on start{
      	  	write("Start CANalyzer");
      	  }
      
    • Stop of Measurement
      	  on stopMeasurement{
      	  	write("stop CANlyzer");
      	  }
      
    • CAN message
      	  on message 0x123{
      	  	write("CAN Message 0x123");
      	  }
      
    • Time event
      	  on timer tmrCycle{
      	  	write("within cycle");
      	  }
      
    • Keystroke
      	  on key 'a'{
      	  	write("Key>a<pressed");
      	  }
      

变量类型
无
无
无

CAPL函数

这是我一些常用的CAPL函数

常用的CAPL函数

  • 变量
char[]int、byte、word、dword、qword
message
frFrame、frPDU、frConfiguration、PDU
Class: Timer、MsTimer
class:File、TestCheck、TestStimulus、CAN
enumstruct
dbMsg *、dbNode *、dbPDU *、dbFrFrame *、dbFrPDU *、signal *
@、$、const
Class:DiagRequest、DiagResponse、ethernetPacket、UdpSocket、TcpSocket
SysVarIntArray
$EngineSpeed.txrq.raw
//special macros
%BUS_TYPE%%CHANNEL%%NETWORK_NAME%%NODE_NAME%
Channels[]
struct: canSettings{
	float baudrate; //in bit/s
	unsigned char tseg1, tseg2; //length of the time segments 1 and 2 in time quanta
	unsigned char sjw; //sync jump width in time quanta
	unsigned char sam; //number of sampling points (1 or 3). Only valid for CAN. For CAN FD "sam" is hard coded to 1.
	unsigned int flags; //see description below
};
  • 系统函数
on prestart、on start
on message
on timer
on key
on sysvar、on sysvar_update
on signal、on singal_update
on FRStartCycle、on FRSlot、on frframe
on prestop、on stopMeasurement
  • 常用函数
void setWriteDbgLevel (unsigned int priority);
long writeDbgLevel(unsigned int priority, char format1[], char format2[], ...);
void setTimer(msTimer t, long duration); settimercyclic()
void cancelTimer(msTimer t);
void output(message msg);
long sysSetVariableLongArray(SysVarName, long values[], long arraySize);
long sysGetVariableLongArray(SysVarName, long values[], long arraySize);
void frSetSendFrame( <frame object> ); 
int ret = frUpdateStatFrame( <frame var> );
random()SilentNM()TalkNM()GotoMode_BusSleep()GotoMode_Awake()ReinitSleepTimer()
SysSetVariableData()sysGetVariableData()SysSetVariableString()sysGetVariableString()
writeCreate()writeLineEx()writeToLogEx()runError()elcount()
SetBusContext()GetBusNameContext()GetBusContext()putValueToControl()setBusContext(GetBusNameContext())
TimeNow()timeNowFloat()timeNowNS()timeNowInt64()getLocalTimeString()getLocalTime(long time[])timeToElapse(mstimer t)timeDiff()MessageTimeNS()getSignalTime()getSignalTimeByTxNode() 
testReportFileName()setLogFileName()startLogging()stopLogging()
//字符串相关
strncpy()strncpy_off()mbstrncpy()mbstrncpy_off()mbsubstr_cpy(), mbsubstr_cpy_off()substr_cpy_off()substr_cpy()strncmp()strncmp_off()mbstrncmp()mbstrncmp_off()strstr()strstr_off()mbstrstr()mbstrstr_off()strstr_regex()strstr_regex_off()strncat()strlen()mbstrlen()snprintf()
//结构体相关
memcpy()memcpy_h2n()memcpy_n2h()memcmp()_align()__size_of()__alignment_of()__offset_of()
elcount()toUpper()toLower()stop()_round()canOffline()canOnline()getSignal()getSignalByTxNode()setSignal()SetSignalByTxNode()
lookupMessage()lookupNode()lookupPDU()lookupFrFrame()lookupFrPDU()lookupSignal()

canSetChannelOutput()
isSimulated()
snprintf()

常用的Test函数

  • 常见的test函数
 TestStepPass、TestStepFail、TestStepWarning、TestCaseDescription、
 TestCaseComment、teststep、testCaseTitle、TestWaitForTesterConfirmation
 
 TestJoinMessageEvent、TestJoinTextEvent、TestJoinEnvVarEvent、TestJoinSignalMatch、  
 TestJoinSignalInRange、TestJoinSignalOutsideRange、TestJoinFrFrameEvent、 
 TestJoinSysVarEvent、TestJoinPDUEvent、TestJoinFrStartCycleEvent、TestJoinFrPDUEvent、  
 TestJoinFrNullFrameEvent、TestJoinFrFrameErrorEvent、TestJoinEthernetPacket、  
 TestJoinEthernetLinkStatus......  
   
 TestWaitForAllJoinedEvents、TestWaitForAnyJoinedEvent、TestWaitForMessage、  
 TestWaitForFrFrame、TestWaitForPDU、TestWaitForSysVar、TestWaitForTextEvent、  
 TestWaitForTimeout、TestWaitForSignalOutsideRange、TestWaitForSignalInRange、  
 TestWaitForSignalMatch......  
 long TestWaitForMessage(dbMsg aMessage, dword aTimeout);  
 long TestWaitForMessage(dword aMessageId, dword aTimeout);  
 long TestWaitForMessage(dword aTimeout);  
   
 TestGetWaitEventMsgData、testGetWaitScopeEventData、TestGetWaitPDUData、  
 TestGetWaitFrFrameData、TestGetWaitFrPDUData、TestGetWaitPDUsTPTCPSrcPort、  
 TestGetWaitPDUsTPUDPSrcPort、TestGetWaitPDUsTPTCPDstPort、 
 TestGetWaitPDUsTPIPv4SrcAddr、TestGetWaitPDUsTPIPv4DstAddr、TestGetWaitPDUsTPUDPDstPort  
   
 TestSetMsgEven、TestSetMsgCycleTime、TestSetMsgDlc、TestResetMsgCycleTime...  
 ChkQuery_NumEvents、ChkQuery_EventSignalValueMin、ChkQuery_EventSignalValueMax、  
 ChkQuery_EventMessageId、ChkQuery_EventMessageName、ChkQuery_EventNodeName、
 ChkQuery_EventSignalValue...  
   
 ChkStart_MsgSignalValueInvalid、ChkStart_MsgDistViolation、ChkStart_MsgOccurrenceCount、  
 ChkStart_MsgRelCycleTimeViolation、ChkStart_MsgAbsCycleTimeViolation、  
 ChkStart_MsgSignalValueRangeViolation、ChkStart_SignalValueChange、  
 ChkStart_SignalCycleTimeViolation、ChkStart_NodeMsgsRelCycleTimeViolation、  
 ChkStart_UndefinedMessageReceived、ChkStart_TimeoutChkStart_ErrorFramesOccured、  
 ChkStart_InconsistentDLC、ChkStart_InconsistentTxDLC、ChkStart_InconsistentRxDLC... 
 
 TestAddCondition、TestRemoveCondition、TestAddConstraint、TestRemoveConstraint、
 ChkControl_Stop、ChkControl_Start、ChkControl_Reset、ChkControl_Destroy、
 
 handle = TestCreateStringInputTable("Test Text", "Test Caption", "Test String Input Table Timeout");
 TestAddStringTableEntry(handle, "Test Entry");
 TestWaitForInput(handle, 5000);
 TestGetStringInput(resultStr, elcount(resultStr));
 handle = TestCreateValueInputTable("Test Text", "Test Caption", "Test Value Input Table Timeout");
 TestAddValueTableEntry(handle, 9);
 TestWaitForInput(handle, 5000);
 write("Result: %f", TestGetValueInput());

 testGetCurrentTestCaseTitle()TestReportAddExternalRef()
  • 诊断相关
class:DiagResponse、DiagRequest
系统函数:on diagResponse、on diagRequst
函数:testWaitForDiagRequestSent()testWaitForDiagResponse()diagGetResponseCode()diagGetLastResponseCode()DiagSendNegativeResponse()DiagGetParameter()DiagSetParameter()DiagSendResponse()diagResize()diagSetComplexParameter()CanTpSendData()CanTpCreateConnection()CanTpSetTxIdentifier()CanTpSetRxIdentifier()CanTpGetSetAddressType()diagGetCommParameter()

Scope CAPL Functions

  • class类
ScopeAnalysisSetup{.samplePoint(char) |.samplePointDataPhase(char)}
scopeBitData{type,typeEx,bitValue,startTime,bitLength,signalVoltage,signalPolarity}
struct: canSettings{
  float baudrate; //in bit/s
  unsigned char tseg1, tseg2; //length of the time segments 1 and 2 in time quanta
  unsigned char sjw; //sync jump width in time quanta
  unsigned char sam; //number of sampling points (1 or 3). Only valid for CAN. For CAN FD "sam" is hard coded to 1.
  unsigned int flags; //see description below
  };
ScopeBitMaskPolygon{maskPointCount,data_0_Mask,data_1_Mask,timeOffset}
ScopeAnalyseHandle{handle(long)}
ScopeAnalyseResult{result,analysedFrameCount,framesWithDecodeFailure,framesWithMaskViolations,bitFailureCount}

  • Function
on ScopeEvent

scopeConnect()
scopeDisconnect()
scopeTriggerNow()
testWaitForScopeEvent()
canFdGetConfiguration()
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值