Lely core libraries  2.2.5
wtm.h File Reference

This header file is part of the CANopen library; it contains the Wireless Transmission Media (WTM) declarations. More...

#include <lely/can/msg.h>
#include <lely/co/co.h>
#include <lely/libc/time.h>
Include dependency graph for wtm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CO_WTM_MAX_LEN   261
 The maximum size of a CANopen WTM generic frame (4 (header) + 255 (payload) + 2 (CRC checksum) = 261).
 
#define CO_WTM_AC_ERROR   UINT32_C(0x01000000)
 CANopen WTM abort code: General error.
 
#define CO_WTM_AC_TIMEOUT   UINT32_C(0x01000001)
 CANopen WTM abort code: Diagnostic protocol timed out limit reached.
 
#define CO_WTM_AC_NO_MEM   UINT32_C(0x01000002)
 CANopen WTM abort code: Out of memory.
 
#define CO_WTM_AC_HARDWARE   UINT32_C(0x01000003)
 CANopen WTM abort code: Access failed due to a hardware error.
 
#define CO_WTM_AC_DATA   UINT32_C(0x01000004)
 CANopen WTM abort code: Data cannot be transferred or stored to the application.
 
#define CO_WTM_AC_DATA_CTL   UINT32_C(0x01000005)
 CANopen WTM abort code: Data cannot be transferred or stored to the application because of local control.
 
#define CO_WTM_AC_DATA_DEV   UINT32_C(0x01000006)
 CANopen WTM abort code: Data cannot be transferred or stored to the application because of the present device state.
 
#define CO_WTM_AC_NO_DATA   UINT32_C(0x01000007)
 CANopen WTM abort code: No data available.
 
#define CO_WTM_AC_NO_IF   UINT32_C(0x01000008)
 CANopen WTM abort code: Requested interface not implemented.
 
#define CO_WTM_AC_IF_DOWN   UINT32_C(0x01000009)
 CANopen WTM abort code: Requested interface disabled.
 
#define CO_WTM_AC_DIAG   UINT32_C(0x0100000a)
 CANopen WTM abort code: Diagnostic data generation not supported.
 
#define CO_WTM_AC_DIAG_CAN   UINT32_C(0x0100000b)
 CANopen WTM abort code: Diagnostic data generation for requested CAN interface not supported.
 
#define CO_WTM_AC_DIAG_WTM   UINT32_C(0x0100000c)
 CANopen WTM abort code: Diagnostic data generation for requested WTM interface not supported.
 
#define CO_WTM_AC_FRAME   UINT32_C(0x02000000)
 CANopen WTM abort code: General generic frame error.
 
#define CO_WTM_AC_PREAMBLE   UINT32_C(0x02000001)
 CANopen WTM abort code: Invalid generic frame preamble.
 
#define CO_WTM_AC_SEQ   UINT32_C(0x02000002)
 CANopen WTM abort code: Invalid sequence counter in generic frame.
 
#define CO_WTM_AC_TYPE   UINT32_C(0x02000003)
 CANopen WTM abort code: Message type not valid or unknown.
 
#define CO_WTM_AC_PAYLOAD   UINT32_C(0x02000004)
 CANopen WTM abort code: Payload field in generic frame invalid.
 
#define CO_WTM_AC_CRC   UINT32_C(0x02000005)
 CANopen WTM abort code: CRC error (Generic frame).
 
#define CO_WTM_AC_CAN   UINT32_C(0x02000006)
 CANopen WTM abort code: CAN telegram essentials invalid.
 

Typedefs

typedef struct __co_wtm co_wtm_t
 An opaque CANopen Wireless Transmission Media (WTM) interface type.
 
typedef void co_wtm_diag_can_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st, uint_least8_t err, uint_least8_t load, uint_least16_t ec, uint_least16_t foc, uint_least16_t coc, void *data)
 The type of a CANopen WTM diagnostic confirmation function, invoked when a CAN communication quality response is received. More...
 
