Messages

Add, delete and modify messages. More...

Functions

KvaDbStatus kvaDbGetFirstMsg (KvaDbHnd dh, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetNextMsg (KvaDbHnd dh, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgById (KvaDbHnd dh, unsigned int id, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgByIdEx (KvaDbHnd dh, unsigned int id, unsigned int flags, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgByPGN (KvaDbHnd dh, unsigned int id, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgByPGNEx (KvaDbHnd dh, unsigned int id, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgByName (KvaDbHnd dh, const char *msg_name, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbGetMsgName (KvaDbMessageHnd mh, char *buf, size_t buflen)
 
KvaDbStatus kvaDbGetMsgQualifiedName (KvaDbMessageHnd mh, char *buf, size_t buflen)
 
KvaDbStatus kvaDbGetMsgComment (KvaDbMessageHnd mh, char *buf, size_t buflen)
 
KvaDbStatus kvaDbGetMsgId (KvaDbMessageHnd mh, unsigned int *id, unsigned int *flags)
 
KvaDbStatus kvaDbGetMsgIdEx (KvaDbMessageHnd mh, unsigned int *id)
 
KvaDbStatus kvaDbGetMsgFlags (KvaDbMessageHnd mh, unsigned int *flags)
 
KvaDbStatus kvaDbGetCanMsgFlags (KvaDbMessageHnd mh, unsigned int *flags)
 
KvaDbStatus kvaDbGetMsgDlc (KvaDbMessageHnd mh, int *dlc)
 
KvaDbStatus kvaDbGetMsgSendNode (KvaDbMessageHnd mh, KvaDbNodeHnd *nh)
 
KvaDbStatus kvaDbAddMsg (KvaDbHnd dh, KvaDbMessageHnd *mh)
 
KvaDbStatus kvaDbDeleteMsg (KvaDbHnd dh, KvaDbMessageHnd mh)
 
KvaDbStatus kvaDbSetMsgName (KvaDbMessageHnd mh, char *buf)
 
KvaDbStatus kvaDbSetMsgComment (KvaDbMessageHnd mh, char *buf)
 
KvaDbStatus kvaDbSetMsgId (KvaDbMessageHnd mh, unsigned int id, unsigned int flags)
 
KvaDbStatus kvaDbSetMsgIdEx (KvaDbMessageHnd mh, unsigned int id)
 
KvaDbStatus kvaDbSetMsgFlags (KvaDbMessageHnd mh, unsigned int flags)
 
KvaDbStatus kvaDbSetMsgDlc (KvaDbMessageHnd mh, int dlc)
 
KvaDbStatus kvaDbSetMsgSendNode (KvaDbMessageHnd mh, KvaDbNodeHnd nh)
 
KvaDbStatus kvaDbGetMsgMux (KvaDbMessageHnd mh, KvaDbSignalHnd *sh)
 
KvaDbStatus kvaDbMsgDlcToBytes (KvaDbProtocolType prot, unsigned int dlc, unsigned int *numBytes)
 
KvaDbStatus kvaDbBytesToMsgDlc (KvaDbProtocolType prot, unsigned int numBytes, unsigned int *dlc)
 

Detailed Description

Add, delete and modify messages.

Function Documentation

◆ kvaDbAddMsg()

KvaDbStatus kvaDbAddMsg ( KvaDbHnd  dh,
KvaDbMessageHnd mh 
)

Add a new message to a database.

Parameters
[in]dhA database handle
[out]mhA handle to the new message
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbDeleteMsg()
Examples:
example/c/candb_sample.c, and example/c/j1939_db.c.

◆ kvaDbBytesToMsgDlc()

KvaDbStatus kvaDbBytesToMsgDlc ( KvaDbProtocolType  prot,
unsigned int  numBytes,
unsigned int *  dlc 
)

Translates number of bytes to message dlc for a given protocol

Parameters
[in]protA protocol type
[in]numBytesNumber of bytes
[out]dlcRaw message dlc
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetProtocol()

◆ kvaDbDeleteMsg()

KvaDbStatus kvaDbDeleteMsg ( KvaDbHnd  dh,
KvaDbMessageHnd  mh 
)

Delete a message from a database.

Parameters
[in]dhA database handle
[in]mhA handle to the message that will be deleted
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbAddMsg()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetCanMsgFlags()

KvaDbStatus kvaDbGetCanMsgFlags ( KvaDbMessageHnd  mh,
unsigned int *  flags 
)

Get relevant message attributes expressed as CAN message flags, see canMSG_xxx and canFDMSG_xxx

Note that canFDMSG_BRS will never be returned for non-CAN FD frames, even though the CANFD_BRS attribute was set in the .dbc file.

Parameters
[in]mhA message handle
[out]flagsThe message flags, canMSG_xxx
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure

◆ kvaDbGetFirstMsg()

KvaDbStatus kvaDbGetFirstMsg ( KvaDbHnd  dh,
KvaDbMessageHnd mh 
)

Get the first message in a database.

Parameters
[in]dhA handle to a database
[out]mhA handle to the first message
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetNextMsg()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgById()

KvaDbStatus kvaDbGetMsgById ( KvaDbHnd  dh,
unsigned int  id,
KvaDbMessageHnd mh 
)

Get a handle to a message with a specific identifier. If the message requested has an extended id, the id should have the KVADB_MESSAGE_EXT flag set.

Parameters
[in]dhA database handle
[in]idThe selected message identifier
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgByName()
kvaDbGetMsgByIdEx()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgByIdEx()

KvaDbStatus kvaDbGetMsgByIdEx ( KvaDbHnd  dh,
unsigned int  id,
unsigned int  flags,
KvaDbMessageHnd mh 
)

Get a handle to a message with a specific identifier. If the requested message has an extended id, KVADB_MESSAGE_EXT should be set on the flags parameter. Bits 31..29 of the id are ignored.

Parameters
[in]dhA database handle
[in]idThe selected message identifier
[in]flagsThe flags, KVADB_MESSAGE_xxx
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgByName()

◆ kvaDbGetMsgByName()

KvaDbStatus kvaDbGetMsgByName ( KvaDbHnd  dh,
const char *  msg_name,
KvaDbMessageHnd mh 
)

Get a handle to a message with a specific name.

Parameters
[in]dhA databse handle
[in]msg_nameThe message name to search for
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgById()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgByPGN()

KvaDbStatus kvaDbGetMsgByPGN ( KvaDbHnd  dh,
unsigned int  id,
KvaDbMessageHnd mh 
)

Get a handle to a message with a specific PGN-identifier. If the message is marked as J1939, checks if the PGN-part is equal. The message identifier needs to contain the KVADB_MESSAGE_EXT flag.

Parameters
[in]dhA database handle
[in]idThe selected message identifier
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgByName()
kvaDbGetMsgByPGNEx()

◆ kvaDbGetMsgByPGNEx()

KvaDbStatus kvaDbGetMsgByPGNEx ( KvaDbHnd  dh,
unsigned int  id,
KvaDbMessageHnd mh 
)

Get a handle to a J1939 message using the PGN-identifier within the CAN id. All bits in the id that are not part of the PGN are ignored.

Parameters
[in]dhA database handle
[in]idThe selected message identifier
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgByName()

◆ kvaDbGetMsgComment()

KvaDbStatus kvaDbGetMsgComment ( KvaDbMessageHnd  mh,
char *  buf,
size_t  buflen 
)

Get the comment for a message as a null-terminated string. A truncated string will be returned if buf is too small and status will be kvaDbOK.

Parameters
[in]mhA message handle
[out]bufThe buffer that will hold the message comment
[in]buflenThe length of the buffer
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgComment()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgDlc()

KvaDbStatus kvaDbGetMsgDlc ( KvaDbMessageHnd  mh,
int *  dlc 
)

Get the data length code for a message.

Parameters
[in]mhA message handle
[out]dlcThe data length code
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgDlc()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgFlags()

KvaDbStatus kvaDbGetMsgFlags ( KvaDbMessageHnd  mh,
unsigned int *  flags 
)

Get the message flags, KVADB_MESSAGE_xxx

Parameters
[in]mhA message handle
[out]flagsThe message flags, KVADB_MESSAGE_xxx
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgFlags()

◆ kvaDbGetMsgId()

KvaDbStatus kvaDbGetMsgId ( KvaDbMessageHnd  mh,
unsigned int *  id,
unsigned int *  flags 
)

Get message identifier and flags. If message is of extended CAN format, its id will contain KVADB_MESSAGE_EXT flag. This call is deprecated. Consider using kvaDbGetMsgIdEx() and kvaDbGetMsgFlags() instead.

Parameters
[in]mhA message handle.
[out]idThe identifier.
[out]flagsThe flags, KVADB_MESSAGE_xxx
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgId()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgIdEx()

KvaDbStatus kvaDbGetMsgIdEx ( KvaDbMessageHnd  mh,
unsigned int *  id 
)

Get the message identifier. The message identifier will not contain any flags.

Parameters
[in]mhA message handle
[out]idThe message identifier
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgIdEx()

◆ kvaDbGetMsgMux()

KvaDbStatus kvaDbGetMsgMux ( KvaDbMessageHnd  mh,
KvaDbSignalHnd sh 
)

Returns handle to a multiplexer signal of a given message. If there are no multiplexer signal, KvaDbOk will be returned and *sh will be NULL.

Parameters
[in]mhA message handle
[out]shMultiplexer signal handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure

◆ kvaDbGetMsgName()

KvaDbStatus kvaDbGetMsgName ( KvaDbMessageHnd  mh,
char *  buf,
size_t  buflen 
)

Get the name of a message as a null-terminated string. A truncated string will be returned if buf is too small and status will be kvaDbOK.

Parameters
[in]mhA message handle
[out]bufThe buffer that will hold the message name
[in]buflenThe length of the buffer.
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgName(), kvaDbGetMsgQualifiedName()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgQualifiedName()

KvaDbStatus kvaDbGetMsgQualifiedName ( KvaDbMessageHnd  mh,
char *  buf,
size_t  buflen 
)

Get the qualified message name, which is the database name and the message name separated by a dot, as a null-terminated string. An empty string will be returned if buf is too small and status will be kvaDbOK.

Parameters
[in]mhA message handle
[out]bufThe buffer that will hold the qualified message name
[in]buflenThe length of the buffer
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgName()
Examples:
example/c/candb_sample.c.

◆ kvaDbGetMsgSendNode()

KvaDbStatus kvaDbGetMsgSendNode ( KvaDbMessageHnd  mh,
KvaDbNodeHnd nh 
)

Get send node for a message

Parameters
[in]mhA message handle
[out]nhA node handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbSetMsgSendNode()

◆ kvaDbGetNextMsg()

KvaDbStatus kvaDbGetNextMsg ( KvaDbHnd  dh,
KvaDbMessageHnd mh 
)

Get a handle to the next message in a database. Should be called after kvaDbGetFirstMsg().

Parameters
[in]dhA database handle
[out]mhA message handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetFirstMsg()
Examples:
example/c/candb_sample.c.

◆ kvaDbMsgDlcToBytes()

KvaDbStatus kvaDbMsgDlcToBytes ( KvaDbProtocolType  prot,
unsigned int  dlc,
unsigned int *  numBytes 
)

Translates message dlc to number of bytes for a given protocol

Parameters
[in]protA protocol type
[in]dlcRaw message dlc
[out]numBytesNumber of bytes
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetProtocol()

◆ kvaDbSetMsgComment()

KvaDbStatus kvaDbSetMsgComment ( KvaDbMessageHnd  mh,
char *  buf 
)

Set the message comment.

Parameters
[in]mhA message handle
[in]bufThe buffer that contains the message comment
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgComment()
Examples:
example/c/candb_sample.c.

◆ kvaDbSetMsgDlc()

KvaDbStatus kvaDbSetMsgDlc ( KvaDbMessageHnd  mh,
int  dlc 
)

Set the data length code for a message.

Parameters
[in]mhA message handle
[in]dlcThe data length code
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgDlc()
Examples:
example/c/candb_sample.c, and example/c/j1939_db.c.

◆ kvaDbSetMsgFlags()

KvaDbStatus kvaDbSetMsgFlags ( KvaDbMessageHnd  mh,
unsigned int  flags 
)

Set the message flags, KVADB_MESSAGE_xxx

Parameters
[in]mhA message handle
[in]flagsThe message flags, KVADB_MESSAGE_xxx
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgFlags()
Examples:
example/c/j1939_db.c.

◆ kvaDbSetMsgId()

KvaDbStatus kvaDbSetMsgId ( KvaDbMessageHnd  mh,
unsigned int  id,
unsigned int  flags 
)

Set the message identifier and flags. If message is of extended CAN format, its id should contain KVADB_MESSAGE_EXT flag. This call is deprecated, consider using kvaDbSetMsgIdEx() and kvaDbSetMsgFlags() instead.

Parameters
[in]mhA message handle
[in]idThe message identifier
[in]flagsThe message flags, KVADB_MESSAGE_xxx
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgId()
Examples:
example/c/candb_sample.c.

◆ kvaDbSetMsgIdEx()

KvaDbStatus kvaDbSetMsgIdEx ( KvaDbMessageHnd  mh,
unsigned int  id 
)

Set the message identifier. The message identifier should not contain any flags.

Parameters
[in]mhA message handle
[in]idThe message identifier
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgIdEx()
Examples:
example/c/j1939_db.c.

◆ kvaDbSetMsgName()

KvaDbStatus kvaDbSetMsgName ( KvaDbMessageHnd  mh,
char *  buf 
)

Set the message name.

Parameters
[in]mhA message handle
[in]bufThe buffer that contains the message name.
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
Note
Please note that allowed characters in identiers are digits, letters and "_" (underscore).
Identifiers shall also start with a letter or underscore.
See also
kvaDbGetMsgName()
Examples:
example/c/candb_sample.c, and example/c/j1939_db.c.

◆ kvaDbSetMsgSendNode()

KvaDbStatus kvaDbSetMsgSendNode ( KvaDbMessageHnd  mh,
KvaDbNodeHnd  nh 
)

Set send node for a message

Parameters
[in]mhA message handle
[in]nhA node handle
Returns
kvaDbOK (zero) if success
kvaDbErr_xxx (negative) if failure
See also
kvaDbGetMsgSendNode()