Kvaser CANLIB: t-script
Typedefs | Functions

t-script

Typedefs

typedef __int64 kvEnvHandle

Functions

kvStatus kvScriptStart (const int hnd, int slotNo)
kvStatus kvScriptStop (const int hnd, int slotNo, int mode)
kvStatus kvScriptUnload (const int hnd, int slotNo)
kvStatus kvScriptSendEvent (const int hnd, int slotNo, int eventType, int eventNo, unsigned int data)
kvEnvHandle kvScriptEnvvarOpen (const int hnd, char *envvarName, int *envvarType, int *envvarSize)
kvStatus kvScriptEnvvarClose (kvEnvHandle eHnd)
kvStatus kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val)
kvStatus kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val)
kvStatus kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val)
kvStatus kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val)
kvStatus kvScriptEnvvarSetData (kvEnvHandle eHnd, void *buf, int start_index, int data_len)
kvStatus kvScriptEnvvarGetData (kvEnvHandle eHnd, void *buf, int start_index, int data_len)
kvStatus kvScriptLoadFileOnDevice (const int hnd, int slotNo, char *localFile)
kvStatus kvScriptLoadFile (const int hnd, int slotNo, char *filePathOnPC)
kvStatus kvScriptRequestText (const int hnd, unsigned int slot, unsigned int request)
kvStatus kvScriptGetText (const int hnd, int *slot, unsigned long *time, unsigned int *flags, char *buf, size_t bufsize)
kvStatus kvScriptStatus (const int hnd, int slot, unsigned int *status)
kvStatus kvFileCopyToDevice (const int hnd, char *hostFileName, char *deviceFileName)
kvStatus kvFileCopyFromDevice (const int hnd, char *deviceFileName, char *hostFileName)
kvStatus kvFileDelete (const int hnd, char *deviceFileName)
kvStatus kvFileGetName (const int hnd, int fileNo, char *name, int namelen)
kvStatus kvFileGetCount (const int hnd, int *count)
kvStatus kvFileGetSystemData (const int hnd, int itemCode, int *result)

Typedef Documentation

typedef __int64 kvEnvHandle

A handle to a t-script envvar. Returned by the function kvScriptEnvvarOpen().


Function Documentation

kvStatus kvFileCopyFromDevice ( const int  hnd,
char *  deviceFileName,
char *  hostFileName 
)
C#
static Canlib.canStatus kvFileCopyFromDevice(int hnd, string deviceFileName, string hostFileName);
Delphi
function kvFileCopyFromDevice(hnd: canHandle; deviceFileName: PChar; hostFileName: PChar): kvStatus;

The kvFileCopyFromDevice() function copies an arbitrary file from the device to the host.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]deviceFileNameThe device file name; a pointer to a NULL terminated array of chars.
[in]hostFileNameThe target host file name; a pointer to a NULL terminated array of chars.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvFileCopyToDevice()
kvStatus kvFileCopyToDevice ( const int  hnd,
char *  hostFileName,
char *  deviceFileName 
)
C#
static Canlib.canStatus kvFileCopyToDevice(int hnd, string hostFileName, string deviceFileName);
Delphi
function kvFileCopyToDevice(hnd: canHandle; hostFileName: PChar; deviceFileName: PChar): kvStatus;

The kvFileCopyToDevice() function copies an arbitrary file from the host to the device.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]hostFileNameThe host file name; a pointer to a NULL terminated array of chars.
[in]deviceFileNameThe target device file name; a pointer to a NULL terminated array of chars.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvFileCopyFromDevice(), kvFileDelete()
kvStatus kvFileDelete ( const int  hnd,
char *  deviceFileName 
)
C#
static Canlib.canStatus kvFileDelete(int hnd, string deviceFileName);
Delphi
function kvFileDelete(hnd: canHandle; deviceFileName: PChar): kvStatus;

The kvFileDelete() function deletes a file on the device.

