kvDiag.h File Reference

The CANtegrity API is based on high frequency sampling of the CAN bus. This allows it to be used for various purposes, such as calculating the bitrate on the bus and measuring clock speeds of devices on the bus. More...

#include <canlib.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  bitrate_t
 
struct  bitrates_t
 
struct  kvDiagSample
 
struct  kvAnalyzerInfo_t
 
struct  kvDiagSample.header
 
struct  kvDiagSample.msg
 
struct  kvDiagSample.sample
 

Macros

DIAG_ANALYZER_TYPE_xxx

Analyzer type.

#define DIAG_ANALYZER_TYPE_DEFAULT   0
 
DIAG_PROGRAM_TYPE

Possible programs that can be run on an analyzer. Used with kvDiagSetProgram().

#define DIAG_PROGRAM_TYPE_NORMAL   0
 
#define DIAG_PROGRAM_TYPE_AUTOBAUD   1
 

Functions

canStatus kvDiagGetNumberOfAnalyzers (const canHandle canHnd, int *analyzerCount)
 
canStatus kvDiagGetAnalyzerInfo (const canHandle canHnd, kvAnalyzerInfo_t *info)
 
canStatus kvDiagAttachAnalyzer (const canHandle canHnd, int type)
 
canStatus kvDiagDetachAnalyzer (const canHandle canHnd)
 
canStatus kvDiagSetProgram (const canHandle canHnd, int programType, const char *const configBuffer)
 
canStatus kvDiagStart (const canHandle canHnd)
 
canStatus kvDiagStop (const canHandle canHnd)
 
canStatus kvDiagReadSample (const canHandle canHnd, kvDiagSample *sample)
 
canStatus kvDiagReadSampleWait (const canHandle canHnd, kvDiagSample *sample, int timeout)
 
canStatus kvDiagCalculateBitrate (const canHandle canHnd, bitrates_t *btr)
 
canStatus kvDiagResetBitrateCalculation (const canHandle canHnd)
 
canStatus kvDiagCalculateClockOffset (const canHandle canHnd, int id, double *fMin, double *fMax, double *fMean, double *fStd, int *n)
 
canStatus kvDiagResetClockOffsetCalculation (const canHandle canHnd)
 

Detailed Description

The CANtegrity API is based on high frequency sampling of the CAN bus. This allows it to be used for various purposes, such as calculating the bitrate on the bus and measuring clock speeds of devices on the bus.

Note
Not supported in linux!
Note
The CANtegrity API is preliminary and will change!

Data Structure Documentation

◆ bitrate_t

struct bitrate_t

Output when using kvDiagCalculateBitrate(), housed in bitrates_t.

Data Fields
double bitrate Bitrate in kBit/s.
int quality Quality value in % (0..100)

◆ bitrates_t

struct bitrates_t
Data Fields
bitrate_t bitrate Bitrate, arbitration bitrate if using FD with BRS.
bitrate_t bitrate_brs Data bitrate if using FD with BRS.

◆ kvDiagSample

struct kvDiagSample
Data Fields
struct kvDiagSample header
struct kvDiagSample msg
struct kvDiagSample sample

◆ kvAnalyzerInfo_t

struct kvAnalyzerInfo_t
Data Fields
int analyzerNo
int type
int version_major
int version_minor

◆ kvDiagSample.header

struct kvDiagSample.header
Data Fields
int seqno Sequence number.
int type Analyzer type.
int version Struct version.

◆ kvDiagSample.msg

struct kvDiagSample.msg
Data Fields
char data[64] CAN data.
int dlc CAN DLC.
int flag CAN flags, canMSG_STD, canMSG_EXT, canMSG_RTR.
int id CAN id.
int64_t time CPU ticks since device boot.

◆ kvDiagSample.sample

struct kvDiagSample.sample
Data Fields
int edgeCount Number of edges in edgeTimes.
int edgeTimes[8192] Time since previous edge in analyzer ticks at sampleFreq.
int sampleFreq Clock frequency of the analyzer.
int64_t startTime Time of the first edge (start bit)
int startValue Value prior to the first edge (start bit)

Macro Definition Documentation

◆ DIAG_ANALYZER_TYPE_DEFAULT

#define DIAG_ANALYZER_TYPE_DEFAULT   0

◆ DIAG_PROGRAM_TYPE_AUTOBAUD

#define DIAG_PROGRAM_TYPE_AUTOBAUD   1

◆ DIAG_PROGRAM_TYPE_NORMAL

#define DIAG_PROGRAM_TYPE_NORMAL   0