kvmlib.h File Reference

Library for accessing Kvaser Memorator (2nd generation) devices. More...

#include <windows.h>
#include <stdint.h>
#include <stdio.h>
#include <pshpack1.h>
#include <poppack.h>

Go to the source code of this file.

Data Structures

struct  kvmLogMsgEx
 A CAN message. More...
 
struct  kvmLogRtcClockEx
 A RTC clock message. More...
 
struct  kvmLogTriggerEx
 A trigger message. More...
 
struct  kvmLogVersionEx
 A version message. More...
 
struct  kvmLogEventEx
 The union of events used by kvmKmeReadEvent(). More...
 
union  kvmLogEventEx.eventUnion
 

Macros

kvmDEVICE_xxx

Device type, used to connect to a Memorator device.

#define kvmDEVICE_MHYDRA   0
 Kvaser Memorator (2nd generation) More...
 
#define kvmDEVICE_MHYDRA_EXT   1
 Kvaser Memorator (2nd generation) with extended data capabilities. More...
 
kvmLDF_MAJOR_xxx

Logged data format (LDF) version.

#define kvmLDF_MAJOR_CAN   3
 Used in Kvaser Memorator (2nd generation) More...
 
#define kvmLDF_MAJOR_CAN64   5
 Used in Kvaser Memorator (2nd generation) with extended data capabilities. More...
 
kvmFS_xxx

File system used when formatting disk.

#define kvmFS_FAT16   0
 fat16 More...
 
#define kvmFS_FAT32   1
 fat32 More...
 
kvmFILE_xxx

KME file type, a binary file format representing log data.

#define kvmFILE_KME24   0
 Deprecated. More...
 
#define kvmFILE_KME25   1
 Deprecated. More...
 
#define kvmFILE_KME40   2
 Kvaser binary format (KME 4.0) More...
 
#define kvmFILE_KME50   3
 Kvaser binary format (KME 5.0) More...
 
#define kvmFILE_KME60   4
 Kvaser binary format (KME 6.0) (Experimental) More...
 
kvmLogFileType_xxx

Type of log file.

#define kvmLogFileType_ERR   0
 a log file containing only error frames, and some frames before and after the error frame. More...
 
#define kvmLogFileType_ALL   1
 a log file with all frames. More...
 
kvm_SWINFO_xxx

Different types of version information that can be extracted using kvmDeviceGetSoftwareInfo()

#define kvm_SWINFO_KVMLIB   1
 Returns the version of kvmlib. More...
 
#define kvm_SWINFO_DRIVER   2
 Returns the used driver version information. More...
 
#define kvm_SWINFO_FIRMWARE   3
 Returns the device firmware version information. More...
 
#define kvm_SWINFO_DRIVER_PRODUCT   4
 Obsolete. Returns the product version information. More...
 
#define kvm_SWINFO_CONFIG_VERSION_NEEDED   5
 Returns the version of the binary format the device requires (param.lif). More...
 
#define kvm_SWINFO_CPLD_VERSION   6
 Obsolete. More...
 
TRIGVAR_TYPE_xxx

The following trigger types can be found in a kvmLogTriggerEx message type field.

#define TRIGVAR_TYPE_MSG_ID   0
 Message ID trigger. More...
 
#define TRIGVAR_TYPE_MSG_DLC   1
 Message DLC trigger. More...
 
#define TRIGVAR_TYPE_MSG_FLAG   2
 Message flag trigger. More...
 
#define TRIGVAR_TYPE_SIGVAL   3
 Signal value trigger. More...
 
#define TRIGVAR_TYPE_EXTERNAL   4
 External trigger. More...
 
#define TRIGVAR_TYPE_TIMER   5
 Timer trigger. More...
 
#define TRIGVAR_TYPE_DISK_FULL   6
 Disk is full trigger. More...
 
#define TRIGVAR_TYPE_STARTUP   9
 Startup trigger. More...
 
kvmLOG_TYPE_xxx

Event types in log

#define kvmLOG_TYPE_INVALID   0
 Invalid MEMOLOG type. More...
 
