CAN驱动总线(高速),500Kbit/s,可基本满足实时要求。
CAN舒适总线(低速),100 Kbit/s,用于对时间要求不高的情况。
数据传输终端:是一个电阻,防止数据在线端被反射,以回声的形式返回,影响数据的传输。
数据传输线:双向数据线,由高低双绞线组成。
当车辆使用诊断CANBUS总线结构后,VAS5051等诊断仪器必须使用相对应的新型诊断线(VAS5051/5A或VAS5051/6A), 否则无法读出相应的诊断信息。另外,车上的诊断接口也作出了相应的改动,具体信息看如下图表: 注:5051仪器的版本号必须大于3.0以上 才能使用诊断CANBUS总线。 新型诊断线能够适用于旧型诊断接口。


CAN具有以下的属性:
• 报文的优先权
• 保证延迟时间
• 设置灵活
• 时间同步的多点接收
• 系统内数据的连贯性
• 多主机
• 错误检测和错误标定
• 只要总线一处于空闲,就自动将破坏的报文重新传输
• 将节点的暂时性错误和永久性错误区分开来,并且可以自动关闭由OSI参考模型分层CAN结构的错误的节点。


错误帧

过载帧

错误类型和界定
5种错误类型�
应用

on sysvar_change (sysvar::TransitionTimeMeasurement::SignalUsedForMeasurement | sysvar::TransitionTimeMeasurement::ThresholdInPercent)
{
switch(@sysvar::TransitionTimeMeasurement::SignalUsedForMeasurement)
{
case 0:
if(@sysvar::TransitionTimeMeasurement::ThresholdInPercent == 0)
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 2630;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 3590;
}
else
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 10;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 90;
}
break;
case 1:
if(@sysvar::TransitionTimeMeasurement::ThresholdInPercent == 0)
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 1565;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 2485;
}
else
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 10;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 90;
}
break;
case 2:
if(@sysvar::TransitionTimeMeasurement::ThresholdInPercent == 0)
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 186;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 2073;
}
else
{
@sysvar::TransitionTimeMeasurement::ThresholdStart = 10;
@sysvar::TransitionTimeMeasurement::ThresholdEnd = 90;
}
break;
}
}
test如何立即执行

测量开始的默认窗口

