Kvaser J1939 Library
kvj1939lib_types.h File Reference

Type definitions for the KVJ1939 Library. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  J1939ChannelParams
 A struct that holds the parameters for creating a j1939 channel. More...
 
struct  J1939ChannelResult
 A struct that holds the result and handle for creating a j1939 channel. More...
 
struct  J1939Identifier
 A struct that represents a J1939 identifier. More...
 
struct  J1939WriteParams
 A struct that holds the parameters for a J1939 write request. More...
 
struct  J1939ReadResult
 A struct that holds the result and header information for a J1939 read operation. More...
 
struct  J1939ChannelOptionResult
 A struct that holds the result and value for a J1939 channel option. More...
 

Typedefs

typedef enum J1939Result J1939Result
 Return status codes, indicating the result of an operation.
 
typedef enum J1939ChannelOption J1939ChannelOption
 Properties that can be configured on a J1939 channel.
 
typedef uint32_t J1939ChannelHandle
 A handle to a J1939 channel.
 
typedef struct J1939ChannelParams J1939ChannelParams
 A struct that holds the parameters for creating a j1939 channel.
 
typedef struct J1939ChannelResult J1939ChannelResult
 A struct that holds the result and handle for creating a j1939 channel. More...
 
typedef struct J1939Identifier J1939Identifier
 A struct that represents a J1939 identifier.
 
typedef struct J1939WriteParams J1939WriteParams
 A struct that holds the parameters for a J1939 write request.
 
typedef struct J1939ReadResult J1939ReadResult
 A struct that holds the result and header information for a J1939 read operation. More...
 
typedef struct J1939ChannelOptionResult J1939ChannelOptionResult
 A struct that holds the result and value for a J1939 channel option. More...
 
typedef void(* J1939RxCallback) (J1939ChannelHandle hnd, void *context, J1939Identifier id, uint64_t timestamp, const uint8_t *payload, uint32_t payload_length, bool error)
 Callback prototype for notifying the upper layers that a complete message has been received, either a single frame message or a segmented message. More...
 
typedef void(* J1939TxCallback) (J1939ChannelHandle hnd, void *context, uint32_t request_handle, J1939Identifier id, uint64_t timestamp, bool error)
 Callback prototype for notifying the upper layers that a J1939 message has been sent on the CAN bus, either a single frame message or a segmented message. More...
 
typedef void(* J1939AcCallback) (J1939ChannelHandle hnd, void *context, uint8_t address, bool valid)
 Callback prototype for notifying the upper layers that a source address claim has been either completed or lost. More...
 

Enumerations

enum  J1939Result {
  J1939_STATUS_OK = 0 , J1939_STATUS_ERROR = -1 , J1939_STATUS_INVALID_CHANNEL = -2 , J1939_STATUS_INVALID_PARAMS = -3 ,
  J1939_STATUS_NOT_SUPPORTED = -4 , J1939_STATUS_TIMEOUT = -5 , J1939_STATUS_TX_BUFFER_FULL = -6 , J1939_STATUS_ADDRESS_CLAIM_LOST = -7 ,
  J1939_STATUS_BUFFER_TOO_SMALL = -8 , J1939_STATUS_ERROR_FRAME = -9
}
 Return status codes, indicating the result of an operation. More...
 
enum  J1939ChannelOption {
  J1939_OPTION_TX_ECHO , J1939_OPTION_TP_PASSTHROUGH_MODE , J1939_OPTION_TP_BAM_INTERPACKET_TIME , J1939_OPTION_TP_MAX_PACKETS_IN_RTS ,
  J1939_OPTION_TP_MAX_PACKETS_IN_CTS , J1939_OPTION_TP_T1_TIMEOUT , J1939_OPTION_TP_T2_TIMEOUT , J1939_OPTION_TP_T3_TIMEOUT ,
  J1939_OPTION_TP_T4_TIMEOUT
}
 Properties that can be configured on a J1939 channel. More...
 

Detailed Description

Type definitions for the KVJ1939 Library.

Typedef Documentation

◆ J1939AcCallback

typedef void(* J1939AcCallback) (J1939ChannelHandle hnd, void *context, uint8_t address, bool valid)

Callback prototype for notifying the upper layers that a source address claim has been either completed or lost.

Parameters
hndHandle to the channel.
contextUser-defined context pointer.
addressThe source address being claimed.
validTrue if the address claim was successful, false if it failed or was lost.