#define kvmLOG_TYPE_CLOCK   1
 The type used in kvmLogRtcClockEx. More...
 
#define kvmLOG_TYPE_MSG   2
 The type used in kvmLogMsgEx. More...
 
#define kvmLOG_TYPE_TRIGGER   3
 The type used in kvmLogTriggerEx. More...
 
#define kvmLOG_TYPE_VERSION   4
 The type used in kvmLogVersionEx. More...
 

Typedefs

typedef int8_t int8
 
typedef uint8_t uint8
 
typedef int16_t int16
 
typedef uint16_t uint16
 
typedef int32_t int32
 
typedef uint32_t uint32
 
typedef int64_t int64
 
typedef HANDLE kmeFileHandle
 A handle to a KME file. More...
 
typedef HANDLE kvmHandle
 A handle to a Memorator or equivalent KMF file. More...
 

Enumerations

kvmStatus

Generally, a return code greater than or equal to zero means success. A value less than zero means failure.

enum  kvmStatus {
  kvmOK = 0,
  kvmFail = -1,
  kvmERR_PARAM = -3,
  kvmERR_LOGFILEOPEN = -8,
  kvmERR_NOSTARTTIME = -9,
  kvmERR_NOLOGMSG = -10,
  kvmERR_LOGFILEWRITE = -11,
  kvmEOF = -12,
  kvmERR_NO_DISK = -13,
  kvmERR_LOGFILEREAD = -14,
  kvmERR_QUEUE_FULL = -20,
  kvmERR_CRC_ERROR = -21,
  kvmERR_SECTOR_ERASED = -22,
  kvmERR_FILE_ERROR = -23,
  kvmERR_DISK_ERROR = -24,
  kvmERR_DISKFULL_DIR = -25,
  kvmERR_DISKFULL_DATA = -26,
  kvmERR_SEQ_ERROR = -27,
  kvmERR_FILE_SYSTEM_CORRUPT = -28,
  kvmERR_UNSUPPORTED_VERSION = -29,
  kvmERR_NOT_IMPLEMENTED = -30,
  kvmERR_FATAL_ERROR = -31,
  kvmERR_ILLEGAL_REQUEST = -32,
  kvmERR_FILE_NOT_FOUND = -33,
  kvmERR_NOT_FORMATTED = -34,
  kvmERR_WRONG_DISK_TYPE = -35,
  kvmERR_TIMEOUT = -36,
  kvmERR_DEVICE_COMM_ERROR = -37,
  kvmERR_OCCUPIED = -38,
  kvmERR_USER_CANCEL = -39,
  kvmERR_FIRMWARE = -40,
  kvmERR_CONFIG_ERROR = -41,
  kvmERR_WRITE_PROT = -42,
  kvmERR_RESULT_TOO_BIG = -43
}
 

Functions

void kvmInitialize (void)
 
kvmStatus kvmGetVersion (int *major, int *minor, int *build)
 
kvmStatus kvmGetErrorText (kvmStatus error, char *buf, size_t len)
 
kvmStatus kvmClose (kvmHandle h)
 
kvmHandle kvmDeviceOpen (int32 cardNr, kvmStatus *status, int32 deviceType)
 
kvmStatus kvmDeviceMountKmf (kvmHandle h)
 
kvmStatus kvmDeviceMountKmfEx (kvmHandle h, int *ldfMajor, int *ldfMinor)
 
kvmHandle kvmKmfOpen (const char *filename, kvmStatus *status, int32 deviceType)
 
kvmHandle kvmKmfOpenEx (const char *filename, kvmStatus *status, int32 deviceType, int *ldfMajor, int *ldfMinor)
 
kvmStatus kvmKmfValidate (kvmHandle h)
 
kvmStatus kvmDeviceFormatDisk (kvmHandle h, int fileSystem, uint32 reserveSpace, uint32 dbaseSpace)
 
kvmStatus kvmLogFileGetCount (kvmHandle h, uint32 *fileCount)
 
kvmStatus kvmLogFileGetType (kvmHandle h, uint32 fileIndx, int32 *logFileType)
 
kvmStatus kvmLogFileMount (kvmHandle h, uint32 fileIndx, uint32 *eventCount)
 
