[89] | 1 | /**
|
---|
| 2 | ** Copyright 2015 by KVASER AB, SWEDEN
|
---|
| 3 | ** WWW: http://www.kvaser.com
|
---|
| 4 | **
|
---|
| 5 | ** This software is furnished under a license and may be used and copied
|
---|
| 6 | ** only in accordance with the terms of such license.
|
---|
| 7 | **
|
---|
| 8 | ** \file kvmlib.h
|
---|
| 9 | ** \brief Library for accessing Kvaser Memorator (2nd generation)
|
---|
| 10 | **
|
---|
| 11 | ** Description:
|
---|
| 12 | ** Library for accessing Kvaser Memorator (2nd generation). This
|
---|
| 13 | ** library is used to extract log data, initialize disk, read and
|
---|
| 14 | ** write configuration to a device, handle on device databases and
|
---|
| 15 | ** more.
|
---|
| 16 | **
|
---|
| 17 | ** ---------------------------------------------------------------------------
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | #ifndef KVMLIB_H
|
---|
| 22 | #define KVMLIB_H
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | #include <windows.h>
|
---|
| 26 | #include <stdio.h>
|
---|
| 27 |
|
---|
| 28 | #ifdef __cplusplus
|
---|
| 29 | extern "C" {
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 | /**
|
---|
| 33 | * \name kvmDEVICE_xxx
|
---|
| 34 | * \anchor kvmDEVICE_xxx
|
---|
| 35 | *
|
---|
| 36 | * Device type, used to connect to a Memorator device.
|
---|
| 37 | *
|
---|
| 38 | * @{
|
---|
| 39 | */
|
---|
| 40 | #define kvmDEVICE_MHYDRA 0 ///< Kvaser Memorator (2nd generation)
|
---|
| 41 | /** @} */
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * \brief A handle to a KME file
|
---|
| 45 | */
|
---|
| 46 | typedef HANDLE kmeFileHandle;
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * \name kvmFS_xxx
|
---|
| 50 | * \anchor kvmFS_xxx
|
---|
| 51 | *
|
---|
| 52 | * File system used when formatting disk.
|
---|
| 53 | *
|
---|
| 54 | * @{
|
---|
| 55 | */
|
---|
| 56 | #define kvmFS_FAT16 0 ///< fat16
|
---|
| 57 | #define kvmFS_FAT32 1 ///< fat32
|
---|
| 58 | /** @} */
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * \name kvmFILE_xxx
|
---|
| 62 | * \anchor kvmFILE_xxx
|
---|
| 63 | *
|
---|
| 64 | * KME file type, a binary file format representing log data.
|
---|
| 65 | *
|
---|
| 66 | * @{
|
---|
| 67 | */
|
---|
| 68 | #define kvmFILE_KME24 0 ///< Deprecated
|
---|
| 69 | #define kvmFILE_KME25 1 ///< Deprecated
|
---|
| 70 | #define kvmFILE_KME40 2 ///< Kvaser binary format (KME 4.0)
|
---|
| 71 | /** @} */
|
---|
| 72 |
|
---|
| 73 | /**
|
---|
| 74 | * \brief A handle to a Memorator or equivalent KMF file
|
---|
| 75 | */
|
---|
| 76 | typedef HANDLE kvmHandle;
|
---|
| 77 |
|
---|
| 78 | typedef signed char int8;
|
---|
| 79 | typedef unsigned char uint8;
|
---|
| 80 | typedef short int16;
|
---|
| 81 | typedef unsigned short uint16;
|
---|
| 82 | typedef long int int32;
|
---|
| 83 | typedef unsigned long int uint32;
|
---|
| 84 | typedef __int64 int64;
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * \name kvmStatus
|
---|
| 89 | * \anchor kvmERR_xxx
|
---|
| 90 | *
|
---|
| 91 | * Generally, a return code greater than or equal to zero means success. A
|
---|
| 92 | * value less than zero means failure.
|
---|
| 93 | *
|
---|
| 94 | * @{
|
---|
| 95 | */
|
---|
| 96 |
|
---|
| 97 | // If you change here, remember to also change kvmlib.cpp and kvmlibtest...
|
---|
| 98 | typedef enum {
|
---|
| 99 | kvmOK = 0, ///< OK!
|
---|
| 100 | kvmFail = -1, ///< Generic error.
|
---|
| 101 | kvmERR_PARAM = -3, ///< Error in supplied parameters.
|
---|
| 102 | kvmERR_LOGFILEOPEN = -8, ///< Can't find/open log file.
|
---|
| 103 | kvmERR_NOSTARTTIME = -9, ///< Start time not found.
|
---|
| 104 | kvmERR_NOLOGMSG = -10, ///< No log message found.
|
---|
| 105 | kvmERR_LOGFILEWRITE = -11, ///< Error writing log file.
|
---|
| 106 | kvmEOF = -12, ///< End of file found.
|
---|
| 107 | kvmERR_NO_DISK = -13, ///< No disk found.
|
---|
| 108 | kvmERR_LOGFILEREAD = -14, ///< Error while reading log file.
|
---|
| 109 | kvmERR_QUEUE_FULL = -20, ///< Queue is full.
|
---|
| 110 | kvmERR_CRC_ERROR = -21, ///< CRC check failed.
|
---|
| 111 | kvmERR_SECTOR_ERASED = -22, ///< Sector unexpectadly erased.
|
---|
| 112 | kvmERR_FILE_ERROR = -23, ///< File I/O error.
|
---|
| 113 | kvmERR_DISK_ERROR = -24, ///< General disk error.
|
---|
| 114 | kvmERR_DISKFULL_DIR = -25, ///< Disk full (directory).
|
---|
| 115 | kvmERR_DISKFULL_DATA = -26, ///< Disk full (data).
|
---|
| 116 | kvmERR_SEQ_ERROR = -27, ///< Unexpected sequence.
|
---|
| 117 | kvmERR_FILE_SYSTEM_CORRUPT = -28, ///< File system corrupt.
|
---|
| 118 | kvmERR_UNSUPPORTED_VERSION = -29, ///< Unsupported version.
|
---|
| 119 | kvmERR_NOT_IMPLEMENTED = -30, ///< Not implemented.
|
---|
| 120 | kvmERR_FATAL_ERROR = -31, ///< Fatal error.
|
---|
| 121 | kvmERR_ILLEGAL_REQUEST = -32, ///< Illegal request.
|
---|
| 122 | kvmERR_FILE_NOT_FOUND = -33, ///< File not found.
|
---|
| 123 | kvmERR_NOT_FORMATTED = -34, ///< Disk not formatted.
|
---|
| 124 | kvmERR_WRONG_DISK_TYPE = -35, ///< Wrong disk type.
|
---|
| 125 | kvmERR_TIMEOUT = -36, ///< Timeout.
|
---|
| 126 | kvmERR_DEVICE_COMM_ERROR = -37, ///< Device communication error.
|
---|
| 127 | kvmERR_OCCUPIED = -38, ///< Device occupied.
|
---|
| 128 | kvmERR_USER_CANCEL = -39, ///< User abort.
|
---|
| 129 | kvmERR_FIRMWARE = -40, ///< Firmware error.
|
---|
| 130 | kvmERR_CONFIG_ERROR = -41, ///< Configuration error.
|
---|
| 131 | kvmERR_WRITE_PROT = -42, ///< Disk is write protected.
|
---|
| 132 |
|
---|
| 133 | } kvmStatus;
|
---|
| 134 | /** @} */
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | /**
|
---|
| 138 | * \name kvm_SWINFO_xxx
|
---|
| 139 | * \anchor kvm_SWINFO_xxx
|
---|
| 140 | *
|
---|
| 141 | * Different types of version information that can be extracted using
|
---|
| 142 | * kvmDeviceGetSoftwareInfo()
|
---|
| 143 | *
|
---|
| 144 | * @{
|
---|
| 145 | */
|
---|
| 146 | #define kvm_SWINFO_DRIVER 2 ///< Returns the used driver version information.
|
---|
| 147 | #define kvm_SWINFO_FIRMWARE 3 ///< Returns the device firmware version information.
|
---|
| 148 | #define kvm_SWINFO_DRIVER_PRODUCT 4 ///< Obsolete. Returns the product version information.
|
---|
| 149 | #define kvm_SWINFO_CONFIG_VERSION_NEEDED 5 ///< Returns the version of the binary format (param.lif).
|
---|
| 150 | #define kvm_SWINFO_CPLD_VERSION 6 ///< Obsolete.
|
---|
| 151 | /** @} */
|
---|
| 152 |
|
---|
| 153 | #include <pshpack1.h>
|
---|
| 154 |
|
---|
| 155 | #ifndef canMSG_RTR
|
---|
| 156 | /**
|
---|
| 157 | * \name canMSG_xxx
|
---|
| 158 | *
|
---|
| 159 | * The following flags can be found in a kvmLogMsgEx message flags field
|
---|
| 160 | * returned from kvmKmeReadEvent(). All flags and/or combinations of them are
|
---|
| 161 | * meaningful for logged message.
|
---|
| 162 | * \anchor canMSG_xxx
|
---|
| 163 | * @{
|
---|
| 164 | */
|
---|
| 165 | # define canMSG_RTR 0x0001 ///< Message is a remote request
|
---|
| 166 | # define canMSG_STD 0x0002 ///< Message has a standard ID
|
---|
| 167 | # define canMSG_EXT 0x0004 ///< Message has an extended ID
|
---|
| 168 | # define canMSG_ERROR_FRAME 0x0020 ///< Message is an error frame
|
---|
| 169 | # define canMSG_TXACK 0x0040 ///< Message is a TX ACK (msg is really sent)
|
---|
| 170 | # define canMSG_TXRQ 0x0080 ///< Message is a TX REQUEST (msg is transfered to the CAN controller chip)
|
---|
| 171 | # define canMSGERR_OVERRUN 0x0600 ///< Message overrun condition occurred.
|
---|
| 172 | /** @} */
|
---|
| 173 | #endif
|
---|
| 174 |
|
---|
| 175 | /**
|
---|
| 176 | * \name TRIGVAR_TYPE_xxx
|
---|
| 177 | *
|
---|
| 178 | * The following trigger types can be found in a kvmLogTriggerEx message type
|
---|
| 179 | * field.
|
---|
| 180 | * \anchor TRIGVAR_TYPE_xxx
|
---|
| 181 | * @{
|
---|
| 182 | */
|
---|
| 183 | #define TRIGVAR_TYPE_MSG_ID 0 ///< Message ID trigger
|
---|
| 184 | #define TRIGVAR_TYPE_MSG_DLC 1 ///< Message DLC trigger
|
---|
| 185 | #define TRIGVAR_TYPE_MSG_FLAG 2 ///< Message flag trigger
|
---|
| 186 | #define TRIGVAR_TYPE_SIGVAL 3 ///< Signal value trigger
|
---|
| 187 | #define TRIGVAR_TYPE_EXTERNAL 4 ///< External trigger
|
---|
| 188 | #define TRIGVAR_TYPE_TIMER 5 ///< Timer trigger
|
---|
| 189 | #define TRIGVAR_TYPE_DISK_FULL 6 ///< Disk is full trigger
|
---|
| 190 | #define TRIGVAR_TYPE_STARTUP 9 ///< Startup trigger
|
---|
| 191 | /** @} */
|
---|
| 192 |
|
---|
| 193 | /**
|
---|
| 194 | * \brief A CAN message
|
---|
| 195 | */
|
---|
| 196 | typedef struct {
|
---|
| 197 | uint32 id; ///< The message identifier
|
---|
| 198 | int64 timeStamp; ///< The timestamp in units of 1 nanosecond
|
---|
| 199 | uint32 channel; ///< The device channel on which the message arrived, 0,1,...
|
---|
| 200 | uint32 dlc; ///< The length of the message
|
---|
| 201 | uint32 flags; ///< Message flags \ref canMSG_xxx
|
---|
| 202 | uint8 data[64]; ///< Message data (64 bytes)
|
---|
| 203 | } kvmLogMsgEx;
|
---|
| 204 |
|
---|
| 205 | /**
|
---|
| 206 | * \brief A RTC clock message
|
---|
| 207 | */
|
---|
| 208 | typedef struct {
|
---|
| 209 | uint32 calendarTime; ///< RTC date, seconds since 1970-01-01T00:00:00+00:00 (UTC)
|
---|
| 210 | int64 timeStamp; ///< The timestamp in units of 1 nanosecond
|
---|
| 211 | } kvmLogRtcClockEx;
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 | /**
|
---|
| 215 | * \brief A trigger message
|
---|
| 216 | */
|
---|
| 217 | typedef struct {
|
---|
| 218 | int32 type; ///< The type of trigger \ref TRIGVAR_TYPE_xxx
|
---|
| 219 | int32 preTrigger; ///< Pretrigger time in milliseconds
|
---|
| 220 | int32 postTrigger; ///< Posttrigger time in milliseconds
|
---|
| 221 | uint32 trigMask; ///< Bitmask with all active triggers
|
---|
| 222 | int64 timeStamp; ///< The timestamp in units of 1 nanosecond
|
---|
| 223 | } kvmLogTriggerEx;
|
---|
| 224 |
|
---|
| 225 | /**
|
---|
| 226 | * \name kvmLOG_TYPE_xxx
|
---|
| 227 | * \anchor kvmLOG_TYPE_xxx
|
---|
| 228 | *
|
---|
| 229 | * Event types in log
|
---|
| 230 | * @{
|
---|
| 231 | */
|
---|
| 232 | #define kvmLOG_TYPE_INVALID 0 ///< Invalid MEMOLOG type
|
---|
| 233 | #define kvmLOG_TYPE_CLOCK 1 ///< The type used in kvmLogRtcClockEx
|
---|
| 234 | #define kvmLOG_TYPE_MSG 2 ///< The type used in kvmLogMsgEx
|
---|
| 235 | #define kvmLOG_TYPE_TRIGGER 3 ///< The type used in kvmLogTriggerEx
|
---|
| 236 | /** @} */
|
---|
| 237 |
|
---|
| 238 | /**
|
---|
| 239 | * \brief The union of events used by kvmKmeReadEvent().
|
---|
| 240 | */
|
---|
| 241 | typedef struct {
|
---|
| 242 | uint32 type; ///< \ref MEMOLOG_TYPE_xxx, Event types in log
|
---|
| 243 | union {
|
---|
| 244 | kvmLogMsgEx msg; ///< A CAN message
|
---|
| 245 | kvmLogRtcClockEx rtc; ///< An RTC message
|
---|
| 246 | kvmLogTriggerEx trig; ///< A trigger message
|
---|
| 247 | uint8 raw[128]; ///< Raw data in a array
|
---|
| 248 | } eventUnion;
|
---|
| 249 | } kvmLogEventEx;
|
---|
| 250 |
|
---|
| 251 | #include <poppack.h>
|
---|
| 252 |
|
---|
| 253 | /**
|
---|
| 254 | * \ingroup Initialization
|
---|
| 255 | *
|
---|
| 256 | * This function must be called before any other functions are used. It will
|
---|
| 257 | * initialize the memolib library.
|
---|
| 258 | */
|
---|
| 259 | void WINAPI kvmInitialize(void);
|
---|
| 260 |
|
---|
| 261 | /**
|
---|
| 262 | * \ingroup Initialization
|
---|
| 263 | *
|
---|
| 264 | * Convert a \ref kvmStatus errorcode to a text.
|
---|
| 265 | *
|
---|
| 266 | * \param[in] error The error code to convert.
|
---|
| 267 | * \param[out] buf Buffer to receive error text.
|
---|
| 268 | * \param[in] len Buffer size in bytes.
|
---|
| 269 | */
|
---|
| 270 | kvmStatus WINAPI kvmGetErrorText(kvmStatus error, char *buf, size_t len);
|
---|
| 271 |
|
---|
| 272 | /**
|
---|
| 273 | * \ingroup Connection
|
---|
| 274 | *
|
---|
| 275 | * Close the connection to the Memorator (device or file) opened with
|
---|
| 276 | * kvmOpenDevice() or kvmDeviceMountKmf(). The handle becomes invalid.
|
---|
| 277 | *
|
---|
| 278 | * \param[in] h An open kvmHandle.
|
---|
| 279 | *
|
---|
| 280 | * \return \ref kvmOK (zero) if success
|
---|
| 281 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 282 | *
|
---|
| 283 | * \sa kvmDeviceMountKmf(), kvmDeviceOpen()
|
---|
| 284 | */
|
---|
| 285 | kvmStatus WINAPI kvmClose(kvmHandle h);
|
---|
| 286 |
|
---|
| 287 | /**
|
---|
| 288 | *\ingroup Connection
|
---|
| 289 | *
|
---|
| 290 | * Connect to a Memorator device and obtain a handle for subsequent device operations.
|
---|
| 291 | * The argument \a cardNr is the Card Number property (decreased by one) displayed in
|
---|
| 292 | * Kvaser Hardware.
|
---|
| 293 | *
|
---|
| 294 | * \param[in] cardNr Card number
|
---|
| 295 | * \param[out] status \ref kvmOK if completely successful,
|
---|
| 296 | * \ref kvmERR_xxx (negative) if failure
|
---|
| 297 | * \param[in] deviceType \ref kvmDEVICE_xxx
|
---|
| 298 | *
|
---|
| 299 | * \return Returns an open handle to a Memorator on success.
|
---|
| 300 | *
|
---|
| 301 | * \sa kvmClose(), kvmLogFileMount()
|
---|
| 302 | */
|
---|
| 303 | kvmHandle WINAPI kvmDeviceOpen(int32 cardNr,
|
---|
| 304 | kvmStatus *status,
|
---|
| 305 | int32 deviceType);
|
---|
| 306 |
|
---|
| 307 | /**
|
---|
| 308 | *\ingroup Connection
|
---|
| 309 | *
|
---|
| 310 | * Mount the log area on the SD card on a connected Kvaser Memorator.
|
---|
| 311 | *
|
---|
| 312 | * \note Must be called after \ref kvmDeviceOpen before any subsequent
|
---|
| 313 | * log operations are called.
|
---|
| 314 | *
|
---|
| 315 | * param[in] h An open kvmHandle.
|
---|
| 316 | *
|
---|
| 317 | * \return \ref kvmOK (zero) if success
|
---|
| 318 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 319 | *
|
---|
| 320 | * kvmClose(), kvmDeviceOpen()
|
---|
| 321 | */
|
---|
| 322 | kvmStatus WINAPI kvmDeviceMountKmf(kvmHandle h);
|
---|
| 323 |
|
---|
| 324 | /**
|
---|
| 325 | * \ingroup Connection
|
---|
| 326 | *
|
---|
| 327 | * Open a KMF file on a hard disk or SD card reader and obtain a handle for
|
---|
| 328 | * subsequent operations. \a deviceType is the device type that generated the
|
---|
| 329 | * file.
|
---|
| 330 | *
|
---|
| 331 | * \param[in] filename KMF filename
|
---|
| 332 | * \param[out] status \ref kvmOK if successful, otherwise
|
---|
| 333 | * \ref kvmERR_xxx
|
---|
| 334 | * \param[in] deviceType \ref kvmDEVICE_xxx
|
---|
| 335 | *
|
---|
| 336 | * \return Returns an open handle to a Memorator on success.
|
---|
| 337 | *
|
---|
| 338 | * \sa kvmClose(), kvmDeviceOpen()
|
---|
| 339 | *
|
---|
| 340 | * \todo What is returned upon failure?
|
---|
| 341 | */
|
---|
| 342 | kvmHandle WINAPI kvmKmfOpen(const char *filename,
|
---|
| 343 | kvmStatus *status,
|
---|
| 344 | int32 deviceType);
|
---|
| 345 |
|
---|
| 346 | /**
|
---|
| 347 | * \ingroup DiskOperations
|
---|
| 348 | *
|
---|
| 349 | * Check for errors
|
---|
| 350 | *
|
---|
| 351 | * \param[in] h An open kvmHandle.
|
---|
| 352 | *
|
---|
| 353 | * \return \ref kvmOK (zero) if success
|
---|
| 354 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 355 | */
|
---|
| 356 | kvmStatus WINAPI kvmKmfValidate(kvmHandle h);
|
---|
| 357 |
|
---|
| 358 | /**
|
---|
| 359 | * \ingroup DiskOperations
|
---|
| 360 | *
|
---|
| 361 | * Format the SD memory card in a connected Memorator.
|
---|
| 362 | *
|
---|
| 363 | *
|
---|
| 364 | * \param[in] h An open kvmHandle.
|
---|
| 365 | * \param[in] fileSystem Creates FAT32 if set to non-zero, else creates FAT16. \ref kvmFS_xxx
|
---|
| 366 | * \param[in] reserveSpace Space to reserve for user files, in MB.
|
---|
| 367 | * \param[in] dbaseSpace Space to reserve for database files, in MB.
|
---|
| 368 | *
|
---|
| 369 | * \return \ref kvmOK (zero) if success
|
---|
| 370 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 371 | *
|
---|
| 372 | * \sa kvmDeviceDiskSize
|
---|
| 373 | */
|
---|
| 374 | kvmStatus WINAPI kvmDeviceFormatDisk(kvmHandle h,
|
---|
| 375 | int fileSystem,
|
---|
| 376 | uint32 reserveSpace,
|
---|
| 377 | uint32 dbaseSpace);
|
---|
| 378 |
|
---|
| 379 | /**
|
---|
| 380 | * \ingroup DataExtraction
|
---|
| 381 | *
|
---|
| 382 | * Count the number of log files
|
---|
| 383 | *
|
---|
| 384 | * \param[in] h An open kvmHandle.
|
---|
| 385 | * \param[out] fileCount The number of log files on disk.
|
---|
| 386 | *
|
---|
| 387 | * \return \ref kvmOK (zero) if success
|
---|
| 388 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 389 | */
|
---|
| 390 | kvmStatus WINAPI kvmLogFileGetCount(kvmHandle h, uint32* fileCount);
|
---|
| 391 |
|
---|
| 392 | /**
|
---|
| 393 | * \ingroup DataExtraction
|
---|
| 394 | *
|
---|
| 395 | * Mount the log file with the specified index. The index starts at 0. The
|
---|
| 396 | * approximate number of events in the log file is returned.
|
---|
| 397 | *
|
---|
| 398 | * \param[in] h An open kvmHandle.
|
---|
| 399 | * \param[in] fileIndx Index of the log file to open.
|
---|
| 400 | * \param[out] eventCount The approximate number of events in the log file
|
---|
| 401 | *
|
---|
| 402 | * \return \ref kvmOK (zero) if success
|
---|
| 403 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 404 | *
|
---|
| 405 | * \sa kvmLogFileDismount()
|
---|
| 406 | */
|
---|
| 407 | kvmStatus WINAPI kvmLogFileMount(kvmHandle h, uint32 fileIndx,
|
---|
| 408 | uint32 *eventCount);
|
---|
| 409 |
|
---|
| 410 | /**
|
---|
| 411 | * \ingroup DataExtraction
|
---|
| 412 | *
|
---|
| 413 | * Dismount the log file opened with kvmLogFileMount(). The handle will stay valid.
|
---|
| 414 | *
|
---|
| 415 | * \param[in] h An open kvmHandle.
|
---|
| 416 | */
|
---|
| 417 | kvmStatus WINAPI kvmLogFileDismount(kvmHandle h);
|
---|
| 418 |
|
---|
| 419 | /**
|
---|
| 420 | * \ingroup DataExtraction
|
---|
| 421 | *
|
---|
| 422 | * Get the time of the first event in the log file. The time is returned in
|
---|
| 423 | * standard unix time format (number of seconds since 1970-01-01T00:00:00+00:00).
|
---|
| 424 | *
|
---|
| 425 | * \param[in] h An open kvmHandle.
|
---|
| 426 | * \param[out] startTime The time of the first event in the log file (UTC)
|
---|
| 427 | *
|
---|
| 428 | * \return \ref kvmOK (zero) if success
|
---|
| 429 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 430 | */
|
---|
| 431 | kvmStatus WINAPI kvmLogFileGetStartTime (kvmHandle h,
|
---|
| 432 | uint32 *startTime);
|
---|
| 433 |
|
---|
| 434 | /**
|
---|
| 435 | * \ingroup DataExtraction
|
---|
| 436 | *
|
---|
| 437 | * Get the serialnumber of the interface that created the log file.
|
---|
| 438 | *
|
---|
| 439 | * \param[in] h An open kvmHandle.
|
---|
| 440 | * \param[out] serialNumber The serialnumber of the interface that created the
|
---|
| 441 | * log file.
|
---|
| 442 | *
|
---|
| 443 | * \return \ref kvmOK (zero) if success
|
---|
| 444 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 445 | */
|
---|
| 446 | kvmStatus WINAPI kvmLogFileGetCreatorSerial(kvmHandle h,
|
---|
| 447 | uint32 *serialNumber);
|
---|
| 448 |
|
---|
| 449 | /**
|
---|
| 450 | * \ingroup DataExtraction
|
---|
| 451 | *
|
---|
| 452 | * Read an event from a log file opened with kvmLogFileMount().
|
---|
| 453 | *
|
---|
| 454 | * \param[in] h An open kvmHandle.
|
---|
| 455 | * \param[out] e Event from log file.
|
---|
| 456 | *
|
---|
| 457 | * \return \ref kvmOK (zero) if success
|
---|
| 458 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 459 | *
|
---|
| 460 | * \todo Will a call to this function increment to next event?
|
---|
| 461 | */
|
---|
| 462 | kvmStatus WINAPI kvmLogFileReadEvent(kvmHandle h, kvmLogEventEx *e);
|
---|
| 463 |
|
---|
| 464 |
|
---|
| 465 | /**
|
---|
| 466 | * \ingroup DataExtraction
|
---|
| 467 | *
|
---|
| 468 | * Delete all log files from a Memorator.
|
---|
| 469 | *
|
---|
| 470 | * \param[in] h An open kvmHandle.
|
---|
| 471 | *
|
---|
| 472 | * \return \ref kvmOK (zero) if success
|
---|
| 473 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 474 | */
|
---|
| 475 | kvmStatus WINAPI kvmLogFileDeleteAll(kvmHandle h);
|
---|
| 476 |
|
---|
| 477 | /**
|
---|
| 478 | * \ingroup SystemInformation
|
---|
| 479 | *
|
---|
| 480 | * Check if the SD memory card is present.
|
---|
| 481 | *
|
---|
| 482 | * \note This function is not supported by all devices.
|
---|
| 483 | *
|
---|
| 484 | * \param[in] h An open kvmHandle.
|
---|
| 485 | * \param[out] present Non-zero means that SD memory card is present.
|
---|
| 486 | *
|
---|
| 487 | * \return \ref kvmOK (zero) if success
|
---|
| 488 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 489 | */
|
---|
| 490 | kvmStatus WINAPI kvmDeviceDiskStatus(kvmHandle h, int *present);
|
---|
| 491 |
|
---|
| 492 | /**
|
---|
| 493 | * \ingroup SystemInformation
|
---|
| 494 | *
|
---|
| 495 | * Get disk usage statistics, reported in number of (512 byte) sectors.
|
---|
| 496 | *
|
---|
| 497 | *
|
---|
| 498 | * \param[in] h An open kvmHandle.
|
---|
| 499 | * \param[out] totalSectorCount Total number of sectors devoted for logging
|
---|
| 500 | * \param[out] usedSectorCount Number of logging sectors used
|
---|
| 501 | *
|
---|
| 502 | * \return \ref kvmOK (zero) if success
|
---|
| 503 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 504 | */
|
---|
| 505 | kvmStatus WINAPI kvmKmfGetUsage(kvmHandle h,
|
---|
| 506 | uint32 *totalSectorCount,
|
---|
| 507 | uint32 *usedSectorCount);
|
---|
| 508 |
|
---|
| 509 | /**
|
---|
| 510 | * \ingroup SystemInformation
|
---|
| 511 | *
|
---|
| 512 | * Get disk size, reported in number of (512 byte) sectors.
|
---|
| 513 | *
|
---|
| 514 | *
|
---|
| 515 | * \param[in] h An open kvmHandle.
|
---|
| 516 | * \param[out] diskSize Disk size in number of (512 byte) sectors.
|
---|
| 517 | *
|
---|
| 518 | * \return \ref kvmOK (zero) if success
|
---|
| 519 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 520 | */
|
---|
| 521 | kvmStatus WINAPI kvmDeviceDiskSize(kvmHandle h, uint32 *diskSize);
|
---|
| 522 |
|
---|
| 523 | /**
|
---|
| 524 | * \ingroup SystemInformation
|
---|
| 525 | *
|
---|
| 526 | * Get serial number related to the Memorator handle.
|
---|
| 527 | *
|
---|
| 528 | * \param[in] h An open kvmHandle.
|
---|
| 529 | * \param[out] serial Serial number of connected device.
|
---|
| 530 | *
|
---|
| 531 | * \return \ref kvmOK (zero) if success
|
---|
| 532 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 533 | */
|
---|
| 534 | kvmStatus WINAPI kvmDeviceGetSerialNumber(kvmHandle h, unsigned int *serial);
|
---|
| 535 |
|
---|
| 536 | /**
|
---|
| 537 | * \ingroup SystemInformation
|
---|
| 538 | *
|
---|
| 539 | * Get software version information.
|
---|
| 540 | *
|
---|
| 541 | * \param[in] h An open kvmHandle.
|
---|
| 542 | * \param[in] itemCode An item code specifying the type of version to get. \ref kvm_SWINFO_xxx
|
---|
| 543 | * \param[out] major Major version number
|
---|
| 544 | * \param[out] minor Minor version number
|
---|
| 545 | * \param[out] build Build number
|
---|
| 546 | * \param[out] flags For internal use only
|
---|
| 547 | *
|
---|
| 548 | * \return \ref kvmOK (zero) if success
|
---|
| 549 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 550 | */
|
---|
| 551 | kvmStatus WINAPI kvmDeviceGetSoftwareInfo(kvmHandle h,
|
---|
| 552 | int32 itemCode,
|
---|
| 553 | unsigned int *major,
|
---|
| 554 | unsigned int *minor,
|
---|
| 555 | unsigned int *build,
|
---|
| 556 | unsigned int *flags);
|
---|
| 557 | /**
|
---|
| 558 | * \ingroup SystemInformation
|
---|
| 559 | *
|
---|
| 560 | * Flash all LEDs on the opened Memorator device
|
---|
| 561 | *
|
---|
| 562 | * \param[in] h An open kvmHandle.
|
---|
| 563 | *
|
---|
| 564 | * \return \ref kvmOK (zero) if success
|
---|
| 565 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 566 | */
|
---|
| 567 | kvmStatus WINAPI kvmDeviceFlashLeds(kvmHandle h);
|
---|
| 568 |
|
---|
| 569 |
|
---|
| 570 | /**
|
---|
| 571 | * \ingroup RealTimeClock
|
---|
| 572 | *
|
---|
| 573 | * Get date and time from the RTC chip. The time is returned in standard
|
---|
| 574 | * unix time format (number of seconds since 1970-01-01T00:00:00+00:00).
|
---|
| 575 | * Only for device handles
|
---|
| 576 | *
|
---|
| 577 | * \param[in] h An open kvmHandle.
|
---|
| 578 | * \param[out] t Time in Unix time format
|
---|
| 579 | *
|
---|
| 580 | * \return \ref kvmOK (zero) if success
|
---|
| 581 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 582 | */
|
---|
| 583 | kvmStatus WINAPI kvmDeviceGetRTC(kvmHandle h, unsigned long *t);
|
---|
| 584 |
|
---|
| 585 | /**
|
---|
| 586 | * \ingroup RealTimeClock
|
---|
| 587 | *
|
---|
| 588 | * Set date and time in the RTC. The time is returned in standard unix
|
---|
| 589 | * time format (number of seconds since 1970-01-01T00:00:00+00:00).
|
---|
| 590 | * Only for device handles.
|
---|
| 591 | *
|
---|
| 592 | * \param[in] h An open kvmHandle.
|
---|
| 593 | * \param[in] t Time in Unix time format
|
---|
| 594 | *
|
---|
| 595 | * \return \ref kvmOK (zero) if success
|
---|
| 596 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 597 | */
|
---|
| 598 | kvmStatus WINAPI kvmDeviceSetRTC(kvmHandle h, unsigned long t);
|
---|
| 599 |
|
---|
| 600 | /**
|
---|
| 601 | * \ingroup Configurations
|
---|
| 602 | *
|
---|
| 603 | * Read binary configuration data (param.lif) from a KMF file.
|
---|
| 604 | *
|
---|
| 605 | * \param[in] h An open kvmHandle.
|
---|
| 606 | * \param[out] buf A pointer to buffer where the configuration (param.lif) will be written.
|
---|
| 607 | * \param[in] buflen The length of the buffer buf.
|
---|
| 608 | * \param[out] actual_len The actual length of the configuration written to buf.
|
---|
| 609 | *
|
---|
| 610 | * \return \ref kvmOK (zero) if success
|
---|
| 611 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 612 | */
|
---|
| 613 | kvmStatus WINAPI kvmKmfReadConfig(kvmHandle h, void *buf,
|
---|
| 614 | size_t buflen, size_t *actual_len);
|
---|
| 615 |
|
---|
| 616 | /**
|
---|
| 617 | * \ingroup Configurations
|
---|
| 618 | *
|
---|
| 619 | * Write binary configuration data (param.lif) to a KMF file.
|
---|
| 620 | *
|
---|
| 621 | * \param[in] h An open kvmHandle.
|
---|
| 622 | * \param[in] buf A pointer to buffer containing the configuration (param.lif) to be written.
|
---|
| 623 | * \param[in] buflen The length of the buffer buf.
|
---|
| 624 | *
|
---|
| 625 | * \return \ref kvmOK (zero) if success
|
---|
| 626 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 627 | */
|
---|
| 628 | kvmStatus WINAPI kvmKmfWriteConfig(kvmHandle h, void *buf, size_t buflen);
|
---|
| 629 |
|
---|
| 630 |
|
---|
| 631 | /**
|
---|
| 632 | * \ingroup Database
|
---|
| 633 | *
|
---|
| 634 | * Read the database file. The database will be extracted to path and the
|
---|
| 635 | * name of the created file copied to filenamebuf.
|
---|
| 636 | *
|
---|
| 637 | * \param[in] h An open kvmHandle.
|
---|
| 638 | * \param[in] path The path where the database file will be stored.
|
---|
| 639 | * \param[out] filenamebuf The filename of the database. (should be greater then 12 bytes)
|
---|
| 640 | * \param[in] buflen The lenght of filenamebuf
|
---|
| 641 | *
|
---|
| 642 | * \return \ref kvmOK (zero) if success
|
---|
| 643 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 644 | *
|
---|
| 645 | * \sa kvmKmfPutDbaseFile()
|
---|
| 646 | */
|
---|
| 647 | kvmStatus WINAPI kvmKmfGetDbaseFile(kvmHandle h, char *path, char *filenamebuf, size_t buflen);
|
---|
| 648 |
|
---|
| 649 | /**
|
---|
| 650 | * \ingroup Database
|
---|
| 651 | *
|
---|
| 652 | * Write the database file
|
---|
| 653 | *
|
---|
| 654 | * \param[in] h An open kvmHandle.
|
---|
| 655 | * \param[in] filename The full path and name of the file, e.g. C:\\temp\\myfile.data
|
---|
| 656 | * Note that the filename will be trucated to an 8.3 filename.
|
---|
| 657 | *
|
---|
| 658 | * \return \ref kvmOK (zero) if success
|
---|
| 659 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 660 | *
|
---|
| 661 | * \sa kvmKmfGetDbaseFile()
|
---|
| 662 | */
|
---|
| 663 | kvmStatus WINAPI kvmKmfPutDbaseFile(kvmHandle h, char *filename);
|
---|
| 664 |
|
---|
| 665 | /**
|
---|
| 666 | * \ingroup Database
|
---|
| 667 | *
|
---|
| 668 | * Erase the database file
|
---|
| 669 | *
|
---|
| 670 | * \param[in] h An open kvmHandle.
|
---|
| 671 | *
|
---|
| 672 | * \return \ref kvmOK (zero) if success
|
---|
| 673 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 674 | */
|
---|
| 675 | kvmStatus WINAPI kvmKmfEraseDbaseFile(kvmHandle h);
|
---|
| 676 |
|
---|
| 677 | /**
|
---|
| 678 | * \ingroup Files
|
---|
| 679 | *
|
---|
| 680 | * Open a KME file for reading and obtain a handle for subsequent operations.
|
---|
| 681 | *
|
---|
| 682 | * \param[in] filename The full path and name of the KME file, e.g. C:\\temp\\myfile.kme
|
---|
| 683 | * \param[in] fileType \ref kvmFILE_xxx
|
---|
| 684 | * \param[out] status \ref kvmOK (zero) if success
|
---|
| 685 | * \ref kvmERR_xxx (negative) if failure
|
---|
| 686 | *
|
---|
| 687 | * \return Returns an open handle to a KME file on success.
|
---|
| 688 | *
|
---|
| 689 | * \sa kvmKmeReadEvent(), kvmKmeCountEvents(), kvmKmeCloseFile()
|
---|
| 690 | *
|
---|
| 691 | */
|
---|
| 692 | kmeFileHandle WINAPI kvmKmeOpenFile (const char *filename,
|
---|
| 693 | kvmStatus *status,
|
---|
| 694 | int32 fileType);
|
---|
| 695 | /**
|
---|
| 696 | * \ingroup Files
|
---|
| 697 | *
|
---|
| 698 | * Open a KME file for writing and obtain a handle for subsequent operations.
|
---|
| 699 | * Note that kvmKmeCreateFile() will overwrite any existing file and that
|
---|
| 700 | * \ref kvmFILE_KME24 and \ref kvmFILE_KME25 are deprecated formats. Please
|
---|
| 701 | * use \ref kvmFILE_KME40.
|
---|
| 702 | *
|
---|
| 703 | * \param[in] filename The full path and name of the KME file, e.g. C:\\temp\\myfile.kme
|
---|
| 704 | * \param[in] fileType \ref kvmFILE_xxx
|
---|
| 705 | * \param[out] status \ref kvmOK (zero) if success
|
---|
| 706 | * \ref kvmERR_xxx (negative) if failure
|
---|
| 707 | *
|
---|
| 708 | * \return Returns an open handle to a KME file on success.
|
---|
| 709 | *
|
---|
| 710 | * \sa kvmKmeWriteEvent(), kvmKmeCountEvents(), kvmKmeCloseFile()
|
---|
| 711 | *
|
---|
| 712 | */
|
---|
| 713 | kmeFileHandle WINAPI kvmKmeCreateFile (const char *filename,
|
---|
| 714 | kvmStatus *status,
|
---|
| 715 | int32 fileType);
|
---|
| 716 |
|
---|
| 717 | /**
|
---|
| 718 | * \ingroup Files
|
---|
| 719 | *
|
---|
| 720 | * Read an event from a KME file opened with kvmKmeOpenFile().
|
---|
| 721 | *
|
---|
| 722 | * \param[in] h An open handle to a KME file.
|
---|
| 723 | * \param[out] e Event from a KME file.
|
---|
| 724 | *
|
---|
| 725 | * \return \ref kvmOK (zero) if success
|
---|
| 726 | * \return \ref kvmERR_NOLOGMSG on EOF
|
---|
| 727 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 728 | *
|
---|
| 729 | * \sa kvmKmeOpenFile(), kvmKmeCountEvents(), kvmKmeCloseFile()
|
---|
| 730 | *
|
---|
| 731 | */
|
---|
| 732 | kvmStatus WINAPI kvmKmeReadEvent (kmeFileHandle h, kvmLogEventEx *e);
|
---|
| 733 |
|
---|
| 734 | /**
|
---|
| 735 | * \ingroup Files
|
---|
| 736 | *
|
---|
| 737 | * Write an event to a KME file created with kvmKmeCreateFile().
|
---|
| 738 | *
|
---|
| 739 | * \param[in] h An open handle to a KME file.
|
---|
| 740 | * \param[in] e Event to write.
|
---|
| 741 | *
|
---|
| 742 | * \return \ref kvmOK (zero) if success
|
---|
| 743 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 744 | *
|
---|
| 745 | * \sa kvmKmeCreateFile(), kvmKmeCountEvents(), kvmKmeCloseFile()
|
---|
| 746 | *
|
---|
| 747 | */
|
---|
| 748 | kvmStatus WINAPI kvmKmeWriteEvent (kmeFileHandle h, kvmLogEventEx *e);
|
---|
| 749 |
|
---|
| 750 | /**
|
---|
| 751 | * \ingroup Files
|
---|
| 752 | *
|
---|
| 753 | * Count the number of events in a KME file.
|
---|
| 754 | *
|
---|
| 755 | * \param[in] h An open handle to a KME file.
|
---|
| 756 | * \param[out] eventCount Approximate number of events in a KME file.
|
---|
| 757 | *
|
---|
| 758 | * \return \ref kvmOK (zero) if success
|
---|
| 759 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 760 | *
|
---|
| 761 | * \sa kvmKmeOpenFile(), kvmKmeCreateFile()
|
---|
| 762 | *
|
---|
| 763 | */
|
---|
| 764 | kvmStatus WINAPI kvmKmeCountEvents(kmeFileHandle h, uint32 *eventCount);
|
---|
| 765 |
|
---|
| 766 | /**
|
---|
| 767 | * \ingroup Files
|
---|
| 768 | *
|
---|
| 769 | * Close an open KME file opened with kvmKmeOpenFile() or created
|
---|
| 770 | * with kvmKmeCreateFile(). The handle becomes invalid.
|
---|
| 771 | *
|
---|
| 772 | * \param[in] h An open handle to a KME file.
|
---|
| 773 | *
|
---|
| 774 | * \return \ref kvmOK (zero) if success
|
---|
| 775 | * \return \ref kvmERR_xxx (negative) if failure
|
---|
| 776 | *
|
---|
| 777 | * \sa kvmKmeOpenFile(), kvmKmeCreateFile()
|
---|
| 778 | *
|
---|
| 779 | */
|
---|
| 780 | kvmStatus WINAPI kvmKmeCloseFile (kmeFileHandle h);
|
---|
| 781 |
|
---|
| 782 | #ifdef __cplusplus
|
---|
| 783 | }
|
---|
| 784 | #endif
|
---|
| 785 |
|
---|
| 786 | #endif //KVMLIB_H
|
---|