typedef void co_wtm_diag_wtm_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t quality, void *data)
 The type of a CANopen WTM diagnostic confirmation function, invoked when a WTM communication quality response is received. More...
 
typedef void co_wtm_diag_can_ind_t(co_wtm_t *wtm, uint_least8_t nif, void *data)
 The type of a CANopen WTM diagnostic indication function, invoked when a CAN communication quality reset message is received. More...
 
typedef void co_wtm_diag_wtm_ind_t(co_wtm_t *wtm, void *data)
 The type of a CANopen WTM diagnostic indication function, invoked when a WTM communication quality reset message is received. More...
 
typedef void co_wtm_diag_ac_ind_t(co_wtm_t *wtm, uint_least32_t ac, void *data)
 The type of a CANopen WTM diagnostic indication function, invoked when an abort code is generated or received. More...
 
typedef int co_wtm_recv_func_t(co_wtm_t *wtm, uint_least8_t nif, const struct timespec *tp, const struct can_msg *msg, void *data)
 The type of a CANopen WTM receive callback function, invoked when a CAN frame is received. More...
 
typedef int co_wtm_send_func_t(co_wtm_t *wtm, const void *buf, size_t nbytes, void *data)
 The type of a CANopen WTM send callback function, invoked when a byte stream needs to be sent. More...
 

Functions

const char * co_wtm_ac_str (uint_least32_t ac)
 Returns a string describing a CANopen WTM abort code.
 
co_wtm_tco_wtm_create (void)
 Creates a new CANopen Wireless Transmission Media (WTM) interface. More...
 
void co_wtm_destroy (co_wtm_t *wtm)
 Destroys a CANopen Wireless Transmission Media (WTM) interface. More...
 
uint_least8_t co_wtm_get_nif (const co_wtm_t *wtm)
 Returns the interface indicator of a CANopen WTM interface. More...
 
int co_wtm_set_nif (co_wtm_t *wtm, uint_least8_t nif)
 Sets the interface indicator of a CANopen WTM interface. More...
 
int co_wtm_set_diag_can (co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st, uint_least8_t err, uint_least8_t load, uint_least16_t ec, uint_least16_t foc, uint_least16_t coc)
 Sets the diagnostic parameters of a CAN interface. More...
 
int co_wtm_set_diag_wtm (co_wtm_t *wtm, uint_least8_t quality)
 Sets the diagnostic parameters of a WTM interface. More...
 
void co_wtm_get_diag_can_con (const co_wtm_t *wtm, co_wtm_diag_can_con_t **pcon, void **pdata)
 Retrieves the confirmation function invoked when a CAN communication quality response is received by a CANopen WTM interface. More...
 
void co_wtm_set_diag_can_con (co_wtm_t *wtm, co_wtm_diag_can_con_t *con, void *data)
 Sets the confirmation function invoked when a CAN communication quality response is received by a CANopen WTM interface. More...
 
void co_wtm_get_diag_wtm_con (const co_wtm_t *wtm, co_wtm_diag_wtm_con_t **pcon, void **pdata)
 Retrieves the confirmation function invoked when a WTM communication quality response is received by a CANopen WTM interface. More...
 
void co_wtm_set_diag_wtm_con (co_wtm_t *wtm, co_wtm_diag_wtm_con_t *con, void *data)
 Sets the confirmation function invoked when a WTM communication quality response is received by a CANopen WTM interface. More...
 
void co_wtm_get_diag_can_ind (const co_wtm_t *wtm, co_wtm_diag_can_ind_t **pcon, void **pdata)
 Retrieves the indication function invoked when a CAN communication quality reset message is received by a CANopen WTM interface. More...
 
void co_wtm_set_diag_can_ind (co_wtm_t *wtm, co_wtm_diag_can_ind_t *con, void *data)
 Sets the indication function invoked when a CAN communication quality reset message is received by a CANopen WTM interface. More...
 
void co_wtm_get_diag_wtm_ind (const co_wtm_t *wtm, co_wtm_diag_wtm_ind_t **pcon, void **pdata)
 Retrieves the indication function invoked when a WTM communication quality reset message is received by a CANopen WTM interface. More...
 