kvmStatus kvmLogFileMountEx (kvmHandle h, uint32 fileIndx, int64 *eventCount)
 
kvmStatus kvmLogFileDismount (kvmHandle h)
 
kvmStatus kvmLogFileGetStartTime (kvmHandle h, uint32 *startTime)
 
kvmStatus kvmLogFileGetEndTime (kvmHandle h, uint32 *endTime)
 
kvmStatus kvmLogFileGetCreatorSerial (kvmHandle h, uint32 *serialNumber)
 
kvmStatus kvmLogFileReadEvent (kvmHandle h, kvmLogEventEx *e)
 
kvmStatus kvmLogFileDeleteAll (kvmHandle h)
 
kvmStatus kvmDeviceDiskStatus (kvmHandle h, int *present)
 
kvmStatus kvmKmfGetUsage (kvmHandle h, uint32 *totalSectorCount, uint32 *usedSectorCount)
 
kvmStatus kvmDeviceDiskSize (kvmHandle h, uint32 *diskSize)
 
kvmStatus kvmDeviceGetSerialNumber (kvmHandle h, unsigned int *serial)
 
kvmStatus kvmDeviceGetSoftwareInfo (kvmHandle h, int32 itemCode, unsigned int *major, unsigned int *minor, unsigned int *build, unsigned int *flags)
 
kvmStatus kvmDeviceFlashLeds (kvmHandle h)
 
kvmStatus kvmDeviceGetRTC (kvmHandle h, uint32 *t)
 
kvmStatus kvmDeviceSetRTC (kvmHandle h, uint32 t)
 
kvmStatus kvmKmfReadConfig (kvmHandle h, void *buf, size_t buflen, size_t *actual_len)
 
kvmStatus kvmKmfWriteConfig (kvmHandle h, void *buf, size_t buflen)
 
kvmStatus kvmKmfGetDbaseFile (kvmHandle h, char *path, char *filenamebuf, size_t buflen)
 
kvmStatus kvmKmfPutDbaseFile (kvmHandle h, char *filename)
 
kvmStatus kvmKmfEraseDbaseFile (kvmHandle h)
 
kmeFileHandle kvmKmeOpenFile (const char *filename, kvmStatus *status, int32 fileType)
 
kvmStatus kvmKmeScanFileType (const char *filename, int32 *fileType)
 
kmeFileHandle kvmKmeCreateFile (const char *filename, kvmStatus *status, int32 fileType)
 
kvmStatus kvmKmeReadEvent (kmeFileHandle h, kvmLogEventEx *e)
 
kvmStatus kvmKmeWriteEvent (kmeFileHandle h, kvmLogEventEx *e)
 
kvmStatus kvmKmeCountEvents (kmeFileHandle h, uint32 *eventCount)
 
kvmStatus kvmKmeCountEventsEx (kmeFileHandle h, int64 *eventCount)
 
kvmStatus kvmKmeCloseFile (kmeFileHandle h)
 

Detailed Description

Library for accessing Kvaser Memorator (2nd generation) devices.

This library is used to extract log data, initialize disk, read and write configuration to a device, handle on device databases and more.


Data Structure Documentation

◆ kvmLogMsgEx

struct kvmLogMsgEx

A CAN message.

Data Fields
uint32 channel The device channel on which the message arrived, 0,1,...
uint8 data[64] Message data (64 bytes)
uint32 dlc The length of the message.
uint32 flags Message flags canMSG_xxx.
uint32 id The message identifier.
int64 timeStamp The timestamp in units of 1 nanosecond.

◆ kvmLogRtcClockEx

struct kvmLogRtcClockEx

A RTC clock message.

Data Fields
uint32 calendarTime RTC date, seconds since 1970-01-01T00:00:00+00:00 (UTC)
int64 timeStamp The timestamp in units of 1 nanosecond.

◆ kvmLogTriggerEx

struct kvmLogTriggerEx

A trigger message.