Note:
Deleting system files is not recommended.
Parameters:
[in]hndAn open handle to a CAN channel.
[in]deviceFileNameThe file on the device to delete; a pointer to a NULL terminated array of chars.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvFileCopyToDevice()
kvStatus kvFileGetCount ( const int  hnd,
int *  count 
)
C#
static Canlib.canStatus kvFileGetCount(int hnd, out int count);
Delphi
function kvFileGetCount(hnd: canHandle; var count: Integer): kvStatus;

The kvFileGetCount() function returns the number of files.

Parameters:
[in]hndAn open handle to a CAN channel.
[out]countA pointer to a 32-bit integer that will receive the file count.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvFileGetName(), kvFileGetSystemData()
kvStatus kvFileGetName ( const int  hnd,
int  fileNo,
char *  name,
int  namelen 
)
C#
static Canlib.canStatus kvFileGetName(int hnd, int fileNo, out string name);
Delphi
function kvFileGetName(hnd: canHandle; fileNo: Integer; name: PChar; namelen: Integer): kvStatus;

The kvFileGetName() function returns the name of the file with number fileNo.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]fileNoThe number of the file.
[out]nameA buffer that will contain the name of the file. The name is a zero-terminated ASCII string.
[in]namelenThe length, in bytes, of the name buffer.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvFileGetCount(), kvFileGetSystemData()
kvStatus kvFileGetSystemData ( const int  hnd,
int  itemCode,
int *  result 
)
C#
static Canlib.canStatus kvFileGetSystemData(int hnd, int itemCode, out int result);
Delphi
function kvFileGetSystemData(hnd: canHandle; itemCode: Integer; var result: Integer): kvStatus;

The kvFileGetSystemData() function is used for reading disk parameters, e.g. size, max number of (user) files, etc.

Note:
Not yet implemented
Parameters:
[in]hndAn open handle to a CAN channel.
[in]itemCodeThe item we want information on.
[out]resultA pointer to a 32-bit integer that will receive the result.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
kvStatus kvScriptEnvvarClose ( kvEnvHandle  eHnd)
C#
static Canlib.canStatus kvScriptEnvvarClose(long eHnd);
Delphi
function kvScriptEnvvarClose(const eHnd: kvEnvHandle): kvStatus;

The kvScriptEnvvarClose() function closes an open envvar.

Parameters:
[in]eHndAn open handle to an envvar.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
kvScriptEnvvarOpen()
Examples:
envvar.c.
kvStatus kvScriptEnvvarGetData ( kvEnvHandle  eHnd,
void *  buf,
int  start_index,
int  data_len 
)
C#
static Canlib.canStatus kvScriptEnvvarGetData(long eHnd, out byte[] buf, int start_index, int data_len);
Delphi
function kvScriptEnvvarGetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus;