void co_wtm_set_diag_wtm_ind (co_wtm_t *wtm, co_wtm_diag_wtm_ind_t *con, void *data)
 Sets the indication function invoked when a WTM communication quality reset message is received by a CANopen WTM interface. More...
 
void co_wtm_get_diag_ac_ind (const co_wtm_t *wtm, co_wtm_diag_ac_ind_t **pind, void **pdata)
 Retrieves the indication function invoked when an abort code is generated or received by a CANopen WTM interface. More...
 
void co_wtm_set_diag_ac_ind (co_wtm_t *wtm, co_wtm_diag_ac_ind_t *ind, void *data)
 Sets the indication function invoked when an abort code is generated or received by a CANopen WTM interface. More...
 
void co_wtm_recv (co_wtm_t *wtm, const void *buf, size_t nbytes)
 Receives and processes a byte stream with a CANopen WTM interface. More...
 
void co_wtm_get_recv_func (const co_wtm_t *wtm, co_wtm_recv_func_t **pfunc, void **pdata)
 Retrieves the callback function invoked when a CAN frame is received by a CANopen WTM interface. More...
 
void co_wtm_set_recv_func (co_wtm_t *wtm, co_wtm_recv_func_t *func, void *data)
 Sets the callback function invoked when a CAN frame is received by a CANopen WTM interface. More...
 
int co_wtm_get_time (const co_wtm_t *wtm, uint_least8_t nif, struct timespec *tp)
 Retrieves the current time of a CANopen WTM interface. More...
 
int co_wtm_set_time (co_wtm_t *wtm, uint_least8_t nif, const struct timespec *tp)
 Sets the current time of a CANopen WTM interface. More...
 
int co_wtm_send (co_wtm_t *wtm, uint_least8_t nif, const struct can_msg *msg)
 Sends a CAN frame from a CANopen WTM interface. More...
 
int co_wtm_send_alive (co_wtm_t *wtm)
 Sends a keep-alive message from a CANopen WTM interface. More...
 
int co_wtm_send_diag_can_req (co_wtm_t *wtm, uint_least8_t nif)
 Sends a CAN communication quality request. More...
 
int co_wtm_send_diag_wtm_req (co_wtm_t *wtm, uint_least8_t nif)
 Sends a WTM communication quality request. More...
 
int co_wtm_send_diag_can_rst (co_wtm_t *wtm, uint_least8_t nif)
 Sends a CAN communication quality reset message. More...
 
int co_wtm_send_diag_wtm_rst (co_wtm_t *wtm, uint_least8_t nif)
 Sends a WTM communication quality reset message. More...
 
int co_wtm_send_diag_ac (co_wtm_t *wtm, uint_least32_t ac)
 Sends a diagnostic abort message from a CANopen WTM interface. More...
 
int co_wtm_flush (co_wtm_t *wtm)
 Flushes the current send buffer of a CANopen WTM interface. More...
 
void co_wtm_get_send_func (const co_wtm_t *wtm, co_wtm_send_func_t **pfunc, void **pdata)
 Retrieves the callback function used to send byte streams from a CANopen WTM interface. More...
 
void co_wtm_set_send_func (co_wtm_t *wtm, co_wtm_send_func_t *func, void *data)
 Sets the callback function used to send byte streams from a CANopen WTM interface. More...
 

Detailed Description

This header file is part of the CANopen library; it contains the Wireless Transmission Media (WTM) declarations.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file wtm.h.

Typedef Documentation

◆ co_wtm_diag_can_con_t

typedef void co_wtm_diag_can_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t st, uint_least8_t err, uint_least8_t load, uint_least16_t ec, uint_least16_t foc, uint_least16_t coc, void *data)

