![]() |
Kvaser ISO-TP SDK
|
Kvaser ISO-TP API. More...
#include <stdarg.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <dlfcn.h>Go to the source code of this file.
Data Structures | |
| struct | AddressInfo |
| ISO-TP address information. More... | |
| struct | CreateParams |
| A struct that holds the parameters for creating an ISO-TP channel. More... | |
| struct | WriteParams |
| A struct that holds the parameters for an ISO-TP write request. More... | |
| struct | IsoTpApi |
| A struct with all function pointers for the ISO-TP API. More... | |
Typedefs | |
| typedef enum CanMode | CanMode |
| Possible CAN modes. | |
| typedef enum MType | MType |
| The type of message to be sent. | |
| typedef enum NResult | NResult |
| The result of the reception or transmission of a message. | |
| typedef enum TAType | TAType |
| The type of target addressing used for the message. | |
| typedef struct AddressInfo | AddressInfo |
| ISO-TP address information. | |
| typedef struct CreateParams | CreateParams |
| A struct that holds the parameters for creating an ISO-TP channel. | |
| typedef struct WriteParams | WriteParams |
| A struct that holds the parameters for an ISO-TP write request. | |
| typedef void(WINAPI * | FFIndicationCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned int length, unsigned long long timestamp) |
| This callback prototype is used for indicating to the upper layers that a FirstFrame (FF) of a segmented message has been received. | |
| typedef void(WINAPI * | IndicationCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned int length, unsigned long long timestamp, const unsigned char *payload, unsigned int payload_length, enum NResult result) |
| This callback prototype is used for indicating to the upper layers that a complete message has been received, either a SingleFrame (SF) message or a segmented message. | |
| typedef void(WINAPI * | ConfirmCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned long long timestamp, enum NResult result, unsigned int request_handle) |
| This callback prototype is used for confirming to the upper layers that a write request has been completed, either a SingleFrame (SF) write request or a segmented data transfer request. | |
| typedef bool(WINAPI * | isotp_start_log_t) () |
| Function prototype for starting the logger for the library. | |
| typedef int(WINAPI * | isotp_create_t) (const struct CreateParams *create_params) |
| Function prototype for creating and opening a new ISO-TP channel. | |
| typedef void(WINAPI * | isotp_destroy_t) (int isotp_handle) |
| Function prototype for closing and removing the ISO-TP channel with the specified handle. | |
| typedef bool(WINAPI * | isotp_register_callbacks_t) (int isotp_handle, FFIndicationCallback ff_indication_callback, IndicationCallback indication_callback, ConfirmCallback confirm_callback) |
| Function prototype for registering callback functions for the ISO-TP channel. | |
| typedef bool(WINAPI * | isotp_set_full_duplex_t) (int isotp_handle, bool value) |
| Function prototype for setting the full_duplex settings. | |
| typedef bool(WINAPI * | isotp_set_j1939_priority_masking_t) (int isotp_handle, bool value) |
| Function prototype for setting the j1939_priority_masking settings. | |
| typedef bool(WINAPI * | isotp_set_pad_value_t) (int isotp_handle, unsigned char value) |
| Function prototype for setting the pad_value settings. | |
| typedef bool(WINAPI * | isotp_set_block_size_t) (int isotp_handle, unsigned char value) |
| Function prototype for setting the block_size settings. | |
| typedef bool(WINAPI * | isotp_set_min_separation_time_t) (int isotp_handle, unsigned char value) |
| Function prototype for setting the min_separation_time settings. | |
| typedef bool(WINAPI * | isotp_set_block_size_override_t) (int isotp_handle, unsigned char value) |
| Function prototype for setting the block_size_override settings. | |
| typedef bool(WINAPI * | isotp_set_min_separation_time_override_t) (int isotp_handle, unsigned char value) |
| Function prototype for setting the min_separation_time_override settings. | |
| typedef bool(WINAPI * | isotp_set_cr_max_t) (int isotp_handle, unsigned int value) |
| Function prototype for setting the cr_max settings. | |
| typedef bool(WINAPI * | isotp_set_a_max_t) (int isotp_handle, unsigned int value) |
| Function prototype for setting the a_max settings. | |
| typedef bool(WINAPI * | isotp_set_bs_max_t) (int isotp_handle, unsigned int value) |
| Function prototype for setting the bs_max settings. | |
| typedef bool(WINAPI * | isotp_set_wft_max_t) (int isotp_handle, unsigned int value) |
| Function prototype for setting the wft_max settings. | |
| typedef int(WINAPI * | isotp_open_t) (int isotp_handle) |
| Function prototype for opening the specified ISO-TP channel and taking its CAN channel bus-on. | |
| typedef int(WINAPI * | isotp_close_t) (int isotp_handle) |
| Function prototype for closing this channel and taking its CAN channel off-bus. | |
| typedef bool(WINAPI * | isotp_write_t) (int isotp_handle, const struct WriteParams *write_params) |
| Function prototype for sending a message. | |
| typedef struct IsoTpApi | IsoTpApi |
| A struct with all function pointers for the ISO-TP API. | |
| typedef bool(WINAPI * | isotp_get_api_t) (IsoTpApi *pApi) |
| Get the ISO-TP API. | |
Enumerations | |
| enum | CanMode { Can , CanFd , CanFdNonIso } |
| Possible CAN modes. More... | |
| enum | MType { Diagnostics = 1 , RemoteDiagnostics = 2 } |
| The type of message to be sent. More... | |
| enum | NResult { Ok = 0 , TimeoutA = 1 , TimeoutBs = 2 , TimeoutCr = 3 , WrongSN = 4 , InvalidFS = 5 , UnexpPDU = 6 , WftOvrn = 7 , BufferOvflw = 8 , Error = 9 } |
| The result of the reception or transmission of a message. More... | |
| enum | TAType { PhysicalCanStandard = 1 , FunctionalCanStandard = 2 , PhysicalCanFdStandard = 3 , FunctionalCanFdStandard = 4 , PhysicalCanExtended = 5 , FunctionalCanExtended = 6 , PhysicalCanFdExtended = 7 , FunctionalCanFdExtended = 8 } |
| The type of target addressing used for the message. More... | |
Functions | |
| void | clear_api (IsoTpApi *pApi) |
| Clears the contents of an ISO-TP API structure. | |
| IsoTpApi | create_api () |
| Create a new ISO-TP API structure. | |
| void | unload_library (IsoTpApi *pApi) |
| Unload the Kvaser ISO-TP library and clear the API structure. | |
| IsoTpApi | load_library (const char *lib_path) |
| Load the Kvaser ISO-TP library. | |
Kvaser ISO-TP API.
This header file defines the Kvaser ISO-TP API, which provides functions for creating and managing ISO-TP channels.
| typedef void(WINAPI * ConfirmCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned long long timestamp, enum NResult result, unsigned int request_handle) |
This callback prototype is used for confirming to the upper layers that a write request has been completed, either a SingleFrame (SF) write request or a segmented data transfer request.
| m_type | The message type.
|
| can_id | The CAN identifier. |
| ta_type | The target address type.
|
| address_extension | The address extension, ignored if m_type is not RemoteDiagnostics. |
| timestamp | The timestamp (in microseconds) of when the complete message has been transmitted. |
| result | The result of the transmission. |
| request_handle | A unique request handle, copied from the original isotp_write call. |
| typedef void(WINAPI * FFIndicationCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned int length, unsigned long long timestamp) |
This callback prototype is used for indicating to the upper layers that a FirstFrame (FF) of a segmented message has been received.
| m_type | The message type.
|
| can_id | The CAN identifier. |
| ta_type | The target address type.
|
| address_extension | The address extension, ignored if m_type is not RemoteDiagnostics. |
| length | The total length of the message that is being received. |
| timestamp | The timestamp (in microseconds) of the first frame. |
| typedef void(WINAPI * IndicationCallback) (enum MType m_type, unsigned int can_id, enum TAType ta_type, unsigned char address_extension, unsigned int length, unsigned long long timestamp, const unsigned char *payload, unsigned int payload_length, enum NResult result) |
This callback prototype is used for indicating to the upper layers that a complete message has been received, either a SingleFrame (SF) message or a segmented message.
| m_type | The message type.
|
| can_id | The CAN identifier. |
| ta_type | The target address type.
|
| address_extension | The address extension, ignored if m_type is not RemoteDiagnostics. |
| length | The total length of the message that has been received. |
| timestamp | The timestamp (in microseconds) of the last frame of the message. |
| payload | The data payload of the message. |
| payload_length | The length of the data payload. |
| result | The result of the reception. |
| typedef int(WINAPI * isotp_close_t) (int isotp_handle) |
Function prototype for closing this channel and taking its CAN channel off-bus.
| isotp_handle | The handle to the ISO-TP channel. |
| typedef int(WINAPI * isotp_create_t) (const struct CreateParams *create_params) |
Function prototype for creating and opening a new ISO-TP channel.
| create_params | The parameters for creating the ISO-TP channel. |
| typedef void(WINAPI * isotp_destroy_t) (int isotp_handle) |
Function prototype for closing and removing the ISO-TP channel with the specified handle.
| isotp_handle | The handle to the ISO-TP channel to be removed. |
| typedef bool(WINAPI * isotp_get_api_t) (IsoTpApi *pApi) |
Get the ISO-TP API.
| pApi | Pointer to the IsoTpApi structure to fill. |
| typedef int(WINAPI * isotp_open_t) (int isotp_handle) |
Function prototype for opening the specified ISO-TP channel and taking its CAN channel bus-on.
| isotp_handle | The handle to the ISO-TP channel. |
| typedef bool(WINAPI * isotp_register_callbacks_t) (int isotp_handle, FFIndicationCallback ff_indication_callback, IndicationCallback indication_callback, ConfirmCallback confirm_callback) |
Function prototype for registering callback functions for the ISO-TP channel.
Call this function after creating the ISO-TP channel and before opening it.
| isotp_handle | The handle to the ISO-TP channel to add callbacks to. |
| ff_indication_callback | The FirstFrame (FF) indication callback. |
| indication_callback | The message received indication callback. |
| confirm_callback | The message transmitted confirmation callback. |
| typedef bool(WINAPI * isotp_set_a_max_t) (int isotp_handle, unsigned int value) |
Function prototype for setting the a_max settings.
Max time allowed between a request and its confirmation, N_As_Max and N_Ar_Max. Specified as milliseconds.
Call this function after creating the ISO-TP channel and before opening it to set the N_As_Max and N_Ar_Max timeout. Default is 1000 milliseconds.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_block_size_override_t) (int isotp_handle, unsigned char value) |
Function prototype for setting the block_size_override settings.
An optional block size override. If set, then this value will be used instead of the value specified in the flow control frame.
Call this function after creating the ISO-TP channel and before opening it to set the block size override. Default is not set (no override).
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_block_size_t) (int isotp_handle, unsigned char value) |
Function prototype for setting the block_size settings.
Call this function after creating the ISO-TP channel and before opening it to set the block size. Default is 0.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_bs_max_t) (int isotp_handle, unsigned int value) |
Function prototype for setting the bs_max settings.
Max allowed time until reception of next flow control frame, N_Bs_Max. Specified as milliseconds.
Call this function after creating the ISO-TP channel and before opening it to set the N_Bs_Max timeout. Default is 1000 milliseconds.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_cr_max_t) (int isotp_handle, unsigned int value) |
Function prototype for setting the cr_max settings.
Max allowed time until reception of the next consecutive frame, N_Cr_Max. Specified as milliseconds.
Call this function after creating the ISO-TP channel and before opening it to set the N_Cr_Max timeout. Default is 1000 milliseconds.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_full_duplex_t) (int isotp_handle, bool value) |
Function prototype for setting the full_duplex settings.
Call this function after creating the ISO-TP channel and before opening it to set the full duplex mode. Default is true.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_j1939_priority_masking_t) (int isotp_handle, bool value) |
Function prototype for setting the j1939_priority_masking settings.
When this flag is set, the J1939 priority bits (28-26 of the CAN ID) shall be masked on all received messages. The priority bits shall be masked on all received ISO 15765 flow control messages and will be ignored if they are included in the LocalAddressInfo. However, transmitted ISO 15765 flow control messages shall include any priority bits set in the RemoteAddressInfo structure.
Call this function after creating the ISO-TP channel and before opening it to set the J1939 priority masking. Default is false.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_min_separation_time_override_t) (int isotp_handle, unsigned char value) |
Function prototype for setting the min_separation_time_override settings.
An optional minimum separation time override. If set, then this value will be used instead of the value specified in the flow control frame.
Call this function after creating the ISO-TP channel and before opening it to set the minimum separation time override. Default is not set (no override).
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_min_separation_time_t) (int isotp_handle, unsigned char value) |
Function prototype for setting the min_separation_time settings.
This value is coded according to ISO 15765-2, 0x00 to 0x7F is 0 to 127 milliseconds, 0xF1 to 0xF9 is 100 to 900 microseconds, all other values will be interpreted as 127 milliseconds.
Call this function after creating the ISO-TP channel and before opening it to set the minimum separation time. Default is 0.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_pad_value_t) (int isotp_handle, unsigned char value) |
Function prototype for setting the pad_value settings.
The value to be used when padding messages.
Call this function after creating the ISO-TP channel and before opening it to set the padding value. Default is 0xCC.
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_set_wft_max_t) (int isotp_handle, unsigned int value) |
Function prototype for setting the wft_max settings.
Max number of FC.WAIT frames that can be sent in a row. If set to 0, then there is no limit.
Call this function after creating the ISO-TP channel and before opening it to set the wft_max setting. Default is 0 (no limit).
| isotp_handle | The handle to the ISO-TP channel. |
| value | The new value. |
| typedef bool(WINAPI * isotp_start_log_t) () |
Function prototype for starting the logger for the library.
This function configures the logger to log messages to both the console and a file named kvisotplib.log.
| typedef bool(WINAPI * isotp_write_t) (int isotp_handle, const struct WriteParams *write_params) |
Function prototype for sending a message.
The call returns immediately after queuing the message to the driver, so the message has not necessarily been transmitted.
| isotp_handle | The handle to the ISO-TP channel. |
| write_params | The parameters containing the message to send. |
A struct with all function pointers for the ISO-TP API.
The result of the reception or transmission of a message.
This enum is used to inform about the result of the reception or transmission of a message.
| enum CanMode |
| enum MType |
| enum NResult |
The result of the reception or transmission of a message.
This enum is used to inform about the result of the reception or transmission of a message.
| enum TAType |
The type of target addressing used for the message.
| void clear_api | ( | IsoTpApi * | pApi | ) |
Clears the contents of an ISO-TP API structure.
| pApi | Pointer to the IsoTpApi structure to clear. |
| IsoTpApi load_library | ( | const char * | lib_path | ) |
Load the Kvaser ISO-TP library.
| lib_path | The path to the library to load. Pass NULL to use default names, "kvisotplib.dll" on Windows and "libkvisotplib.so" on Linux. |
| void unload_library | ( | IsoTpApi * | pApi | ) |
Unload the Kvaser ISO-TP library and clear the API structure.
| pApi | Pointer to the IsoTpApi structure to unload. |