t-script

Starting, stopping scripts, moving files to/from device. More...

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, const 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, const 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 kvScriptGetMaxEnvvarSize (int hnd, int *envvarSize)
 
kvStatus kvScriptTxeGetData (const char *filePathOnPC, int item, void *buffer, unsigned int *bufsize)
 

Detailed Description

Starting, stopping scripts, moving files to/from device.

Function Documentation

◆ kvScriptEnvvarClose()

kvStatus kvScriptEnvvarClose ( kvEnvHandle  eHnd)
C#
static Canlib.kvStatus kvScriptEnvvarClose(kvEnvHandle 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:
example/c/tscript/envvar/envvar.c.

◆ kvScriptEnvvarGetData()

kvStatus kvScriptEnvvarGetData ( kvEnvHandle  eHnd,
void *  buf,
int  start_index,
int  data_len 
)
C#
static Canlib.kvStatus kvScriptEnvvarGetData(kvEnvHandle eHnd, out byte[] buf, Int32 start_index, Int32 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.

Note
Not implemented in linux.
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
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarSetData(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetFloat()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptEnvvarGetFloat()

kvStatus kvScriptEnvvarGetFloat ( kvEnvHandle  eHnd,
float *  val 
)
C#
static Canlib.kvStatus kvScriptEnvvarGetFloat(kvEnvHandle eHnd, out Single val);
Delphi
function kvScriptEnvvarGetFloat(const eHnd: kvEnvHandle; var val: Single): kvStatus;

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

Note
Not implemented in linux.
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
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarSetFloat(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetData()

◆ kvScriptEnvvarGetInt()

kvStatus kvScriptEnvvarGetInt ( kvEnvHandle  eHnd,
int *  val 
)
C#
static Canlib.kvStatus kvScriptEnvvarGetInt(kvEnvHandle eHnd, out Int32 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
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarSetInt(), kvScriptEnvvarGetFloat(), kvScriptEnvvarGetData()

◆ kvScriptEnvvarOpen()

kvEnvHandle kvScriptEnvvarOpen ( const int  hnd,
const char *  envvarName,
int *  envvarType,
int *  envvarSize 
)
C#
static kvEnvHandle kvScriptEnvvarOpen(CanHandle hnd, String envvarName, out Int32 envvarType, out Int32 envvarSize);
Delphi
function kvScriptEnvvarOpen(const hnd: canHandle; envvarName: PAnsiChar; 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
Environment Variable
kvScriptEnvvarClose()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptEnvvarSetData()

kvStatus kvScriptEnvvarSetData ( kvEnvHandle  eHnd,
const void *  buf,
int  start_index,
int  data_len 
)
C#
static Canlib.kvStatus kvScriptEnvvarSetData(kvEnvHandle eHnd, byte[] buf, Int32 start_index, Int32 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.

Note
Not implemented in linux.
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
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarGetData(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetFloat()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptEnvvarSetFloat()

kvStatus kvScriptEnvvarSetFloat ( kvEnvHandle  eHnd,
float  val 
)
C#
static Canlib.kvStatus kvScriptEnvvarSetFloat(kvEnvHandle eHnd, Single val);
Delphi
function kvScriptEnvvarSetFloat(const eHnd: kvEnvHandle; val: Single): kvStatus;

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

Note
Not implemented in linux.
Parameters
[in]eHndAn open handle to an envvar.
[in]valThe new value.
Returns
canOK (zero) if success
canERR_xxx (negative) if failure
See also
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarGetFloat(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetData()

◆ kvScriptEnvvarSetInt()

kvStatus kvScriptEnvvarSetInt ( kvEnvHandle  eHnd,
int  val 
)
C#
static Canlib.kvStatus kvScriptEnvvarSetInt(kvEnvHandle eHnd, Int32 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
Environment Variable
kvScriptEnvvarOpen(), kvScriptEnvvarGetInt(), kvScriptEnvvarSetFloat(), kvScriptEnvvarSetData()

◆ kvScriptGetMaxEnvvarSize()

kvStatus kvScriptGetMaxEnvvarSize ( int  hnd,
int *  envvarSize 
)
C#
static Canlib.kvStatus kvScriptGetMaxEnvvarSize(CanHandle hnd, out Int32 size);
Delphi
function kvScriptGetMaxEnvvarSize(hnd: canHandle; var envvarSize: Integer): kvStatus;

The kvScriptGetMaxEnvvarSize() function returns the maximum size of an envvar.

Note
Not implemented in linux.
Parameters
[in]hndAn open handle to a CAN channel.
[out]envvarSizeThe maximum size of an envvar.
Returns
canOK (zero) if success
canERR_xxx (negative) if failure

◆ kvScriptGetText()

kvStatus kvScriptGetText ( const int  hnd,
int *  slot,
unsigned long *  time,
unsigned int *  flags,
char *  buf,
size_t  bufsize 
)
C#
static Canlib.kvStatus kvScriptGetText(CanHandle hnd, out Int32 slot, out Int64 time, out Int32 flags, out String buf);
Delphi
function kvScriptGetText(hnd: canHandle; var slot: integer; var time: Cardinal; var flags: Cardinal; buf: PAnsiChar; bufsize: size_t): 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

◆ kvScriptLoadFile()

kvStatus kvScriptLoadFile ( const int  hnd,
int  slotNo,
char *  filePathOnPC 
)
C#
static Canlib.kvStatus kvScriptLoadFile(CanHandle hnd, Int32 slotNo, String filePathOnPC);
Delphi
function kvScriptLoadFile(hnd: canHandle; slotNo: Integer; filePathOnPC: PAnsiChar): kvStatus;

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

Note
The canHandle is used to determine what channel is set as the default channel for the loaded script. If your canHandle was opened via a device's second channel, the default channel number will be set to 1 (the numbering of channel on the card starts from 0).
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
Load and Unload Script
kvScriptLoadFileOnDevice(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptLoadFileOnDevice()

kvStatus kvScriptLoadFileOnDevice ( const int  hnd,
int  slotNo,
char *  localFile 
)
C#
static Canlib.kvStatus kvScriptLoadFileOnDevice(CanHandle hnd, Int32 slotNo, String localFile);
Delphi
function kvScriptLoadFileOnDevice(hnd: canHandle; slotNo: Integer; localFile: PAnsiChar): 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
Load and Unload Script
kvScriptLoadFile(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()

◆ kvScriptRequestText()

kvStatus kvScriptRequestText ( const int  hnd,
unsigned int  slot,
unsigned int  request 
)
C#
static Canlib.kvStatus kvScriptRequestText(CanHandle hnd, Int32 slot, Int32 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

◆ kvScriptSendEvent()

kvStatus kvScriptSendEvent ( const int  hnd,
int  slotNo,
int  eventType,
int  eventNo,
unsigned int  data 
)
C#
static Canlib.kvStatus kvScriptSendEvent(CanHandle hnd, Int32 slotNo, Int32 eventType, Int32 eventNo, Int32 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.

Note
Not implemented in linux.
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
Send Event

◆ kvScriptStart()

kvStatus kvScriptStart ( const int  hnd,
int  slotNo 
)
C#
static Canlib.kvStatus kvScriptStart(CanHandle hnd, Int32 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
Start and Stop script
kvScriptLoadFile(), kvScriptStop()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptStatus()

kvStatus kvScriptStatus ( const int  hnd,
int  slot,
unsigned int *  status 
)
C#
static Canlib.kvStatus kvScriptStatus(CanHandle hnd, Int32 slotNo, out Int32 status);
Delphi
function kvScriptStatus(hnd: canHandle; slot: integer; var status: Cardinal): 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

◆ kvScriptStop()

kvStatus kvScriptStop ( const int  hnd,
int  slotNo,
int  mode 
)
C#
static Canlib.kvStatus kvScriptStop(CanHandle hnd, Int32 slotNo, Int32 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
Start and Stop script
kvScriptLoadFile(), kvScriptStart()
Examples:
example/c/tscript/envvar/envvar.c.

◆ kvScriptTxeGetData()

kvStatus kvScriptTxeGetData ( const char *  filePathOnPC,
int  item,
void *  buffer,
unsigned int *  bufsize 
)
C#
static Canlib.kvStatus kvScriptTxeGetData(String filePathOnPC, Int32 item, out object buffer);
Delphi
function kvScriptTxeGetData(filePathOnPC: PAnsiChar; item: Integer; var buffer; var bufsize: Cardinal): canStatus;

This function can be used to retrieve information from a compiled script file (.txe).

Parameters
[in]filePathOnPCThe compiled script file name; a pointer to a NULL terminated array of chars.
[in]itemThis parameter specifies what data to obtain. Valid values are one of the constants canTXEDATA_xxx.
[out]bufferThe address of a buffer which is to receive the data.
[in,out]bufsizeThe size of the buffer to which the buffer parameter points. When the function returns, bufsize contains the number of bytes copied into the buffer.
Returns
canOK (zero) if success
canERR_xxx (negative) if failure

If the buffer specified by buffer and bufsize is not large enough to hold the data requested, the function returns canERR_BUFFER_TOO_SMALL and stores the required buffer size in the integer pointed to by bufsize. The content of buffer is undefined.

If parameter buffer is NULL, and bufsize is non-NULL, the function returns canOK and stores the required buffer size in the integer pointed to by bufsize.

◆ kvScriptUnload()

kvStatus kvScriptUnload ( const int  hnd,
int  slotNo 
)
C#
static Canlib.kvStatus kvScriptUnload(CanHandle hnd, Int32 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
Load and Unload Script
kvScriptLoadFile(), kvScriptStop()
Examples:
example/c/tscript/envvar/envvar.c.