The type of a CANopen WTM diagnostic confirmation function, invoked when a CAN communication quality response is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote CAN interface indicator (in the range [1..127]).
stThe current CAN controller status (one of CAN_STATE_ACTIVE, CAN_STATE_PASSIVE or CAN_STATE_BUSOFF, or 0xf if the information is not available).
errthe last detected error (0 if no error was detected, one of CAN_ERROR_BIT, CAN_ERROR_STUFF, CAN_ERROR_CRC, CAN_ERROR_FORM or CAN_ERROR_ACK in case of an error, or 0xf if the information is not available).
loadthe current busload percentage (in the range [0..100], or 0xff if the information is not available).
ecthe number of detected errors that led to the increase of one of the CAN controller internal error counters (in the range [0..0xfffe], or 0xffff if the information is not available).
focthe FIFO overrun counter (in the range [0..0xfffe], or 0xffff if the information is not available).
cocthe CAN controller overrun counter (in the range [0..0xfffe], or 0xffff if the information is not available).
dataa pointer to user-specified data.

Definition at line 144 of file wtm.h.

◆ co_wtm_diag_wtm_con_t

typedef void co_wtm_diag_wtm_con_t(co_wtm_t *wtm, uint_least8_t nif, uint_least8_t quality, void *data)

The type of a CANopen WTM diagnostic confirmation function, invoked when a WTM communication quality response is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote WTM interface indicator (in the range [1..127]).
qualitythe link quality percentage (in the range [0..100], or 0xff if the information is not available).
dataa pointer to user-specified data.

Definition at line 159 of file wtm.h.

◆ co_wtm_diag_can_ind_t

typedef void co_wtm_diag_can_ind_t(co_wtm_t *wtm, uint_least8_t nif, void *data)

The type of a CANopen WTM diagnostic indication function, invoked when a CAN communication quality reset message is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote CAN interface indicator (in the range [1..127]).
dataa pointer to user-specified data.

Definition at line 170 of file wtm.h.

◆ co_wtm_diag_wtm_ind_t

typedef void co_wtm_diag_wtm_ind_t(co_wtm_t *wtm, void *data)

The type of a CANopen WTM diagnostic indication function, invoked when a WTM communication quality reset message is received.

Parameters
wtma pointer to a CANopen WTM interface.
dataa pointer to user-specified data.

Definition at line 180 of file wtm.h.

◆ co_wtm_diag_ac_ind_t

typedef void co_wtm_diag_ac_ind_t(co_wtm_t *wtm, uint_least32_t ac, void *data)

The type of a CANopen WTM diagnostic indication function, invoked when an abort code is generated or received.

Parameters
wtma pointer to a CANopen WTM interface.
acthe abort code.
dataa pointer to user-specified data.

Definition at line 190 of file wtm.h.

◆ co_wtm_recv_func_t

typedef int co_wtm_recv_func_t(co_wtm_t *wtm, uint_least8_t nif, const struct timespec *tp, const struct can_msg *msg, void *data)

The type of a CANopen WTM receive callback function, invoked when a CAN frame is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe CAN interface indicator (in the range [1..127]).
tpa pointer to the (relative) time at which the CAN frame was received (can be NULL).
msga pointer to the received CAN frame.
dataa pointer to user-specified data.
Returns
0 on success, or -1 on error. In the latter case, implementations SHOULD set the error number with set_errnum().

Definition at line 206 of file wtm.h.

◆ co_wtm_send_func_t

typedef int co_wtm_send_func_t(co_wtm_t *wtm, const void *buf, size_t nbytes, void *data)

The type of a CANopen WTM send callback function, invoked when a byte stream needs to be sent.

Parameters
wtma pointer to a CANopen WTM interface.
bufa pointer to the bytes to be sent.
nbytesthe number of bytes to send.
dataa pointer to user-specified data.
Returns
0 on success, or -1 on error. In the latter case, implementations SHOULD set the error number with set_errnum().

Definition at line 222 of file wtm.h.

Function Documentation

◆ co_wtm_create()

co_wtm_t* co_wtm_create ( void  )

Creates a new CANopen Wireless Transmission Media (WTM) interface.