Data Fields
int32 postTrigger Posttrigger time in milliseconds.
int32 preTrigger Pretrigger time in milliseconds.
int64 timeStamp The timestamp in units of 1 nanosecond.
uint32 trigMask Bitmask with all active triggers.
int32 type The type of trigger TRIGVAR_TYPE_xxx.

◆ kvmLogVersionEx

struct kvmLogVersionEx

A version message.

Data Fields
uint32 eanHi
uint32 eanLo
uint32 fwBuild
uint32 fwMajor
uint32 fwMinor
uint32 lioMajor
uint32 lioMinor
uint32 serialNumber

◆ kvmLogEventEx

struct kvmLogEventEx

The union of events used by kvmKmeReadEvent().

Data Fields
union kvmLogEventEx eventUnion
uint32 type kvmLOG_TYPE_xxx, Event types in log

◆ kvmLogEventEx.eventUnion

union kvmLogEventEx.eventUnion
Data Fields
kvmLogMsgEx msg A CAN message.
uint8 raw[128] Raw data in a array.
kvmLogRtcClockEx rtc An RTC message.
kvmLogTriggerEx trig A trigger message.
kvmLogVersionEx ver A version message.

Macro Definition Documentation

◆ kvm_SWINFO_CONFIG_VERSION_NEEDED

#define kvm_SWINFO_CONFIG_VERSION_NEEDED   5

Returns the version of the binary format the device requires (param.lif).

◆ kvm_SWINFO_CPLD_VERSION

#define kvm_SWINFO_CPLD_VERSION   6

Obsolete.

◆ kvm_SWINFO_DRIVER

#define kvm_SWINFO_DRIVER   2

Returns the used driver version information.

◆ kvm_SWINFO_DRIVER_PRODUCT

#define kvm_SWINFO_DRIVER_PRODUCT   4

Obsolete. Returns the product version information.

◆ kvm_SWINFO_FIRMWARE

#define kvm_SWINFO_FIRMWARE   3

Returns the device firmware version information.

◆ kvm_SWINFO_KVMLIB

#define kvm_SWINFO_KVMLIB   1

Returns the version of kvmlib.

◆ kvmDEVICE_MHYDRA

#define kvmDEVICE_MHYDRA   0

Kvaser Memorator (2nd generation)

◆ kvmDEVICE_MHYDRA_EXT

#define kvmDEVICE_MHYDRA_EXT   1

Kvaser Memorator (2nd generation) with extended data capabilities.

◆ kvmFILE_KME24

#define kvmFILE_KME24   0

Deprecated.

◆ kvmFILE_KME25

#define kvmFILE_KME25   1

Deprecated.

◆ kvmFILE_KME40

#define kvmFILE_KME40   2

Kvaser binary format (KME 4.0)

◆ kvmFILE_KME50

#define kvmFILE_KME50   3

Kvaser binary format (KME 5.0)

◆ kvmFILE_KME60

#define kvmFILE_KME60   4

Kvaser binary format (KME 6.0) (Experimental)

◆ kvmFS_FAT16

#define kvmFS_FAT16   0

fat16

◆ kvmFS_FAT32

#define kvmFS_FAT32   1

fat32

◆ kvmLDF_MAJOR_CAN

#define kvmLDF_MAJOR_CAN   3

Used in Kvaser Memorator (2nd generation)

◆ kvmLDF_MAJOR_CAN64

#define kvmLDF_MAJOR_CAN64   5

Used in Kvaser Memorator (2nd generation) with extended data capabilities.

◆ kvmLOG_TYPE_CLOCK

#define kvmLOG_TYPE_CLOCK   1

The type used in kvmLogRtcClockEx.

◆ kvmLOG_TYPE_INVALID

#define kvmLOG_TYPE_INVALID   0

Invalid MEMOLOG type.

◆ kvmLOG_TYPE_MSG

#define kvmLOG_TYPE_MSG   2

The type used in kvmLogMsgEx.

◆ kvmLOG_TYPE_TRIGGER

#define kvmLOG_TYPE_TRIGGER   3

The type used in kvmLogTriggerEx.

◆ kvmLOG_TYPE_VERSION

#define kvmLOG_TYPE_VERSION   4

The type used in kvmLogVersionEx.