节点的属性宏-可调用
- %NODE_NAME%
Node name//只能用在节点中,不能用在test - %CHANNEL%
Number of the channel to which the node is assigned. - %NETWORK_NAME%
Number of the network to which the node is assigned. - %FILE_NAME%//XX.can
Name of the file that contains the source code (e.g. SomeIncludeFile.cin). - %FILE_NAME_NO_EXT%//XX
Name of the file that contains the source code but without file extension (e.g. SomeIncludeFile). - %BASE_FILE_NAME%//
Name of the .can file that is just compiled (e.g. SomeFile.can); especially useful in include files. - %BASE_FILE_NAME_NO_EXT%
Name of the .can file that is just compiled but without file extension (e.g. SomeFile); especially useful in include files. - %BUS_TYPE%//CAN/LIN
Bus type of the channel to which the node is assigned.
write("The node name is %NODE_NAME%");
write("Activated functionality in network %NETWORK_NAME% (Channel %BUS_TYPE%%CHANNEL%)");
message * canTestMessage;//要测量的message
message EngineData msg1;
//enable ACK
canSetChannelOutput(%CHANNEL%, 1);//默认是1 可写可不写,停发的时候可以写0
canTestMessage = msg1;//可重复赋值
canTestMessage.can = %CHANNEL%;
variables
{
char scopeTestStepName[256];const long domVoltageThreshold = 900; //mV
const long recVoltageThreshold = 500; // mV//bit masks used for analysis
ScopeBitMaskPolygon bitMaskArb;
ScopeBitMaskPolygon bitMaskBRS;
ScopeBitMaskPolygon bitMaskData;
ScopeBitMaskPolygon bitMaskCRCdel;
//bit lengths in ns
double bitLengthArb, bitLengthBRS, bitLengthData, bitLengthCRCdel;//the one and only analysis handle used for all analysis functions
ScopeAnalyseHandle scopeAnlyzHandle = {Handle = 999};
long maxNumOfErrorsToShow = 10; //max. number of errors added in test report
CANSettings arbPhaseSettings;
CANSettings dataPhaseSettings;
}
nt WaitForAnyCANMessage()
{
long res;
res = TestWaitForMessage(1000);if(res < 0){
testStepFail(testStepName, "No message received", "");
return 0;
}
res = TestGetWaitEventMsgData(canTestMessage);//获取数据到cantestmessage
if(res != 0){
testStepFail(testStepName, "No message received", "");
return 0;
}
return 1;
}
testfunction Init ()
{
maxNumOfErrorsToShow =10;
InitBitMaskArbitration();
InitBitMaskBRS();
InitBitMaskData();
InitBitMaskCRCdel();strncpy(testStepName, "Test Prepration", testStepNameLength);
testWaitForTimeout(1000); //needed for virtual scope, if test modul is started immiditly
if(DoScopeConnect() <= 0 ) return;
if(!WaitForAnyCANMessage())
{
write("Waiting for CAN message failed");
return;
}
if(!DoScopeTrigger())
{
write("Scope trigger failed");
return;
}
{
long res;
res = testWaitForScopeFitData(canTestMessage, eCAPLScopeDataField_CAN_MESSAGE, eCAPLScopeDataField_CAN_MESSAGE);//前面必须获取数据到此message,此函数有效
if(CheckStatusInternal(res, "testWaitForScopeFitData"))//返回值正确
{
const long bufLength = 256;
char buffer[bufLength];
snprintf(buffer, bufLength, "Frame under test. ID = %d, DLC = %d, EDL = %d, BRS = %d",
valOfId(canTestMessage.id), canTestMessage.dlc, canTestMessage.edl, canTestMessage.BRS);
TestReportAddWindowCapture("Scope", scopeTestStepName, buffer);//截图scope
}
}
}int CheckStatusInternal(long status, char text[])
{
if(status <= 0)
{
testStepFail(scopeTestStepName, " Internal error in %s, return code = %d", text, status);
return 0;
}
return 1;
}
int DoBitAnlyz(ScopeBitMaskPolygon bitMask, dword startField, dword endField, char text[], double bitLength)
{
int i;
const int testRepetitions = 3;
const long textLength = 256;
char text1[textLength], bitNameStartField[textLength], bitNameEndField[textLength];
long flags, numOfInValidMasks, invalidMaskNumber;
GetBitFieldName(bitNameStartField, textLength, startField);
GetBitFieldName(bitNameEndField, textLength, endField);
if(startField != endField)testReportAddExtendedInfo("text", "Analysing bits from %s to %s", bitNameStartField, bitNameEndField);//添加表头
elsetestReportAddExtendedInfo("text", "Analysing bit %s", bitNameStartField);
flags = 0;for(i=0;;++i)
{
numOfInValidMasks = TestWaitScopeAnalyseSignal(canTestMessage, flags,
startField, endField,
bitMask, domVoltageThreshold, recVoltageThreshold, scopeAnlyzHandle);//900 500mv显隐性阈值
if(numOfInValidMasks < 0)//如果重复测量三次-警告;第四次报错
{
if(i<testRepetitions)
{
testStepWarning(testStepName, " Internal error in %s, return code = %d", "TestWaitScopeAnalyseSignal", numOfInValidMasks);
}
else
{
testStepFail(testStepName, " Internal error in %s, return code = %d", "TestWaitScopeAnalyseSignal", numOfInValidMasks);
return 0;
}
}
elsebreak;
}
if(numOfInValidMasks == 0)
{
//no mask violations found
snprintf(text1, textLength, "First bit(s) of the analyzed cutout");
DoShowBitMask(scopeAnlyzHandle, startField, 0, 10, text1);
}
else
{
//there are bit mask violations
testStepFail(scopeTestStepName, "%d bit mask violations found.", numOfInValidMasks);//iterate through all erroneous bits, make a screen shot, and add a description to the test report
for(invalidMaskNumber = 1; invalidMaskNumber <= numOfInValidMasks && invalidMaskNumber <= maxNumOfErrorsToShow; ++invalidMaskNumber)
{
ScopeMaskViolationData maskViolationData;
if(DoGetCAPLViolationMask(scopeAnlyzHandle, invalidMaskNumber, maskViolationData)){
ShowBitMask(scopeAnlyzHandle, invalidMaskNumber, maskViolationData, bitMask, bitLength);
}
}
}
//get average voltages//获取平均电压
if(startField != endField)
{
long res;
ScopeMaskViolationData maskViolationData;
res = testWaitScopeGetBitInfo(scopeAnlyzHandle, startField, 0, endField, 0, maskViolationData);
if(!CheckStatusInternal(res, "testWaitScopeGetBitInfo")) return 0;
//添加到表头
TestReportAddExtendedInfo("text", "Average voltages:\nCAN high dominant = %d mV, CAN high recessive = %d mV\nCAN low dominant = %d mV, CAN low recessive = %d mV\nCAN diff dominant = %d mV, CAN diff recessive = %d mV",
maskViolationData.domVoltageCANH, maskViolationData.recVoltageCANH,
maskViolationData.domVoltageCANL, maskViolationData.recVoltageCANL,
maskViolationData.domVoltageDiff, maskViolationData.recVoltageDiff);
}
return 1;
}
int DoShowBitMask(ScopeAnalyseHandle handle, long msgFieldStart, long bitIndex, long bitCount, char text[])
{
long res;//display the cutout in the scope window
res = TestWaitScopeShowMask(handle, msgFieldStart, bitIndex, bitCount);//仅显示差分信号
if(res != 1)
{
testStepFail(scopeTestStepName, " Internal error in TestWaitScopeShowMask, return code = %d", res);
return 0;
}//make a scrren shot and add it to the test report
TestReportAddWindowCapture("Scope", scopeTestStepName, text);//截图
return 1;
}
1221

被折叠的 条评论
为什么被折叠?



