Functions
t-script
CANlib

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

## Functions
kvStatus | kvScriptStart (const CanHandle hnd, int slotNo)
kvStatus | kvScriptStop (const CanHandle hnd, int slotNo, int mode)
kvStatus | kvScriptUnload (const CanHandle hnd, int slotNo)
kvStatus | kvScriptSendEvent (const CanHandle hnd, int slotNo, int eventType, int eventNo, unsigned int data)
kvEnvHandle | kvScriptEnvvarOpen (const CanHandle 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 CanHandle hnd, int slotNo, char *localFile)
kvStatus | kvScriptLoadFile (const CanHandle hnd, int slotNo, char *filePathOnPC)
kvStatus | kvScriptStatus (const CanHandle hnd, int slot, unsigned int *status)
kvStatus | kvScriptGetMaxEnvvarSize (int hnd, int *envvarSize)
kvStatus | kvScriptTxeGetData (const char *filePathOnPC, int item, void *buffer, unsigned int *bufsize)
kvStatus | kvFileCopyToDevice (const CanHandle hnd, char *hostFileName, char *deviceFileName)
kvStatus | kvFileCopyFromDevice (const CanHandle hnd, char *deviceFileName, char *hostFileName)
kvStatus | kvFileDelete (const CanHandle hnd, char *deviceFileName)
kvStatus | kvFileGetName (const CanHandle hnd, int fileNo, char *name, int namelen)
kvStatus | kvFileGetCount (const CanHandle hnd, int *count)
kvStatus | kvFileGetSystemData (const CanHandle hnd, int itemCode, int *result)

## Detailed Description

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

## Function Documentation

## ◆ kvFileCopyFromDevice()

kvStatus kvFileCopyFromDevice | ( | const CanHandle | hnd,
|  | char * | deviceFileName,
|  | char * | hostFileName
| ) |  |

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

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | deviceFileName | The device file name; a pointer to a `NULL` terminated array of chars.
  [in] | hostFileName | The 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()

## ◆ kvFileCopyToDevice()

kvStatus kvFileCopyToDevice | ( | const CanHandle | hnd,
|  | char * | hostFileName,
|  | char * | deviceFileName
| ) |  |

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

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | hostFileName | The host file name; a pointer to a `NULL` terminated array of chars.
  [in] | deviceFileName | The 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()

## ◆ kvFileDelete()

kvStatus kvFileDelete | ( | const CanHandle | hnd,
|  | char * | deviceFileName
| ) |  |

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

Note
  Deleting system files is not recommended.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | deviceFileName | The 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()

## ◆ kvFileGetCount()

kvStatus kvFileGetCount | ( | const CanHandle | hnd,
|  | int * | count
| ) |  |

The kvFileGetCount() function returns the number of files.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [out] | count | A 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()

## ◆ kvFileGetName()

kvStatus kvFileGetName | ( | const CanHandle | hnd,
|  | int | fileNo,
|  | char * | name,
|  | int | namelen
| ) |  |

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

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | fileNo | The number of the file.
  [out] | name | A buffer that will contain the name of the file. The name is a zero-terminated ASCII string.
  [in] | namelen | The length, in bytes, of the name buffer.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvFileGetCount(), kvFileGetSystemData()

## ◆ kvFileGetSystemData()

kvStatus kvFileGetSystemData | ( | const CanHandle | hnd,
|  | int | itemCode,
|  | int * | result
| ) |  |

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

Note
  Not yet implemented

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | itemCode | The item we want information on.
  [out] | result | A pointer to a 32-bit integer that will receive the result.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

## ◆ kvScriptEnvvarClose()

kvStatus kvScriptEnvvarClose | ( | kvEnvHandle | eHnd | ) |

The kvScriptEnvvarClose() function closes an open envvar.

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarOpen()

## ◆ kvScriptEnvvarGetData()