◆ J1939ChannelOptionResult

A struct that holds the result and value for a J1939 channel option.

If the result is not J1939_STATUS_OK, then the value will be invalid.

◆ J1939ChannelResult

A struct that holds the result and handle for creating a j1939 channel.

If the result is not J1939_STATUS_OK, then the handle will be invalid.

◆ J1939ReadResult

A struct that holds the result and header information for a J1939 read operation.

If the result is not J1939_STATUS_OK, then the other fields will be invalid.

◆ J1939RxCallback

typedef void(* J1939RxCallback) (J1939ChannelHandle hnd, void *context, J1939Identifier id, uint64_t timestamp, const uint8_t *payload, uint32_t payload_length, bool error)

Callback prototype for notifying the upper layers that a complete message has been received, either a single frame message or a segmented message.

Parameters
hndHandle to the channel.
contextUser-defined context pointer.
idThe J1939 identifier.
timestampThe timestamp (in microseconds) of the last frame of the message.
payloadThe data payload of the message.
payload_lengthThe length of the data payload.
errorWhether the message was received with errors (error frame).

◆ J1939TxCallback

typedef void(* J1939TxCallback) (J1939ChannelHandle hnd, void *context, uint32_t request_handle, J1939Identifier id, uint64_t timestamp, bool error)

Callback prototype for notifying the upper layers that a J1939 message has been sent on the CAN bus, either a single frame message or a segmented message.

Parameters
hndHandle to the channel.
contextUser-defined context pointer.
request_handleThe J1939 identifier.
idThe J1939 identifier.
timestampThe timestamp (in microseconds) of the last frame of the message.
errorWhether the message transmission failed.

Enumeration Type Documentation

◆ J1939ChannelOption

Properties that can be configured on a J1939 channel.

Enumerator
J1939_OPTION_TX_ECHO 

Enable or disable echoing transmitted messages (1: enable, 0: disable). Default is enabled.

J1939_OPTION_TP_PASSTHROUGH_MODE 

Enable or disable TP passthrough mode (1: enable, 0: disable). Default is disabled. When TP passthrough mode is enabled, the library will not handle TP frames (TP.CM and TP.DT) and will instead pass them through to the application as single-frame messages.

J1939_OPTION_TP_BAM_INTERPACKET_TIME 

Set the delay (in milliseconds) between consecutive TP segments when sending BAM messages (0-200). Default is 50.

J1939_OPTION_TP_MAX_PACKETS_IN_RTS 

Set the maximum number of packets to send in each RTS/CTS window when transmitting TP messages (1-255). Default is 255 (no limit).

J1939_OPTION_TP_MAX_PACKETS_IN_CTS 

Set the maximum number of packets to receive in each CTS window when receiving TP messages (1-255). Default is 255 (no limit).

J1939_OPTION_TP_T1_TIMEOUT 

Set the T1 timeout (in milliseconds) for TP sessions (0-20000). Default is 750.

J1939_OPTION_TP_T2_TIMEOUT 

Set the T2 timeout (in milliseconds) for TP sessions (0-20000). Default is 1250.

J1939_OPTION_TP_T3_TIMEOUT 

Set the T3 timeout (in milliseconds) for TP sessions (0-20000). Default is 1250.

J1939_OPTION_TP_T4_TIMEOUT 

Set the T4 timeout (in milliseconds) for TP sessions (0-20000). Default is 1050.

◆ J1939Result

Return status codes, indicating the result of an operation.

Enumerator
J1939_STATUS_OK 

Operation completed successfully.

J1939_STATUS_ERROR 

A general error occurred.

J1939_STATUS_INVALID_CHANNEL 

The specified channel is invalid or in the wrong state.

J1939_STATUS_INVALID_PARAMS 

The specified parameters are invalid.

J1939_STATUS_NOT_SUPPORTED 

The requested operation is not supported.

J1939_STATUS_TIMEOUT 

The operation timed out.

J1939_STATUS_TX_BUFFER_FULL 

Tx buffer is full.

J1939_STATUS_ADDRESS_CLAIM_LOST 

Address claim failed or lost.

J1939_STATUS_BUFFER_TOO_SMALL 

The provided buffer is too small.

J1939_STATUS_ERROR_FRAME 

The message was received with frame errors.