Converting
Hello kvlclib
This example shows a simple conversion from .kme50 to .csv using kvlclib.
#include "kvlclib.h"
static void check(const char* s, int stat)
{
if (stat != kvlcOK){
printf("%s returned %d\n", s, stat);
exit(1);
}
}
int main()
{
KvlcStatus stat;
KvlcHandle hnd;
// Instantiate converter handle and specify output file + format specifier
check("kvlcCreateConverter", stat);
// Set the input file and specify input format
check("kvlcSetInputFile", stat);
// Convert file
do {
stat = kvlcConvertEvent(hnd);
if (stat == kvlcERR_FILE_EXISTS)
printf("File already exists!\n");
// Check if conversion terminated correctly
if (stat != kvlcEOF){
check("kvlcConvertEvent", stat);
}
// Check if overruns occured
stat = kvlcIsOverrunActive(hnd, &overrun);
check("kvlcIsOverrunActive", stat);
if (overrun){
printf("NOTE! The extracted data contained overrun.\n");
}
// Check for truncated CAN FD frames (dlc > 8)
stat = kvlcIsDataTruncated(hnd, &truncated);
check("kvlcIsDataTruncated", stat);
if (truncated){
printf("NOTE! The extracted data was truncated.\n");
}
// Destroy the converter
stat = kvlcDeleteConverter(hnd);
check("kvlcDeleteConverter", stat);
return 0;
}
As could be seen, kvlclib does not overwrite files by default. We had to check kvlcConvertEvent for kvlcERR_FILE_EXISTS.
If we want to enable automatic overwrites on the converter, we can set the property KVLC_PROPERTY_OVERWRITE.
- See also
- Properties