CANtegrity API. More...
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) |
CANtegrity API.
The kvDiagXxx functions specify the CANtegrity API, which is based on high frequency sampling of the CAN bus. To check if a device has CANtegrity support, use canGetChannelData() with the item canCHANNELDATA_CHANNEL_CAP and the flag canCHANNEL_CAP_CANTEGRITY.
Attach an analyzer to the a CAN channel handle. The device needs to have the CANtegrity capability. See CANtegrity API (kvDiag) for how to check this.
[in] | canHnd | An open handle to a CAN channel of a KSI capable device. |
[in] | type | DIAG_ANALYZER_TYPE_XXX. |
canStatus kvDiagCalculateBitrate | ( | const canHandle | canHnd, |
bitrates_t * | btr | ||
) |
Run with DIAG_PROGRAM_TYPE_AUTOBAUD, see CANtegrity API (kvDiag).
Calculate the bitrate on the CAN bus by sampling a series of CAN frames. Uses all the sampled frames in the device buffer on each call. Stores information between calls. May require several calls until the quality value is sufficiently high.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
[out] | btr | Contains two sets of values for bitrate and quality. |
canStatus kvDiagCalculateClockOffset | ( | const canHandle | canHnd, |
int | id, | ||
double * | fMin, | ||
double * | fMax, | ||
double * | fMean, | ||
double * | fStd, | ||
int * | n | ||
) |
Run with DIAG_PROGRAM_TYPE_NORMAL, see CANtegrity API (kvDiag).
Get the clock offset of a device relative to the clock of the measuring device. This roughly equates to the relative difference of the two frequencies.
where
The result is expressed as a normal distribution over the sampled frames used. The unit of measurement is ppt (parts per trillion, 1e-12).
The function stores information between calls. Call until sufficient precision is reached. Each call will consume one sampled frame from the device buffer.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
[in] | id | Id with which the device of interest is sending |
[out] | fMin | Minimum drift encountered (parts per trillion) |
[out] | fMax | Maximum drift encountered (parts per trillion) |
[out] | fMean | Mean drift encountered (parts per trillion) |
[out] | fStd | Standard deviation (parts per trillion) |
[out] | n | Number of sampled frames used. |
Detach the analyzer from the CAN channel handle.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
canStatus kvDiagGetAnalyzerInfo | ( | const canHandle | canHnd, |
kvAnalyzerInfo_t * | info | ||
) |
Get analyzer info.
[in] | canHnd | An open handle to a CAN channel. |
[in,out] | info | for analyzer info. |
Get the number of analyzers.
[in] | canHnd | An open handle to a CAN channel. |
[out] | analyzerCount | Number of analyzers. |
canStatus kvDiagReadSample | ( | const canHandle | canHnd, |
kvDiagSample * | sample | ||
) |
Run with DIAG_PROGRAM_TYPE_NORMAL, see CANtegrity API (kvDiag).
Read (and consume) one full sample from an analyzer.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
[out] | sample | Pointer to struct to receive the sample. |
canStatus kvDiagReadSampleWait | ( | const canHandle | canHnd, |
kvDiagSample * | sample, | ||
int | timeout | ||
) |
Run with DIAG_PROGRAM_TYPE_NORMAL, see CANtegrity API (kvDiag).
Read (and consume) one full sample from an analyzer. Will wait until a message arrives or a timeout occurs.It can take up to 100 ms for this function to return after a new sample is available.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
[out] | sample | Pointer to struct to receive the sample. |
[in] | timeout | Number of milliseconds to wait for the next sample. |
Resets the bitrate calculation of kvDiagCalculateBitrate().
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
Resets the clock offset calculation of kvDiagCalculateClockOffset().
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
canStatus kvDiagSetProgram | ( | const canHandle | canHnd, |
int | programType, | ||
const char *const | configBuffer | ||
) |
Choose analyzer program to run.
configBuffer
is a JSON string containing configuration parameters. The following is an example configuration yielding a bitrate of 1MBit/s:
where
[in] | canHnd | An open handle to a CAN channel with an attached analayzer. |
[in] | programType | Analyzer program, either DIAG_PROGRAM_TYPE_NORMAL or DIAG_PROGRAM_TYPE_AUTOBAUD. |
[in] | configBuffer | A configuration string in JSON format specifying bus parameters. |
Start data acquisition.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |
Stop data acquisition.
[in] | canHnd | An open handle to a CAN channel with an attached analyzer. |