Lely core libraries 2.3.4
gw_txt.h File Reference

This header file is part of the CANopen library; it contains the ASCII gateway declarations (see CiA 309-3 version 2.1). More...

#include <lely/co/gw.h>
Include dependency graph for gw_txt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CO_GW_TXT_IMPL_HI   2
 The high number of the version of CiA 309-3 implemented by this gateway.
 
#define CO_GW_TXT_IMPL_LO   1
 The low number of the version of CiA 309-3 implemented by this gateway.
 

Typedefs

typedef struct __co_gw_txt co_gw_txt_t
 An opaque CANopen ASCII gateway type.
 
typedef int co_gw_txt_recv_func_t(const char *txt, void *data)
 The type of a CANopen ASCII gateway receive callback function, invoked when when an indication of conformation is received from a gateway and needs to be sent to the user. More...
 
typedef int co_gw_txt_send_func_t(const struct co_gw_req *req, void *data)
 The type of a CANopen ASCII gateway send callback function, invoked when a request has been issued by the user and needs to be sent to a gateway. More...
 

Functions

co_gw_txt_tco_gw_txt_create (void)
 Creates a new CANopen ASCII gateway. More...
 
void co_gw_txt_destroy (co_gw_txt_t *gw)
 Destroys a CANopen ASCII gateway. More...
 
int co_gw_txt_iec (co_gw_txt_t *gw)
 Returns (and clears) the last internal error code.
 
size_t co_gw_txt_pending (const co_gw_txt_t *gw)
 Returns the number of pending (i.e., unconfirmed) requests.
 
int co_gw_txt_recv (co_gw_txt_t *gw, const struct co_gw_srv *srv)
 Receives and forwards an indication or confirmation from a CANopen gateway. More...
 
void co_gw_txt_get_recv_func (const co_gw_txt_t *gw, co_gw_txt_recv_func_t **pfunc, void **pdata)
 Retrieves the callback function used to forward indications and confirmations received by a CANopen gateway to the user. More...
 
void co_gw_txt_set_recv_func (co_gw_txt_t *gw, co_gw_txt_recv_func_t *func, void *data)
 Sets the callback function used to forward indications and confirmations received by a CANopen gateway to the user. More...
 
size_t co_gw_txt_send (co_gw_txt_t *gw, const char *begin, const char *end, struct floc *at)
 Sends a user request to a CANopen gateway. More...
 
void co_gw_txt_get_send_func (const co_gw_txt_t *gw, co_gw_txt_send_func_t **pfunc, void **pdata)
 Retrieves the callback function used to send requests from the user to a CANopen gateway. More...
 
void co_gw_txt_set_send_func (co_gw_txt_t *gw, co_gw_txt_send_func_t *func, void *data)
 Sets the callback function used to send requests from the user to a CANopen gateway. More...
 

Detailed Description

This header file is part of the CANopen library; it contains the ASCII gateway declarations (see CiA 309-3 version 2.1).

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 gw_txt.h.

Typedef Documentation

◆ co_gw_txt_recv_func_t

typedef int co_gw_txt_recv_func_t(const char *txt, void *data)

The type of a CANopen ASCII gateway receive callback function, invoked when when an indication of conformation is received from a gateway and needs to be sent to the user.

Parameters
txta pointer to a human-readable string containing the indication or confirmation.
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 58 of file gw_txt.h.

◆ co_gw_txt_send_func_t

typedef int co_gw_txt_send_func_t(const struct co_gw_req *req, void *data)

The type of a CANopen ASCII gateway send callback function, invoked when a request has been issued by the user and needs to be sent to a gateway.

Parameters
reqa pointer to the parameters of the request to be sent.
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 70 of file gw_txt.h.

Function Documentation

◆ co_gw_txt_create()

co_gw_txt_t * co_gw_txt_create ( void  )

Creates a new CANopen ASCII gateway.

See also
co_gw_txt_destroy()

Definition at line 337 of file gw_txt.c.

◆ co_gw_txt_destroy()

void co_gw_txt_destroy ( co_gw_txt_t gw)

Destroys a CANopen ASCII gateway.

See also
co_gw_txt_create()

Definition at line 362 of file gw_txt.c.

◆ co_gw_txt_recv()

int co_gw_txt_recv ( co_gw_txt_t gw,
const struct co_gw_srv srv 
)

Receives and forwards an indication or confirmation from a CANopen gateway.

Parameters
gwa pointer to a CANopen ASCII gateway.
srva pointer to the service parameters.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 389 of file gw_txt.c.

◆ co_gw_txt_get_recv_func()

void co_gw_txt_get_recv_func ( const co_gw_txt_t gw,
co_gw_txt_recv_func_t **  pfunc,
void **  pdata 
)

Retrieves the callback function used to forward indications and confirmations received by a CANopen gateway to the user.

Parameters
gwa pointer to a CANopen ASCII gateway.
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_gw_txt_set_recv_func()

Definition at line 486 of file gw_txt.c.

◆ co_gw_txt_set_recv_func()

void co_gw_txt_set_recv_func ( co_gw_txt_t gw,
co_gw_txt_recv_func_t func,
void *  data 
)

Sets the callback function used to forward indications and confirmations received by a CANopen gateway to the user.

Parameters
gwa pointer to a CANopen ASCII gateway.
funca pointer to the function invoked by co_gw_txt_recv().
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_gw_txt_get_recv_func()

Definition at line 760 of file gw_txt.c.

◆ co_gw_txt_send()

size_t co_gw_txt_send ( co_gw_txt_t gw,
const char *  begin,
const char *  end,
struct floc at 
)

Sends a user request to a CANopen gateway.

Parameters
gwa pointer to a CANopen ASCII gateway.
begina pointer to the start of the buffer containing the request.
enda pointer to one past the last character in the buffer (can be NULL if the buffer is null-terminated).
atan optional pointer to the file location of begin (used for diagnostic purposes). On success, if at != NULL, *at points to one past the last character parsed. On error, *at is left untouched.
Returns
the number of characters read.

Definition at line 498 of file gw_txt.c.

◆ co_gw_txt_get_send_func()

void co_gw_txt_get_send_func ( const co_gw_txt_t gw,
co_gw_txt_send_func_t **  pfunc,
void **  pdata 
)

Retrieves the callback function used to send requests from the user to a CANopen gateway.

Parameters
gwa pointer to a CANopen ASCII gateway.
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_gw_txt_set_send_func()

Definition at line 770 of file gw_txt.c.

◆ co_gw_txt_set_send_func()

void co_gw_txt_set_send_func ( co_gw_txt_t gw,
co_gw_txt_send_func_t func,
void *  data 
)

Sets the callback function used to send requests from the user to a CANopen gateway.

Parameters
gwa pointer to a CANopen ASCII gateway.
funca pointer to the function invoked by co_gw_txt_send().
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_gw_txt_get_send_func()

Definition at line 782 of file gw_txt.c.