Lely core libraries  2.3.4
nmt_cfg.c File Reference
#include "co.h"
#include "nmt_cfg.h"
#include <lely/co/dcf.h>
#include <lely/co/dev.h>
#include <lely/co/obj.h>
#include <lely/co/val.h>
#include <lely/util/diag.h>
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
Include dependency graph for nmt_cfg.c:

Go to the source code of this file.

Data Structures

struct  __co_nmt_cfg
 A CANopen NMT 'configuration request' service. More...
 
struct  __co_nmt_cfg_state
 A CANopen NMT 'configuration request' state. More...
 

Macros

#define LELY_CO_NMT_CFG_RESET_TIMEOUT   1000
 The timeout (in milliseconds) after sending the NMT 'reset communication' or 'reset node' command.
 

Typedefs

typedef const struct __co_nmt_cfg_state co_nmt_cfg_state_t
 An opaque CANopen NMT 'configuration request' state type.
 

Functions

static int co_nmt_cfg_recv (const struct can_msg *msg, void *data)
 The CAN receive callback function for a 'configuration request'. More...
 
static int co_nmt_cfg_timer (const struct timespec *tp, void *data)
 The CAN timer callback function for a 'configuration request'. More...
 
static void co_nmt_cfg_dn_con (co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, void *data)
 The CANopen SDO download confirmation callback function for a 'configuration request'. More...
 
static void co_nmt_cfg_enter (co_nmt_cfg_t *cfg, co_nmt_cfg_state_t *next)
 Enters the specified state of a 'configuration request; and invokes the exit and entry functions.
 
static void co_nmt_cfg_emit_recv (co_nmt_cfg_t *cfg, const struct can_msg *msg)
 Invokes the 'CAN frame received' transition function of the current state of a 'configuration request'. More...
 
static void co_nmt_cfg_emit_time (co_nmt_cfg_t *cfg, const struct timespec *tp)
 Invokes the 'timeout' transition function of the current state of a 'configuration request'. More...
 