The kvScriptEnvvarGetData() function retrieves a range of data bytes from an envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[out]bufA pointer to a data area where the retrieved data range should be stored.
[in]start_indexThe start index of the data range.
[in]data_lenThe length in bytes of the data range.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarSetData(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetFloat()
Examples:
envvar.c.
kvStatus kvScriptEnvvarGetFloat ( kvEnvHandle  eHnd,
float *  val 
)
C#
static Canlib.canStatus kvScriptEnvvarGetFloat(long eHnd, out float val);
Delphi
function kvScriptEnvvarGetFloat(const eHnd: kvEnvHandle; var val: Single): kvStatus;

The kvScriptEnvvarGetFloat() function retrieves the value of a float envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[out]valA pointer to a float where the retrieved result should be stored.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarSetFloat(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetData()
kvStatus kvScriptEnvvarGetInt ( kvEnvHandle  eHnd,
int *  val 
)
C#
static Canlib.canStatus kvScriptEnvvarGetInt(long eHnd, out int val);
Delphi
function kvScriptEnvvarGetInt(const eHnd: kvEnvHandle; var val: Integer): kvStatus;

The kvScriptEnvvarGetInt() function retrieves the value of an int envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[out]valThe current value.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarSetInt(), kvScriptEnvvarGetFloat(), kvScriptEnvvarGetData()
kvEnvHandle kvScriptEnvvarOpen ( const int  hnd,
char *  envvarName,
int *  envvarType,
int *  envvarSize 
)
C#
static long kvScriptEnvvarOpen(int hnd, string envvarName, out int envvarType, out int envvarSize);
Delphi
function kvScriptEnvvarOpen(const hnd: canHandle; envvarName: PChar; var envvarType: Integer; var envvarSize: Integer): kvEnvHandle;

The kvScriptEnvvarOpen() opens an existing envvar and returns a handle to it.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]envvarNameThe envvar's name; a pointer to a NULL terminated array of chars.
[out]envvarTypeA pointer to a 32-bit integer that will receive the kvENVVAR_TYPE_xxx type.
[out]envvarSizeA pointer to a 32-bit integer that will receive the size of the envvar in bytes.
Returns:
A kvEnvHandle handle (positive) to an envvar if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarClose()
Examples:
envvar.c.
kvStatus kvScriptEnvvarSetData ( kvEnvHandle  eHnd,
void *  buf,
int  start_index,
int  data_len 
)
C#
static Canlib.canStatus kvScriptEnvvarSetData(long eHnd, byte[] buf, int start_index, int data_len);
Delphi
function kvScriptEnvvarSetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus;

The kvScriptEnvvarSetData() function sets a range of data bytes in an envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[in]bufA pointer to a data area with the new values.
[in]start_indexThe start index of the envvar's data range that we want to update.
[in]data_lenThe length in bytes of the envvar's data range that we want to update.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarGetData(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetFloat()
Examples:
envvar.c.
kvStatus kvScriptEnvvarSetFloat ( kvEnvHandle  eHnd,
float  val 
)
C#
static Canlib.canStatus kvScriptEnvvarSetFloat(long eHnd, float val);
Delphi
function kvScriptEnvvarSetFloat(const eHnd: kvEnvHandle; val: Single): kvStatus;

The kvScriptEnvvarSetFloat() sets the value of a float envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[in]valThe new value.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarGetFloat(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetData()
kvStatus kvScriptEnvvarSetInt ( kvEnvHandle  eHnd,
int  val 
)
C#
static Canlib.canStatus kvScriptEnvvarSetInt(long eHnd, int val);
Delphi
function kvScriptEnvvarSetInt(const eHnd: kvEnvHandle; val: Integer): kvStatus;

The kvScriptEnvvarSetInt() sets the value of an int envvar.

Parameters:
[in]eHndAn open handle to an envvar.
[in]valThe new value.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptEnvvarOpen(), kvScriptEnvvarGetInt(), kvScriptEnvvarSetFloat(), kvScriptEnvvarSetData()
kvStatus kvScriptGetText ( const int  hnd,
int *  slot,
unsigned long *  time,
unsigned int *  flags,
char *  buf,
size_t  bufsize 
)
C#
static Canlib.canStatus kvScriptGetText(int hnd, out int slot, out ulong time, out int flags, out string buf);
Delphi
function kvScriptGetText(hnd: canHandle; var slot: integer; var time: Cardinal; var flags: Cardinal; buf: PChar; bufsize: Cardinal): kvStatus;

The kvScriptGetText() Reads a printf from a subscribed script slot. Set up a subscription with kvScriptRequestText().

Parameters:
[in]hndAn open handle to a CAN channel.
[out]slotThe slot where the printf originated.
[out]timeThe printf timestamp.
[out]flagsPrintf flags. A combination of canSTAT_xxx flags.
[out]bufBuffer to hold the printf string.
[in]bufsizeSize of the buffer.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
kvStatus kvScriptLoadFile ( const int  hnd,
int  slotNo,
char *  filePathOnPC 
)
C#
static Canlib.canStatus kvScriptLoadFile(int hnd, int slotNo, ref string filePathOnPC);
Delphi
function kvScriptLoadFile(hnd: canHandle; slotNo: Integer; filePathOnPC: PChar): kvStatus;

The kvScriptLoadFile() function loads a compiled script file (.txe) stored on the host (PC) into a script slot on the device.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot where to load the script.
[in]filePathOnPCThe script file name; a pointer to a NULL terminated array of chars.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptLoadFileOnDevice(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()
Examples:
envvar.c.
kvStatus kvScriptLoadFileOnDevice ( const int  hnd,
int  slotNo,
char *  localFile 
)
C#
static Canlib.canStatus kvScriptLoadFileOnDevice(int hnd, int slotNo, ref string localFile);
Delphi
function kvScriptLoadFileOnDevice(hnd: canHandle; slotNo: Integer; localFile: PChar): kvStatus;

The kvScriptLoadFileOnDevice() function loads a compiled script file (.txe) stored on the device (SD card) into a script slot on the device.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot where to load the script.
[in]localFileThe script file name; a pointer to a NULL terminated array of chars.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptLoadFile(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()
kvStatus kvScriptRequestText ( const int  hnd,
unsigned int  slot,
unsigned int  request 
)
C#
static Canlib.canStatus kvScriptRequestText(int hnd, int slot, int request);
Delphi
function kvScriptRequestText(hnd: canHandle; slotNo: cardinal; request: cardinal): kvStatus;

The kvScriptRequestText() Sets up a printf subscription to a selected script slot. Read the printf messages with kvScriptGetText().

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotThe slot to subscribe to.
[in]requestSubscription request i.e. kvSCRIPT_REQUEST_TEXT_xxx.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
kvStatus kvScriptSendEvent ( const int  hnd,
int  slotNo,
int  eventType,
int  eventNo,
unsigned int  data 
)
C#
static Canlib.canStatus kvScriptSendEvent(int hnd, int slotNo, int eventType, int eventNo, uint data);
Delphi
function kvScriptSendEvent(const hnd: canHandle; slotNo: integer; eventType: integer; eventNo: integer; data: Cardinal): kvStatus;

The kvScriptSendEvent() function sends an event of a type, and an event number and associated data to a script running in a specific slot.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot where the script was loaded and is running.
[in]eventTypeThe event to send, of type kvEVENT_xxx
[in]eventNoThe event's number.
[in]dataThe event's data.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvStatus kvScriptStart ( const int  hnd,
int  slotNo 
)
C#
static Canlib.canStatus kvScriptStart(int hnd, int slotNo);
Delphi
function kvScriptStart(const hnd: canHandle; slotNo: integer): kvStatus;

The kvScriptStart() function starts a loaded script.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot with the loaded script we want to start.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptLoadFile(), kvScriptStop()
Examples:
envvar.c.
kvStatus kvScriptStatus ( const int  hnd,
int  slot,
unsigned int *  status 
)
C#
static Canlib.canStatus kvScriptStatus(int hnd, int slot, out unsigned int status);
Delphi
function kvScriptStatus(hnd: canHandle; var slot: integer; var time: integer): kvStatus;

The kvScriptStatus() function reads the current status of a script slot.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotThe slot which status we want.
[out]statusThe script status, as kvSCRIPT_STATUS_xxx flag bits
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
kvStatus kvScriptStop ( const int  hnd,
int  slotNo,
int  mode 
)
C#
static Canlib.canStatus kvScriptStop(int hnd, int slotNo, int mode);
Delphi
function kvScriptStop(const hnd: canHandle; slotNo: integer; mode: integer): kvStatus;

The kvScriptStop() function stops a started script.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot with the loaded and running script we want to stop.
[in]modeStop mode of type kvSCRIPT_STOP_xxx
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptLoadFile(), kvScriptStart()
Examples:
envvar.c.
kvStatus kvScriptUnload ( const int  hnd,
int  slotNo 
)
C#
static Canlib.canStatus kvScriptUnload(int hnd, int slotNo);
Delphi
function kvScriptUnload(const hnd: canHandle; slotNo: integer): kvStatus;

The kvScriptUnload() function unloads a stopped script.

Parameters:
[in]hndAn open handle to a CAN channel.
[in]slotNoThe slot with the loaded and stopped script we want to unload.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
kvScriptLoadFile(), kvScriptStop()
Examples:
envvar.c.