Returns
a pointer to a new WTM interface, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_wtm_destroy()

Definition at line 290 of file wtm.c.

◆ co_wtm_destroy()

void co_wtm_destroy ( co_wtm_t wtm)

Destroys a CANopen Wireless Transmission Media (WTM) interface.

See also
co_wtm_create()

Definition at line 315 of file wtm.c.

◆ co_wtm_get_nif()

uint_least8_t co_wtm_get_nif ( const co_wtm_t wtm)

Returns the interface indicator of a CANopen WTM interface.

See also
co_wtm_set_nif()

Definition at line 324 of file wtm.c.

◆ co_wtm_set_nif()

int co_wtm_set_nif ( co_wtm_t wtm,
uint_least8_t  nif 
)

Sets the interface indicator of a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe WTM interface indicator (in the range [1..127]).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_wtm_get_nif()

Definition at line 332 of file wtm.c.

◆ co_wtm_set_diag_can()

int co_wtm_set_diag_can ( co_wtm_t wtm,
uint_least8_t  nif,
uint_least8_t  st,
uint_least8_t  err,
uint_least8_t  load,
uint_least16_t  ec,
uint_least16_t  foc,
uint_least16_t  coc 
)

Sets the diagnostic parameters of a CAN interface.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe local CAN interface indicator (in the range [1..127]).
stThe current CAN controller status (one of CAN_STATE_ACTIVE, CAN_STATE_PASSIVE or CAN_STATE_BUSOFF, or 0xf if the information is not available).
errthe last detected error (0 if no error was detected, one of CAN_ERROR_BIT, CAN_ERROR_STUFF, CAN_ERROR_CRC, CAN_ERROR_FORM or CAN_ERROR_ACK in case of an error, or 0xf if the information is not available).
loadthe current busload percentage (in the range [0..100], or 0xff if the information is not available).
ecthe number of detected errors that led to the increase of one of the CAN controller internal error counters (in the range [0..0xfffe], or 0xffff if the information is not available).
focthe FIFO overrun counter (in the range [0..0xfffe], or 0xffff if the information is not available).
cocthe CAN controller overrun counter (in the range [0..0xfffe], or 0xffff if the information is not available).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 347 of file wtm.c.

◆ co_wtm_set_diag_wtm()

int co_wtm_set_diag_wtm ( co_wtm_t wtm,
uint_least8_t  quality 
)

Sets the diagnostic parameters of a WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
qualitythe link quality percentage (in the range [0..100], or 0xff if the information is not available).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 398 of file wtm.c.

◆ co_wtm_get_diag_can_con()

void co_wtm_get_diag_can_con ( const co_wtm_t wtm,
co_wtm_diag_can_con_t **  pcon,
void **  pdata 
)

Retrieves the confirmation function invoked when a CAN communication quality response is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pconthe address at which to store a pointer to the confirmation function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_diag_can_con()

Definition at line 413 of file wtm.c.

◆ co_wtm_set_diag_can_con()

void co_wtm_set_diag_can_con ( co_wtm_t wtm,
co_wtm_diag_can_con_t con,
void *  data 
)

Sets the confirmation function invoked when a CAN communication quality response is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
cona pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to con.
See also
co_wtm_get_diag_can_con()

Definition at line 425 of file wtm.c.

◆ co_wtm_get_diag_wtm_con()

void co_wtm_get_diag_wtm_con ( const co_wtm_t wtm,
co_wtm_diag_wtm_con_t **  pcon,
void **  pdata 
)

Retrieves the confirmation function invoked when a WTM communication quality response is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pconthe address at which to store a pointer to the confirmation function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_diag_wtm_con()

Definition at line 434 of file wtm.c.

◆ co_wtm_set_diag_wtm_con()

void co_wtm_set_diag_wtm_con ( co_wtm_t wtm,
co_wtm_diag_wtm_con_t con,
void *  data 
)

Sets the confirmation function invoked when a WTM communication quality response is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
cona pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to con.
See also
co_wtm_get_diag_wtm_con()

