Kvaser J1939 Library
kvj1939lib_types.h
Go to the documentation of this file.
1#ifndef KVJ1939LIB_TYPES_H
2#define KVJ1939LIB_TYPES_H
3
9/* API type definitions */
10#include <stdbool.h>
11#include <stdint.h>
12
16typedef enum J1939Result {
38
42typedef enum J1939ChannelOption {
68
72typedef uint32_t J1939ChannelHandle;
73
77typedef struct J1939ChannelParams {
79 uint32_t channel;
84 uint32_t bit_rate;
86
91typedef struct J1939ChannelResult {
97
101typedef struct J1939Identifier {
103 uint32_t pgn;
105 uint8_t priority;
107 uint8_t src_addr;
109 uint8_t dest_addr;
111
115typedef struct J1939WriteParams {
119 const uint8_t* payload;
126
131typedef struct J1939ReadResult {
137 uint64_t timestamp;
141
150 uint32_t value;
152
165typedef void (*J1939RxCallback)(J1939ChannelHandle hnd, void* context, J1939Identifier id,
166 uint64_t timestamp, const uint8_t* payload, uint32_t payload_length,
167 bool error);
168
180typedef void (*J1939TxCallback)(J1939ChannelHandle hnd, void* context, uint32_t request_handle,
181 J1939Identifier id, uint64_t timestamp, bool error);
182
192typedef void (*J1939AcCallback)(J1939ChannelHandle hnd, void* context, uint8_t address, bool valid);
193
194#endif /* KVJ1939LIB_TYPES_H */
uint32_t J1939ChannelHandle
A handle to a J1939 channel.
Definition: kvj1939lib_types.h:72
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 complet...
Definition: kvj1939lib_types.h:192
struct J1939WriteParams J1939WriteParams
A struct that holds the parameters for a J1939 write request.
struct J1939ChannelResult J1939ChannelResult
A struct that holds the result and handle for creating a j1939 channel.
J1939Result
Return status codes, indicating the result of an operation.
Definition: kvj1939lib_types.h:16
@ J1939_STATUS_NOT_SUPPORTED
The requested operation is not supported.
Definition: kvj1939lib_types.h:26
@ J1939_STATUS_INVALID_CHANNEL
The specified channel is invalid or in the wrong state.
Definition: kvj1939lib_types.h:22
@ J1939_STATUS_TX_BUFFER_FULL
Tx buffer is full.
Definition: kvj1939lib_types.h:30
@ J1939_STATUS_TIMEOUT
The operation timed out.
Definition: kvj1939lib_types.h:28
@ J1939_STATUS_INVALID_PARAMS
The specified parameters are invalid.
Definition: kvj1939lib_types.h:24
@ J1939_STATUS_ERROR_FRAME
The message was received with frame errors.
Definition: kvj1939lib_types.h:36
@ J1939_STATUS_ERROR
A general error occurred.
Definition: kvj1939lib_types.h:20
@ J1939_STATUS_OK
Operation completed successfully.
Definition: kvj1939lib_types.h:18
@ J1939_STATUS_ADDRESS_CLAIM_LOST
Address claim failed or lost.
Definition: kvj1939lib_types.h:32
@ J1939_STATUS_BUFFER_TOO_SMALL
The provided buffer is too small.
Definition: kvj1939lib_types.h:34
struct J1939ChannelOptionResult J1939ChannelOptionResult
A struct that holds the result and value for a J1939 channel option.
struct J1939ChannelParams J1939ChannelParams
A struct that holds the parameters for creating a j1939 channel.
struct J1939Identifier J1939Identifier
A struct that represents a J1939 identifier.
J1939ChannelOption
Properties that can be configured on a J1939 channel.
Definition: kvj1939lib_types.h:42
@ J1939_OPTION_TP_T2_TIMEOUT
Set the T2 timeout (in milliseconds) for TP sessions (0-20000). Default is 1250.
Definition: kvj1939lib_types.h:62
@ J1939_OPTION_TP_PASSTHROUGH_MODE
Enable or disable TP passthrough mode (1: enable, 0: disable). Default is disabled....
Definition: kvj1939lib_types.h:49
@ 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...
Definition: kvj1939lib_types.h:55
@ 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)....
Definition: kvj1939lib_types.h:58
@ J1939_OPTION_TX_ECHO
Enable or disable echoing transmitted messages (1: enable, 0: disable). Default is enabled.
Definition: kvj1939lib_types.h:44
@ J1939_OPTION_TP_T4_TIMEOUT
Set the T4 timeout (in milliseconds) for TP sessions (0-20000). Default is 1050.
Definition: kvj1939lib_types.h:66
@ J1939_OPTION_TP_T1_TIMEOUT
Set the T1 timeout (in milliseconds) for TP sessions (0-20000). Default is 750.
Definition: kvj1939lib_types.h:60
@ J1939_OPTION_TP_T3_TIMEOUT
Set the T3 timeout (in milliseconds) for TP sessions (0-20000). Default is 1250.
Definition: kvj1939lib_types.h:64
@ J1939_OPTION_TP_BAM_INTERPACKET_TIME
Set the delay (in milliseconds) between consecutive TP segments when sending BAM messages (0-200)....
Definition: kvj1939lib_types.h:52
struct J1939ReadResult J1939ReadResult
A struct that holds the result and header information for a J1939 read operation.
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,...
Definition: kvj1939lib_types.h:180
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,...
Definition: kvj1939lib_types.h:165
A struct that holds the result and value for a J1939 channel option.
Definition: kvj1939lib_types.h:146
J1939Result result
The result of the operation.
Definition: kvj1939lib_types.h:148
uint32_t value
The value of the requested channel option, if successful.
Definition: kvj1939lib_types.h:150
A struct that holds the parameters for creating a j1939 channel.
Definition: kvj1939lib_types.h:77
uint32_t channel
The CANlib channel number to use.
Definition: kvj1939lib_types.h:79
uint32_t bit_rate
The bit rate to use for the channel. If set to 0, then this channel will be opened with NO_INIT_ACCES...
Definition: kvj1939lib_types.h:84
bool support_virtual
True if virtual channels are supported.
Definition: kvj1939lib_types.h:81
A struct that holds the result and handle for creating a j1939 channel.
Definition: kvj1939lib_types.h:91
J1939Result result
The result of the operation.
Definition: kvj1939lib_types.h:93
J1939ChannelHandle hnd
The handle to the created channel, if successful.
Definition: kvj1939lib_types.h:95
A struct that represents a J1939 identifier.
Definition: kvj1939lib_types.h:101
uint8_t priority
The priority of the message. 0 = highest, 7 = lowest.
Definition: kvj1939lib_types.h:105
uint8_t dest_addr
The destination address of the message. Ignored for PDU2 messages.
Definition: kvj1939lib_types.h:109
uint8_t src_addr
The source address of the message.
Definition: kvj1939lib_types.h:107
uint32_t pgn
The message PGN. The lower byte is 0 for PDU1 messages.
Definition: kvj1939lib_types.h:103
A struct that holds the result and header information for a J1939 read operation.
Definition: kvj1939lib_types.h:131
J1939Identifier id
The J1939 identifier of the message, if successful.
Definition: kvj1939lib_types.h:135
J1939Result result
The result of the operation.
Definition: kvj1939lib_types.h:133
uint32_t payload_length
The length of the message data, if successful.
Definition: kvj1939lib_types.h:139
uint64_t timestamp
The timestamp (in microseconds) of the last frame of the message, if successful.
Definition: kvj1939lib_types.h:137
A struct that holds the parameters for a J1939 write request.
Definition: kvj1939lib_types.h:115
const uint8_t * payload
Pointer to the message data to be sent.
Definition: kvj1939lib_types.h:119
struct J1939Identifier id
The J1939 identifier of the message to be sent.
Definition: kvj1939lib_types.h:117
uint32_t payload_length
The length of the message data to be sent.
Definition: kvj1939lib_types.h:121
uint32_t request_handle
A unique handle to the write request. Tx confirmation callback will be called with this handle if it ...
Definition: kvj1939lib_types.h:124