Web Analytics

Kneron PLUS core APIs

Core functions provide fundamental functionality like connection and firmware update

Include Header File: kp_core.h


Functions

kp_connect_devices

To connect multiple (including one) Kneron devices.

kp_device_group_t kp_connect_devices(
    int num_devices
    int device_port_ids[]
    int *error_code
)
Parameters:

num_devices     [in]      number of devices
device_port_ids [in]      an array contains device's port ID which can be known from kp_scan_devices(), if '0' is given then it will try to connect first connectable device.
error_code      [out]     optional variable to indicate an error if connecting devices failed.

Returns:

kp_device_group_t represents a set of devices handle, if NULL means failed.


kp_disable_firmware_log

Disable firmware log of all devices with firmware log enabled.

int kp_disable_firmware_log(
    kp_device_group_t devices
)
Parameters:

devices         [in]      a set of devices handle.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_disconnect_devices

To disconnect a Kneron device.

int kp_disconnect_devices(
    kp_device_group_t devices
)
Parameters:

devices         [in]      a set of devices handle.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_enable_firmware_log

Enable firmware log from certain device.

int kp_enable_firmware_log(
    kp_device_group_t devices
    int dev_port_id
    char *log_file_path
)
This function enables receiving firmware log from certain device with specific device index. The firmware log could be written to text file or directly output to stdout.

Parameters:

devices         [in]      a set of devices handle.
dev_port_id     [in]      the device port id to enable firmware log.
log_file_path   [in]      the log file path, if NULL is passed then firmware log would be directly output to stdout.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_error_string

Translate error code to char string.

const char *kp_error_string(
    int error_code
)
Parameters:

error_code      [in]      status/error code from enum KP_API_RETURN_CODE.

Returns:

a char buffer of string represents the error message.


kp_get_model_info

Get model info (crc, model id, etc.).

int kp_get_model_info(
    kp_device_group_t devices
    int dev_port_id
    kp_model_nef_descriptor_t *all_models_desc
)
Parameters:

devices         [in]      a set of devices handle.
dev_port_id     [in]      specific device port id.
all_models_desc [out]     return value of model info.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_get_system_info

Get system info (kn number and firmware version).

int kp_get_system_info(
    kp_device_group_t devices
    int dev_port_id
    kp_system_info_t *system_info
)
Parameters:

devices         [in]      a set of devices handle.
dev_port_id     [in]      specific device port id.
system_info     [out]     return value of system info.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_get_version

Get PLUS version.

const char *kp_get_version()
Returns:

a string represents the PLUS version.


kp_load_firmware

upload firmware from buffers

int kp_load_firmware(
    kp_device_group_t devices
    void *scpu_fw_buf
    int scpu_fw_size
    void *ncpu_fw_buf
    int ncpu_fw_size
)
Parameters:

devices         [in]      a set of devices handle.
scpu_fw_buf     [in]      scpu firmware buffer
scpu_fw_size    [in]      scpu firmware size
ncpu_fw_buf     [in]      ncpu firmware buffer
ncpu_fw_size    [in]      ncpu firmware size

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_load_firmware_from_file

upload firmware from file

int kp_load_firmware_from_file(
    kp_device_group_t devices
    const char *scpu_fw_path
    const char *ncpu_fw_path
)
Parameters:

devices         [in]      a set of devices handle.
scpu_fw_path    [in]      scpu firmware file path
ncpu_fw_path    [in]      ncpu firmware file path

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_load_model

upload models to device through USB

int kp_load_model(
    kp_device_group_t devices
    void *nef_buf
    int nef_size
    kp_model_nef_descriptor_t *model_desc
)
Parameters:

devices         [in]      a set of devices handle.
nef_buf         [in]      a buffer contains the content of NEF file.
nef_size        [in]      file size of the NEF.
model_desc      [out]     this parameter is output for describing the uploaded models.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_load_model_from_file

Similar to kp_load_model(), and it accepts file path instead of a buffer.

int kp_load_model_from_file(
    kp_device_group_t devices
    const char *file_path
    kp_model_nef_descriptor_t *model_desc
)
Parameters:

devices         [in]      a set of devices handle.
file_path       [in]      a buffer contains the content of NEF file.
model_desc      [out]     this parameter is output for describing the uploaded models.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_load_model_from_flash

Load model from device flash

int kp_load_model_from_flash(
    kp_device_group_t devices
    kp_model_nef_descriptor_t *model_desc
)
Parameters:

devices         [in]      a set of devices handle.
model_desc      [out]     this parameter is output for describing the uploaded models.

Returns:

int refer to KP_API_RETURN_CODE in kp_struct.h


kp_reset_device

reset the device in hardware mode or software mode.

int kp_reset_device(
    kp_device_group_t devices
    kp_reset_mode_t reset_mode
)
Parameters:

devices         [in]      a set of devices handle.
reset_mode      [in]      refer to kp_reset_mode_t.

Returns:

refer to KP_API_RETURN_CODE in kp_struct.h


kp_scan_devices

Scan all Kneron devices and report a list.

kp_devices_list_t *kp_scan_devices()
This function can get devices connectivity information at runtime.

Returns:

refer to kp_devices_list_t.


kp_set_timeout

To set a global timeout value for all USB communications with the device.

void kp_set_timeout(
    kp_device_group_t devices
    int milliseconds
)
Parameters:

devices         [in]      a set of devices handle.
milliseconds    [in]      pre-set timeout value in milliseconds.