static void co_nmt_cfg_emit_dn_con (co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
 Invokes the 'SDO download confirmation' transition function of the current state of a 'configuration request'. More...
 
static void co_nmt_cfg_emit_res (co_nmt_cfg_t *cfg, co_unsigned32_t ac)
 Invokes the 'result received' transition function of the current state of a 'configuration request'. More...
 
static co_nmt_cfg_state_tco_nmt_cfg_abort_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'abort' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_restore_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'restore configuration' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_restore_on_dn_con (co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'restore configuration' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_reset_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'reset' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_reset_on_recv (co_nmt_cfg_t *cfg, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'reset' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_reset_on_time (co_nmt_cfg_t *cfg, const struct timespec *tp)
 The 'timeout' transition function of the 'reset' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_store_1f20_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'store object 1F20' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_store_1f20_on_dn_con (co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'store object 1F20' state.
 
static void co_nmt_cfg_store_1f20_on_leave (co_nmt_cfg_t *cfg)
 The exit function of the 'store object 1F20' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_store_1f22_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'store object 1F22' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_store_1f22_on_dn_con (co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'store object 1F22' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_user_on_enter (co_nmt_cfg_t *cfg)
 The entry function of the 'user-defined configuration' state.
 
static co_nmt_cfg_state_tco_nmt_cfg_user_on_res (co_nmt_cfg_t *cfg, co_unsigned32_t ac)
 The 'result received' function of the 'user-defined configuration' state.
 
co_nmt_cfg_tco_nmt_cfg_create (can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
 Creates a new CANopen NMT 'configuration request'. More...
 
void co_nmt_cfg_destroy (co_nmt_cfg_t *cfg)
 Destroys a CANopen NMT 'configuration request'. More...
 
int co_nmt_cfg_cfg_req (co_nmt_cfg_t *cfg, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
 Starts a CANopen NMT 'configuration request'. More...
 
int co_nmt_cfg_cfg_res (co_nmt_cfg_t *cfg, co_unsigned32_t ac)
 Indicates the result of the 'update configuration' step of an NMT 'configuration request'. More...
 

Detailed Description

This file is part of the CANopen library; it contains the implementation of the NMT 'configuration request' functions.

See also
src/nmt_cfg.h
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 nmt_cfg.c.

Function Documentation

◆ co_nmt_cfg_recv()

static int co_nmt_cfg_recv ( const struct can_msg msg,
void *  data 
)
static

The CAN receive callback function for a 'configuration request'.

See also
can_recv_func_t

Definition at line 476 of file nmt_cfg.c.

◆ co_nmt_cfg_timer()

static int co_nmt_cfg_timer ( const struct timespec *  tp,
void *  data 
)
static

The CAN timer callback function for a 'configuration request'.

See also
can_timer_func_t

Definition at line 488 of file nmt_cfg.c.

◆ co_nmt_cfg_dn_con()

static void co_nmt_cfg_dn_con ( co_csdo_t sdo,
co_unsigned16_t  idx,
co_unsigned8_t  subidx,
co_unsigned32_t  ac,
void *  data 
)
static

The CANopen SDO download confirmation callback function for a 'configuration request'.

See also
co_csdo_dn_con_t

Definition at line 500 of file nmt_cfg.c.

◆ co_nmt_cfg_emit_recv()

static void co_nmt_cfg_emit_recv ( co_nmt_cfg_t cfg,
const struct can_msg msg 
)
inlinestatic

Invokes the 'CAN frame received' transition function of the current state of a 'configuration request'.

Parameters
cfga pointer to a 'configuration request'.
msga pointer to the received CAN frame.

Definition at line 527 of file nmt_cfg.c.

◆ co_nmt_cfg_emit_time()

static void co_nmt_cfg_emit_time ( co_nmt_cfg_t cfg,
const struct timespec *  tp 
)
inlinestatic

Invokes the 'timeout' transition function of the current state of a 'configuration request'.

Parameters
cfga pointer to a 'configuration request'.
tpa pointer to the current time.

Definition at line 537 of file nmt_cfg.c.

◆ co_nmt_cfg_emit_dn_con()

static void co_nmt_cfg_emit_dn_con ( co_nmt_cfg_t cfg,
co_unsigned16_t  idx,
co_unsigned8_t  subidx,
co_unsigned32_t  ac 
)
inlinestatic

Invokes the 'SDO download confirmation' transition function of the current state of a 'configuration request'.

Parameters
cfga pointer to a 'configuration request'.
acthe SDO abort code (0 on success).
idxthe object index.
subidxthe object sub-index.

Definition at line 547 of file nmt_cfg.c.

◆ co_nmt_cfg_emit_res()

static void co_nmt_cfg_emit_res ( co_nmt_cfg_t cfg,
co_unsigned32_t  ac 
)
inlinestatic

Invokes the 'result received' transition function of the current state of a 'configuration request'.

Parameters
cfga pointer to a 'configuration request'.
acthe SDO abort code (0 on success).

Definition at line 558 of file nmt_cfg.c.

◆ co_nmt_cfg_create()

co_nmt_cfg_t* co_nmt_cfg_create ( can_net_t net,
co_dev_t dev,
co_nmt_t nmt 
)

Creates a new CANopen NMT 'configuration request'.

Parameters
neta pointer to a CAN network.
deva pointer to a CANopen device.
nmta pointer to an NMT master service.
Returns
a pointer to a new NMT 'configuration request', or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_nmt_cfg_destroy()

Definition at line 401 of file nmt_cfg.c.

◆ co_nmt_cfg_destroy()

void co_nmt_cfg_destroy ( co_nmt_cfg_t boot)

Destroys a CANopen NMT 'configuration request'.

See also
co_nmt_cfg_create()

Definition at line 426 of file nmt_cfg.c.

◆ co_nmt_cfg_cfg_req()

int co_nmt_cfg_cfg_req ( co_nmt_cfg_t cfg,
co_unsigned8_t  id,
int  timeout,
co_csdo_ind_t dn_ind,
co_csdo_ind_t up_ind,
void *  data 
)

Starts a CANopen NMT 'configuration request'.

Parameters
cfga pointer to an NMT 'configuration request'.
idthe node-ID.
timeoutthe SDO timeout (in milliseconds). See co_csdo_set_timeout().
dn_inda pointer to the SDO download progress indication function (can be NULL).
up_inda pointer to the SDO upload progress indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to dn_ind and up_ind.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 435 of file nmt_cfg.c.

◆ co_nmt_cfg_cfg_res()

int co_nmt_cfg_cfg_res ( co_nmt_cfg_t cfg,
co_unsigned32_t  ac 
)

Indicates the result of the 'update configuration' step of an NMT 'configuration request'.

Parameters
cfga pointer to an NMT 'configuration request'.
acthe SDO abort code (0 on success).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 466 of file nmt_cfg.c.