◆ kvmLogFileType_ALL

#define kvmLogFileType_ALL   1

a log file with all frames.

◆ kvmLogFileType_ERR

#define kvmLogFileType_ERR   0

a log file containing only error frames, and some frames before and after the error frame.

◆ TRIGVAR_TYPE_DISK_FULL

#define TRIGVAR_TYPE_DISK_FULL   6

Disk is full trigger.

◆ TRIGVAR_TYPE_EXTERNAL

#define TRIGVAR_TYPE_EXTERNAL   4

External trigger.

◆ TRIGVAR_TYPE_MSG_DLC

#define TRIGVAR_TYPE_MSG_DLC   1

Message DLC trigger.

◆ TRIGVAR_TYPE_MSG_FLAG

#define TRIGVAR_TYPE_MSG_FLAG   2

Message flag trigger.

◆ TRIGVAR_TYPE_MSG_ID

#define TRIGVAR_TYPE_MSG_ID   0

Message ID trigger.

◆ TRIGVAR_TYPE_SIGVAL

#define TRIGVAR_TYPE_SIGVAL   3

Signal value trigger.

◆ TRIGVAR_TYPE_STARTUP

#define TRIGVAR_TYPE_STARTUP   9

Startup trigger.

◆ TRIGVAR_TYPE_TIMER

#define TRIGVAR_TYPE_TIMER   5

Timer trigger.

Typedef Documentation

◆ int16

typedef int16_t int16

◆ int32

typedef int32_t int32

◆ int64

typedef int64_t int64

◆ int8

typedef int8_t int8

◆ kmeFileHandle

typedef HANDLE kmeFileHandle

A handle to a KME file.

◆ kvmHandle

typedef HANDLE kvmHandle

A handle to a Memorator or equivalent KMF file.

◆ uint16

typedef uint16_t uint16

◆ uint32

typedef uint32_t uint32

◆ uint8

typedef uint8_t uint8

Enumeration Type Documentation

◆ kvmStatus

enum kvmStatus
Enumerator
kvmOK 

OK!

kvmFail 

Generic error.

kvmERR_PARAM 

Error in supplied parameters.

kvmERR_LOGFILEOPEN 

Can't find/open log file.

kvmERR_NOSTARTTIME 

Start time not found.

kvmERR_NOLOGMSG 

No log message found.

kvmERR_LOGFILEWRITE 

Error writing log file.

kvmEOF 

End of file found.

kvmERR_NO_DISK 

No disk found.

kvmERR_LOGFILEREAD 

Error while reading log file.

kvmERR_QUEUE_FULL 

Queue is full.

kvmERR_CRC_ERROR 

CRC check failed.

kvmERR_SECTOR_ERASED 

Sector unexpectadly erased.

kvmERR_FILE_ERROR 

File I/O error.

kvmERR_DISK_ERROR 

General disk error.

kvmERR_DISKFULL_DIR 

Disk full (directory).

kvmERR_DISKFULL_DATA 

Disk full (data).

kvmERR_SEQ_ERROR 

Unexpected sequence.

kvmERR_FILE_SYSTEM_CORRUPT 

File system corrupt.

kvmERR_UNSUPPORTED_VERSION 

Unsupported version.

kvmERR_NOT_IMPLEMENTED 

Not implemented.

kvmERR_FATAL_ERROR 

Fatal error.

kvmERR_ILLEGAL_REQUEST 

Illegal request.

kvmERR_FILE_NOT_FOUND 

File not found.

kvmERR_NOT_FORMATTED 

Disk not formatted.

kvmERR_WRONG_DISK_TYPE 

Wrong disk type.

kvmERR_TIMEOUT 

Timeout.

kvmERR_DEVICE_COMM_ERROR 

Device communication error.

kvmERR_OCCUPIED 

Device occupied.

kvmERR_USER_CANCEL 

User abort.

kvmERR_FIRMWARE 

Firmware error.

kvmERR_CONFIG_ERROR 

Configuration error.

kvmERR_WRITE_PROT 

Disk is write protected.

kvmERR_RESULT_TOO_BIG 

Result is too big for an out-parameter.