Definition at line 446 of file wtm.c.

◆ co_wtm_get_diag_can_ind()

void co_wtm_get_diag_can_ind ( const co_wtm_t wtm,
co_wtm_diag_can_ind_t **  pcon,
void **  pdata 
)

Retrieves the indication function invoked when a CAN communication quality reset message is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pconthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_diag_can_ind()

Definition at line 455 of file wtm.c.

◆ co_wtm_set_diag_can_ind()

void co_wtm_set_diag_can_ind ( co_wtm_t wtm,
co_wtm_diag_can_ind_t con,
void *  data 
)

Sets the indication function invoked when a CAN communication quality reset message is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
cona pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to con.
See also
co_wtm_get_diag_can_ind()

Definition at line 467 of file wtm.c.

◆ co_wtm_get_diag_wtm_ind()

void co_wtm_get_diag_wtm_ind ( const co_wtm_t wtm,
co_wtm_diag_wtm_ind_t **  pcon,
void **  pdata 
)

Retrieves the indication function invoked when a WTM communication quality reset message is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pconthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_diag_wtm_ind()

Definition at line 476 of file wtm.c.

◆ co_wtm_set_diag_wtm_ind()

void co_wtm_set_diag_wtm_ind ( co_wtm_t wtm,
co_wtm_diag_wtm_ind_t con,
void *  data 
)

Sets the indication function invoked when a WTM communication quality reset message is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
cona pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to con.
See also
co_wtm_get_diag_wtm_ind()

Definition at line 488 of file wtm.c.

◆ co_wtm_get_diag_ac_ind()