kvStatus kvScriptEnvvarGetData | ( | kvEnvHandle | eHnd,
|  | void * | buf,
|  | int | start_index,
|  | int | data_len
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [out] | buf | A pointer to a data area where the retrieved data range should be stored.
  [in] | start_index | The start index of the data range.
  [in] | data_len | The length in bytes of the data range.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarSetData(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetFloat()

## ◆ kvScriptEnvvarGetFloat()

kvStatus kvScriptEnvvarGetFloat | ( | kvEnvHandle | eHnd,
|  | float * | val
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [out] | val | A pointer to a `float` where the retrieved result should be stored.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarSetFloat(), kvScriptEnvvarGetInt(), kvScriptEnvvarGetData()

## ◆ kvScriptEnvvarGetInt()

kvStatus kvScriptEnvvarGetInt | ( | kvEnvHandle | eHnd,
|  | int * | val
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [out] | val | The current value.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarSetInt(), kvScriptEnvvarGetFloat(), kvScriptEnvvarGetData()

## ◆ kvScriptEnvvarOpen()

kvEnvHandle kvScriptEnvvarOpen | ( | const CanHandle | hnd,
|  | char * | envvarName,
|  | int * | envvarType,
|  | int * | envvarSize
| ) |  |

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

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | envvarName | The envvar's name; a pointer to a `NULL` terminated array of chars.
  [out] | envvarType | A pointer to a 32-bit integer that will receive the kvENVVAR_TYPE_xxx type.
  [out] | envvarSize | A pointer to a 32-bit integer that will receive the size of the envvar in bytes.

Note
  Not implemented in linux.

Returns
  A kvEnvHandle handle (positive) to an envvar if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarClose()

## ◆ kvScriptEnvvarSetData()

kvStatus kvScriptEnvvarSetData | ( | kvEnvHandle | eHnd,
|  | void * | buf,
|  | int | start_index,
|  | int | data_len
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [in] | buf | A pointer to a data area with the new values.
  [in] | start_index | The start index of the envvar's data range that we want to update.
  [in] | data_len | The 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
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarGetData(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetFloat()

## ◆ kvScriptEnvvarSetFloat()

kvStatus kvScriptEnvvarSetFloat | ( | kvEnvHandle | eHnd,
|  | float | val
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [in] | val | The new value.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarGetFloat(), kvScriptEnvvarSetInt(), kvScriptEnvvarSetData()

## ◆ kvScriptEnvvarSetInt()

kvStatus kvScriptEnvvarSetInt | ( | kvEnvHandle | eHnd,
|  | int | val
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | eHnd | An open handle to an envvar.
  [in] | val | The new value.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptEnvvarXxx Example
  kvScriptEnvvarOpen(), kvScriptEnvvarGetInt(), kvScriptEnvvarSetFloat(), kvScriptEnvvarSetData()

## ◆ kvScriptGetMaxEnvvarSize()

kvStatus kvScriptGetMaxEnvvarSize | ( | int | hnd,
|  | int * | envvarSize
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [out] | envvarSize | The maximum size of an envvar.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

## ◆ kvScriptLoadFile()

kvStatus kvScriptLoadFile | ( | const CanHandle | hnd,
|  | int | slotNo,
|  | char * | filePathOnPC
| ) |  |

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

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot where to load the script.
  [in] | filePathOnPC | The script file name; a pointer to a `NULL` terminated array of chars.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptStart Example
  kvScriptLoadFileOnDevice(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()

## ◆ kvScriptLoadFileOnDevice()

kvStatus kvScriptLoadFileOnDevice | ( | const CanHandle | hnd,
|  | int | slotNo,
|  | char * | localFile
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot where to load the script.
  [in] | localFile | The script file name; a pointer to a `NULL` terminated array of chars.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptStart Example
  kvScriptLoadFile(), kvFileCopyToDevice(), kvScriptStart(), kvScriptStop()

## ◆ kvScriptSendEvent()

kvStatus kvScriptSendEvent | ( | const CanHandle | hnd,
|  | int | slotNo,
|  | int | eventType,
|  | int | eventNo,
|  | unsigned int | data
| ) |  |

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] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot where the script was loaded and is running.
  [in] | eventType | The event to send, of type kvEVENT_xxx
  [in] | eventNo | The event's number.
  [in] | data | The event's data.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptSendEvent Example

## ◆ kvScriptStart()

kvStatus kvScriptStart | ( | const CanHandle | hnd,
|  | int | slotNo
| ) |  |

The kvScriptStart() function starts a loaded script.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot with the loaded script we want to start.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptStart Example
  kvScriptLoadFile(), kvScriptStop()

## ◆ kvScriptStatus()

kvStatus kvScriptStatus | ( | const CanHandle | hnd,
|  | int | slot,
|  | unsigned int * | status
| ) |  |

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

Note
  Not implemented in linux.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slot | The slot which status we want.
  [out] | status | The script status, as kvSCRIPT_STATUS_xxx flag bits

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

## ◆ kvScriptStop()

kvStatus kvScriptStop | ( | const CanHandle | hnd,
|  | int | slotNo,
|  | int | mode
| ) |  |

The kvScriptStop() function stops a started script.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot with the loaded and running script we want to stop.
  [in] | mode | Stop mode of type kvSCRIPT_STOP_xxx

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptStart Example
  kvScriptLoadFile(), kvScriptStart()

## ◆ kvScriptTxeGetData()

kvStatus kvScriptTxeGetData | ( | const char * | filePathOnPC,
|  | int | item,
|  | void * | buffer,
|  | unsigned int * | bufsize
| ) |  |

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

Parameters

  [in] | filePathOnPC | The compiled script file name; a pointer to a `NULL` terminated array of chars.
  [in] | item | This parameter specifies what data to obtain. Valid values are one of the constants canTXEDATA_xxx.
  [out] | buffer | The address of a buffer which is to receive the data.
  [in,out] | bufsize | The 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 CanHandle | hnd,
|  | int | slotNo
| ) |  |

The kvScriptUnload() function unloads a stopped script.

Parameters

  [in] | hnd | An open handle to a CAN channel.
  [in] | slotNo | The slot with the loaded and stopped script we want to unload.

Returns
  canOK (zero) if success
  canERR_xxx (negative) if failure

See also
  kvScriptLoadFile(), kvScriptStop()