void co_wtm_get_diag_ac_ind ( const co_wtm_t wtm,
co_wtm_diag_ac_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked when an abort code is generated or received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pindthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_diag_ac_ind()

Definition at line 497 of file wtm.c.

◆ co_wtm_set_diag_ac_ind()

void co_wtm_set_diag_ac_ind ( co_wtm_t wtm,
co_wtm_diag_ac_ind_t ind,
void *  data 
)

Sets the indication function invoked when an abort code is generated or received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
inda pointer to the function to be invoked. If ind is NULL, the default indication function will be used (which invokes diag()).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to ind.
See also
co_wtm_get_diag_ac_ind()

Definition at line 509 of file wtm.c.

◆ co_wtm_recv()

void co_wtm_recv ( co_wtm_t wtm,
const void *  buf,
size_t  nbytes 
)

Receives and processes a byte stream with a CANopen WTM interface.

This function MAY invoke the callback function specified to co_wtm_set_recv_func() 0 or more times.

Parameters
wtma pointer to a CANopen WTM interface.
bufa pointer to the bytes to be processed.
nbytesthe number of bytes received.

Definition at line 518 of file wtm.c.

◆ co_wtm_get_recv_func()

void co_wtm_get_recv_func ( const co_wtm_t wtm,
co_wtm_recv_func_t **  pfunc,
void **  pdata 
)

Retrieves the callback function invoked when a CAN frame is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pfuncthe address at which to store a pointer to the callback function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_recv_func()

Definition at line 769 of file wtm.c.

◆ co_wtm_set_recv_func()

void co_wtm_set_recv_func ( co_wtm_t wtm,
co_wtm_recv_func_t func,
void *  data 
)

Sets the callback function invoked when a CAN frame is received by a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
funca pointer to the function to be invoked by co_wtm_recv().
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_wtm_get_recv_func()

Definition at line 781 of file wtm.c.

◆ co_wtm_get_time()

int co_wtm_get_time ( const co_wtm_t wtm,
uint_least8_t  nif,
struct timespec *  tp 
)

Retrieves the current time of a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe CAN interface indicator (in the range [1..127]).
tpthe address at which to store the current time (can be NULL).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_wtm_set_time()

Definition at line 790 of file wtm.c.

◆ co_wtm_set_time()

int co_wtm_set_time ( co_wtm_t wtm,
uint_least8_t  nif,
const struct timespec *  tp 
)

Sets the current time of a CANopen WTM interface.

This function MAY invoke the callback function set by co_wtm_set_send_func().

Parameters
wtma pointer to a CANopen WTM interface.
nifthe CAN interface indicator (in the range [1..127]).
tpa pointer to the current time.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_wtm_get_time()

Definition at line 806 of file wtm.c.

◆ co_wtm_send()

int co_wtm_send ( co_wtm_t wtm,
uint_least8_t  nif,
const struct can_msg msg 
)

Sends a CAN frame from a CANopen WTM interface.

This function MAY invoke the callback function set by co_wtm_set_send_func(). Note that no generic frames are sent until the send buffer is full. Sending a generic frame can be forced with co_wtm_flush().

Parameters
wtma pointer to a CANopen WTM interface.
nifthe CAN interface indicator (in the range [1..127]).
msga pointer to the CAN frame to be sent.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 840 of file wtm.c.

◆ co_wtm_send_alive()

int co_wtm_send_alive ( co_wtm_t wtm)

Sends a keep-alive message from a CANopen WTM interface.

This function MAY invoke the callback function set by co_wtm_set_send_func().

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 922 of file wtm.c.

◆ co_wtm_send_diag_can_req()

int co_wtm_send_diag_can_req ( co_wtm_t wtm,
uint_least8_t  nif 
)

Sends a CAN communication quality request.

The function specified to co_wtm_set_diag_can_con() is invoked if a response is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote CAN interface indicator (in the range [1..127]).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 936 of file wtm.c.

◆ co_wtm_send_diag_wtm_req()

int co_wtm_send_diag_wtm_req ( co_wtm_t wtm,
uint_least8_t  nif 
)

Sends a WTM communication quality request.

The function specified to co_wtm_set_diag_wtm_con() is invoked if a response is received.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote WTM interface indicator (in the range [1..127]).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 954 of file wtm.c.

◆ co_wtm_send_diag_can_rst()

int co_wtm_send_diag_can_rst ( co_wtm_t wtm,
uint_least8_t  nif 
)

Sends a CAN communication quality reset message.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote CAN interface indicator (in the range [1..127]).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 972 of file wtm.c.

◆ co_wtm_send_diag_wtm_rst()

int co_wtm_send_diag_wtm_rst ( co_wtm_t wtm,
uint_least8_t  nif 
)

Sends a WTM communication quality reset message.

Parameters
wtma pointer to a CANopen WTM interface.
nifthe remote WTM interface indicator (in the range [1..127]).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 990 of file wtm.c.

◆ co_wtm_send_diag_ac()

int co_wtm_send_diag_ac ( co_wtm_t wtm,
uint_least32_t  ac 
)

Sends a diagnostic abort message from a CANopen WTM interface.

This function MAY invoke the callback function set by co_wtm_set_send_func().

Parameters
wtma pointer to a CANopen WTM interface.
acthe abort code.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 1008 of file wtm.c.

◆ co_wtm_flush()

int co_wtm_flush ( co_wtm_t wtm)

Flushes the current send buffer of a CANopen WTM interface.

This function MAY invoke the callback function set by co_wtm_set_send_func().

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 1023 of file wtm.c.

◆ co_wtm_get_send_func()

void co_wtm_get_send_func ( const co_wtm_t wtm,
co_wtm_send_func_t **  pfunc,
void **  pdata 
)

Retrieves the callback function used to send byte streams from a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
pfuncthe address at which to store a pointer to the callback function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_wtm_set_send_func()

Definition at line 1053 of file wtm.c.

◆ co_wtm_set_send_func()

void co_wtm_set_send_func ( co_wtm_t wtm,
co_wtm_send_func_t func,
void *  data 
)

Sets the callback function used to send byte streams from a CANopen WTM interface.

Parameters
wtma pointer to a CANopen WTM interface.
funca pointer to the function to be invoked by co_wtm_send().
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_wtm_get_send_func()

Definition at line 1065 of file wtm.c.