Lely core libraries  2.3.4
nmt_boot.c File Reference

This file is part of the CANopen library; it contains the implementation of the NMT 'boot slave' functions. More...

#include "co.h"
#include "nmt_boot.h"
#include <lely/co/dev.h>
#include <lely/co/obj.h>
#include <lely/co/val.h>
#include <lely/util/diag.h>
#include <lely/util/time.h>
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
Include dependency graph for nmt_boot.c:

Go to the source code of this file.

Data Structures

struct  __co_nmt_boot
 A CANopen NMT 'boot slave' service. More...
 
struct  __co_nmt_boot_state
 A CANopen NMT 'boot slave' state. More...
 

Macros

#define LELY_CO_NMT_BOOT_WAIT_TIMEOUT   1000
 The timeout (in milliseconds) before trying to boot the slave again.
 
#define LELY_CO_NMT_BOOT_SDO_RETRY   3
 The number of times an SDO request is retried after a timeout.
 
#define LELY_CO_NMT_BOOT_RTR_TIMEOUT   100
 The timeout (in milliseconds) after sending a node guarding RTR.
 
#define LELY_CO_NMT_BOOT_RESET_TIMEOUT   1000
 The timeout (in milliseconds) after sending the NMT 'reset communication' command.
 
#define LELY_CO_NMT_BOOT_CHECK_TIMEOUT   100
 The timeout (in milliseconds) before checking the flash status indication or the program control of a slave again.
 

Typedefs

typedef const struct __co_nmt_boot_state co_nmt_boot_state_t
 An opaque CANopen NMT 'boot slave' state type.
 

Functions

static int co_nmt_boot_recv (const struct can_msg *msg, void *data)
 The CAN receive callback function for a 'boot slave' service. More...
 
static int co_nmt_boot_timer (const struct timespec *tp, void *data)
 The CAN timer callback function for a 'boot slave' service. More...
 
static void co_nmt_boot_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 'boot slave' service. More...
 
static void co_nmt_boot_up_con (co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, const void *ptr, size_t n, void *data)
 The CANopen SDO upload confirmation callback function for a 'boot slave' service. More...
 
static void co_nmt_boot_cfg_con (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac, void *data)
 The CANopen NMT 'configuration request' confirmation callback function for a 'boot slave' service. More...
 
static void co_nmt_boot_enter (co_nmt_boot_t *boot, co_nmt_boot_state_t *next)
 Enters the specified state of a 'boot slave' service and invokes the exit and entry functions.
 
static void co_nmt_boot_emit_recv (co_nmt_boot_t *boot, const struct can_msg *msg)
 Invokes the 'CAN frame received' transition function of the current state of a 'boot slave' service. More...
 
static void co_nmt_boot_emit_time (co_nmt_boot_t *boot, const struct timespec *tp)
 Invokes the 'timeout' transition function of the current state of a 'boot slave' service. More...
 
static void co_nmt_boot_emit_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 Invokes the 'SDO download confirmation' transition function of the current state of a 'boot slave' service. More...
 
static void co_nmt_boot_emit_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 Invokes the 'SDO upload confirmation' transition function of the current state of a 'boot slave' service. More...
 
static void co_nmt_boot_emit_cfg_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 Invokes the 'configuration request confirmation' transition function of the current state of a 'boot slave' service. More...
 
static co_nmt_boot_state_tco_nmt_boot_wait_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'wait asynchronously' state.
 
static co_nmt_boot_state_tco_nmt_boot_abort_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'abort' state.
 
static co_nmt_boot_state_tco_nmt_boot_error_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'error' state.
 
static void co_nmt_boot_error_on_leave (co_nmt_boot_t *boot)
 The exit function of the 'error' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_device_type_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check device type' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_device_type_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check device type' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_vendor_id_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check vendor ID' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_vendor_id_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check vendor ID' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_product_code_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check product code' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_product_code_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check product code' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_revision_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check revision number' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_revision_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check revision number' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_serial_nr_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check serial number' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_serial_nr_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check serial number' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_node_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check node state' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_node_on_recv (co_nmt_boot_t *boot, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'check node state' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_node_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'check node state' state.
 
static void co_nmt_boot_chk_node_on_leave (co_nmt_boot_t *boot)
 The exit function of the 'check node state' state.
 
static co_nmt_boot_state_tco_nmt_boot_reset_comm_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'reset communication' state.
 
static co_nmt_boot_state_tco_nmt_boot_reset_comm_on_recv (co_nmt_boot_t *boot, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'reset communication' state.
 
static co_nmt_boot_state_tco_nmt_boot_reset_comm_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'reset communication' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_sw_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check software' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_sw_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check software' state.
 
static co_nmt_boot_state_tco_nmt_boot_stop_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'stop program' state.
 
static co_nmt_boot_state_tco_nmt_boot_stop_prog_on_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'stop program' state.
 
static co_nmt_boot_state_tco_nmt_boot_stop_prog_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'stop program' state.
 
static co_nmt_boot_state_tco_nmt_boot_clear_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'clear program' state.
 
static co_nmt_boot_state_tco_nmt_boot_clear_prog_on_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'clear program' state.
 
static co_nmt_boot_state_tco_nmt_boot_blk_dn_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'download program' state.
 
static co_nmt_boot_state_tco_nmt_boot_blk_dn_prog_on_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'download program' state.
 
static co_nmt_boot_state_tco_nmt_boot_dn_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'download program' state.
 
static co_nmt_boot_state_tco_nmt_boot_dn_prog_on_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'download program' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_flash_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'wait for end of flashing' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_flash_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'wait for end of flashing' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_flash_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'wait for end of flashing' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check program SW ID state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_prog_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check program SW ID' state.
 
static co_nmt_boot_state_tco_nmt_boot_start_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'start program' state.
 
static co_nmt_boot_state_tco_nmt_boot_start_prog_on_dn_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'SDO download confirmation' transition function of the 'start program' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_prog_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'wait till program is started' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_prog_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'wait till program is started' state.
 
static co_nmt_boot_state_tco_nmt_boot_wait_prog_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'wait till program is started' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_cfg_date_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'check configuration date' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_cfg_date_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check configuration date' state.
 
static co_nmt_boot_state_tco_nmt_boot_chk_cfg_time_on_up_con (co_nmt_boot_t *boot, co_unsigned32_t ac, const void *ptr, size_t n)
 The 'SDO upload confirmation' transition function of the 'check configuration time' state.
 
static co_nmt_boot_state_tco_nmt_boot_up_cfg_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'update configuration' state.
 
static co_nmt_boot_state_tco_nmt_boot_up_cfg_on_cfg_con (co_nmt_boot_t *boot, co_unsigned32_t ac)
 The 'configuration request confirmation' transition unction of the 'update configuration' state.
 
static co_nmt_boot_state_tco_nmt_boot_ec_on_enter (co_nmt_boot_t *boot)
 The entry function of the 'start error control' state.
 
static co_nmt_boot_state_tco_nmt_boot_ec_on_recv (co_nmt_boot_t *boot, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'start error control' state.
 
static co_nmt_boot_state_tco_nmt_boot_ec_on_time (co_nmt_boot_t *boot, const struct timespec *tp)
 The 'timeout' transition function of the 'start error control' state.
 
static int co_nmt_boot_dn (co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val)
 Issues an SDO download request to the slave. More...
 
static int co_nmt_boot_up (co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx)
 Issues an SDO upload request to the slave. More...
 
static int co_nmt_boot_chk (co_nmt_boot_t *boot, co_unsigned16_t idx, co_unsigned8_t subidx, const void *ptr, size_t n)
 Compares the result of an SDO upload request to the value of a local sub-object. More...
 
static int co_nmt_boot_send_rtr (co_nmt_boot_t *boot)
 Sends a node guarding RTR to the slave. More...
 
co_nmt_boot_tco_nmt_boot_create (can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
 Creates a new CANopen NMT 'boot slave' service. More...
 
void co_nmt_boot_destroy (co_nmt_boot_t *boot)
 Destroys a CANopen NMT 'boot slave' service. More...
 
int co_nmt_boot_boot_req (co_nmt_boot_t *boot, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
 Starts a CANopen NMT 'boot slave' service. More...
 

Variables

static co_nmt_boot_state_t *const co_nmt_boot_wait_state = &(co_nmt_boot_state_t){ .on_time = &co_nmt_boot_wait_on_time }
 The 'wait asynchronously' state.
 
static co_nmt_boot_state_t *const co_nmt_boot_abort_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_abort_on_enter }
 The 'abort' state.
 
static co_nmt_boot_state_t *const co_nmt_boot_error_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_error_on_enter, .on_leave = &co_nmt_boot_error_on_leave }
 The 'error' state.
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_device_type_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_device_type_on_enter, .on_up_con = &co_nmt_boot_chk_device_type_on_up_con }
 The 'check device type' state (see Fig. 5 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_vendor_id_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_vendor_id_on_enter, .on_up_con = &co_nmt_boot_chk_vendor_id_on_up_con }
 The 'check vendor ID' state (see Fig. 5 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_product_code_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_product_code_on_enter, .on_up_con = &co_nmt_boot_chk_product_code_on_up_con }
 The 'check product code' state (see Fig. 5 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_revision_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_revision_on_enter, .on_up_con = &co_nmt_boot_chk_revision_on_up_con }
 The 'check revision number' state (see Fig. 5 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_serial_nr_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_serial_nr_on_enter, .on_up_con = &co_nmt_boot_chk_serial_nr_on_up_con }
 The 'check serial number' state (see Fig. 5 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_node_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_node_on_enter, .on_recv = &co_nmt_boot_chk_node_on_recv, .on_time = &co_nmt_boot_chk_node_on_time, .on_leave = &co_nmt_boot_chk_node_on_leave }
 The 'check node state' state (see Fig. 6 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_reset_comm_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_reset_comm_on_enter, .on_recv = &co_nmt_boot_reset_comm_on_recv, .on_time = &co_nmt_boot_reset_comm_on_time }
 The 'reset communication' state (see Fig. 6 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_sw_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_sw_on_enter, .on_up_con = &co_nmt_boot_chk_sw_on_up_con }
 The 'check software' state (see Fig. 6 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_stop_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_stop_prog_on_enter, .on_dn_con = &co_nmt_boot_stop_prog_on_dn_con, .on_up_con = &co_nmt_boot_stop_prog_on_up_con }
 The 'stop program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_clear_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_clear_prog_on_enter, .on_dn_con = &co_nmt_boot_clear_prog_on_dn_con }
 The 'clear program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_blk_dn_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_blk_dn_prog_on_enter, .on_dn_con = &co_nmt_boot_blk_dn_prog_on_dn_con }
 The 'download program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_dn_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_dn_prog_on_enter, .on_dn_con = &co_nmt_boot_dn_prog_on_dn_con }
 The 'download program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_wait_flash_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_wait_flash_on_enter, .on_time = &co_nmt_boot_wait_flash_on_time, .on_up_con = &co_nmt_boot_wait_flash_on_up_con }
 The 'check flashing' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_prog_on_enter, .on_up_con = &co_nmt_boot_chk_prog_on_up_con }
 The 'check program SW ID' state (see Fig. 8 in CiA 302-2 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_start_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_start_prog_on_enter, .on_dn_con = &co_nmt_boot_start_prog_on_dn_con }
 The 'start program' state (see Fig. 3 in CiA 302-3 version 4.1.0).
 
static co_nmt_boot_state_t *const co_nmt_boot_wait_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_wait_prog_on_enter, .on_time = &co_nmt_boot_wait_prog_on_time, .on_up_con = &co_nmt_boot_wait_prog_on_up_con }
 The 'wait till program is started' state (see Fig. More...
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_date_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_cfg_date_on_enter, .on_up_con = &co_nmt_boot_chk_cfg_date_on_up_con }
 The 'check configuration date' state (see Fig. More...
 
static co_nmt_boot_state_t *const co_nmt_boot_chk_cfg_time_state = &(co_nmt_boot_state_t){ .on_up_con = &co_nmt_boot_chk_cfg_time_on_up_con }
 The 'check configuration time' state (see Fig. More...
 
static co_nmt_boot_state_t *const co_nmt_boot_up_cfg_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_up_cfg_on_enter, .on_cfg_con = &co_nmt_boot_up_cfg_on_cfg_con }
 The 'update configuration' state (see Fig. More...
 
static co_nmt_boot_state_t *const co_nmt_boot_ec_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_ec_on_enter, .on_recv = &co_nmt_boot_ec_on_recv, .on_time = &co_nmt_boot_ec_on_time }
 The 'start error control' state (see Fig. 11 in CiA 302-2 version 4.1.0).
 

Detailed Description

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

See also
src/nmt_boot.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_boot.c.

Function Documentation

◆ co_nmt_boot_recv()

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

The CAN receive callback function for a 'boot slave' service.

See also
can_recv_func_t

Definition at line 951 of file nmt_boot.c.

◆ co_nmt_boot_timer()

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

The CAN timer callback function for a 'boot slave' service.

See also
can_timer_func_t

Definition at line 963 of file nmt_boot.c.

◆ co_nmt_boot_dn_con()

static void co_nmt_boot_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 'boot slave' service.

See also
co_csdo_dn_con_t

Definition at line 975 of file nmt_boot.c.

◆ co_nmt_boot_up_con()

static void co_nmt_boot_up_con ( co_csdo_t sdo,
co_unsigned16_t  idx,
co_unsigned8_t  subidx,
co_unsigned32_t  ac,
const void *  ptr,
size_t  n,
void *  data 
)
static

The CANopen SDO upload confirmation callback function for a 'boot slave' service.

See also
co_csdo_up_con_t

Definition at line 988 of file nmt_boot.c.

◆ co_nmt_boot_cfg_con()

static void co_nmt_boot_cfg_con ( co_nmt_t nmt,
co_unsigned8_t  id,
co_unsigned32_t  ac,
void *  data 
)
static

The CANopen NMT 'configuration request' confirmation callback function for a 'boot slave' service.

See also
co_nmt_cfg_con_t

Definition at line 1001 of file nmt_boot.c.

◆ co_nmt_boot_emit_recv()

static void co_nmt_boot_emit_recv ( co_nmt_boot_t boot,
const struct can_msg msg 
)
inlinestatic

Invokes the 'CAN frame received' transition function of the current state of a 'boot slave' service.

Parameters
boota pointer to a 'boot slave' service.
msga pointer to the received CAN frame.

Definition at line 1029 of file nmt_boot.c.

◆ co_nmt_boot_emit_time()

static void co_nmt_boot_emit_time ( co_nmt_boot_t boot,
const struct timespec *  tp 
)
inlinestatic

Invokes the 'timeout' transition function of the current state of a 'boot slave' service.

Parameters
boota pointer to a 'boot slave' service.
tpa pointer to the current time.

Definition at line 1039 of file nmt_boot.c.

◆ co_nmt_boot_emit_dn_con()

static void co_nmt_boot_emit_dn_con ( co_nmt_boot_t boot,
co_unsigned32_t  ac 
)
inlinestatic

Invokes the 'SDO download confirmation' transition function of the current state of a 'boot slave' service.

Parameters
boota pointer to a 'boot slave' service.
acthe SDO abort code (0 on success).

Definition at line 1049 of file nmt_boot.c.

◆ co_nmt_boot_emit_up_con()

static void co_nmt_boot_emit_up_con ( co_nmt_boot_t boot,
co_unsigned32_t  ac,
const void *  ptr,
size_t  n 
)
inlinestatic

Invokes the 'SDO upload confirmation' transition function of the current state of a 'boot slave' service.

Parameters
boota pointer to a 'boot slave' service.
acthe SDO abort code (0 on success).
ptra pointer to the uploaded bytes.
nthe number of bytes at ptr.

Definition at line 1059 of file nmt_boot.c.

◆ co_nmt_boot_emit_cfg_con()

static void co_nmt_boot_emit_cfg_con ( co_nmt_boot_t boot,
co_unsigned32_t  ac 
)
inlinestatic

Invokes the 'configuration request confirmation' transition function of the current state of a 'boot slave' service.

Parameters
boota pointer to a 'boot slave' service.
acthe SDO abort code (0 on success).

Definition at line 1070 of file nmt_boot.c.

◆ co_nmt_boot_dn()

static int co_nmt_boot_dn ( co_nmt_boot_t boot,
co_unsigned16_t  idx,
co_unsigned8_t  subidx,
co_unsigned16_t  type,
const void *  val 
)
static

Issues an SDO download request to the slave.

co_nmt_boot_dn_con() is called upon completion of the request.

Parameters
boota pointer to a 'boot slave' service.
idxthe remote object index.
subidxthe remote object sub-index.
typethe data type.
valthe address of the value to be written.
Returns
0 on success, or -1 on error.

Definition at line 2196 of file nmt_boot.c.

◆ co_nmt_boot_up()

static int co_nmt_boot_up ( co_nmt_boot_t boot,
co_unsigned16_t  idx,
co_unsigned8_t  subidx 
)
static

Issues an SDO upload request to the slave.

co_nmt_boot_up_con() is called upon completion of the request.

Parameters
boota pointer to a 'boot slave' service.
idxthe remote object index.
subidxthe remote object sub-index.
Returns
0 on success, or -1 on error.

Definition at line 2206 of file nmt_boot.c.

◆ co_nmt_boot_chk()

static int co_nmt_boot_chk ( co_nmt_boot_t boot,
co_unsigned16_t  idx,
co_unsigned8_t  subidx,
const void *  ptr,
size_t  n 
)
static

Compares the result of an SDO upload request to the value of a local sub-object.

Parameters
boota pointer to a 'boot slave' service.
idxthe local object index.
subidxthe local object sub-index.
ptra pointer to the uploaded bytes.
nthe number of bytes at ptr.
Returns
1 if the received value matches that of the specified sub-object, and 0 if not.

Definition at line 2215 of file nmt_boot.c.

◆ co_nmt_boot_send_rtr()

static int co_nmt_boot_send_rtr ( co_nmt_boot_t boot)
static

Sends a node guarding RTR to the slave.

Returns
0 on success, or -1 on error.

Definition at line 2235 of file nmt_boot.c.

◆ co_nmt_boot_create()

co_nmt_boot_t* co_nmt_boot_create ( can_net_t net,
co_dev_t dev,
co_nmt_t nmt 
)

Creates a new CANopen NMT 'boot slave' service.

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 'boot slave' service, or NULL on error.
See also
co_nmt_boot_destroy()

Definition at line 885 of file nmt_boot.c.

◆ co_nmt_boot_destroy()

void co_nmt_boot_destroy ( co_nmt_boot_t boot)

Destroys a CANopen NMT 'boot slave' service.

See also
co_nmt_boot_create()

Definition at line 910 of file nmt_boot.c.

◆ co_nmt_boot_boot_req()

int co_nmt_boot_boot_req ( co_nmt_boot_t boot,
co_unsigned8_t  id,
int  timeout,
co_csdo_ind_t dn_ind,
co_csdo_ind_t up_ind,
void *  data 
)

Starts a CANopen NMT 'boot slave' service.

Parameters
boota pointer to an NMT 'boot slave' service.
idthe node-ID.
timeoutthe SDO timeout (in milliseconds).
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 919 of file nmt_boot.c.

Variable Documentation

◆ co_nmt_boot_wait_prog_state

co_nmt_boot_state_t* const co_nmt_boot_wait_prog_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_wait_prog_on_enter, .on_time = &co_nmt_boot_wait_prog_on_time, .on_up_con = &co_nmt_boot_wait_prog_on_up_con }
static

The 'wait till program is started' state (see Fig.

8 in CiA 302-2 version 4.1.0).

Definition at line 655 of file nmt_boot.c.

◆ co_nmt_boot_chk_cfg_date_state

co_nmt_boot_state_t* const co_nmt_boot_chk_cfg_date_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_chk_cfg_date_on_enter, .on_up_con = &co_nmt_boot_chk_cfg_date_on_up_con }
static

The 'check configuration date' state (see Fig.

8 in CiA 302-2 version 4.1.0).

Definition at line 677 of file nmt_boot.c.

◆ co_nmt_boot_chk_cfg_time_state

co_nmt_boot_state_t* const co_nmt_boot_chk_cfg_time_state = &(co_nmt_boot_state_t){ .on_up_con = &co_nmt_boot_chk_cfg_time_on_up_con }
static

The 'check configuration time' state (see Fig.

8 in CiA 302-2 version 4.1.0).

Definition at line 694 of file nmt_boot.c.

◆ co_nmt_boot_up_cfg_state

co_nmt_boot_state_t* const co_nmt_boot_up_cfg_state = &(co_nmt_boot_state_t){ .on_enter = &co_nmt_boot_up_cfg_on_enter, .on_cfg_con = &co_nmt_boot_up_cfg_on_cfg_con }
static

The 'update configuration' state (see Fig.

8 in CiA 302-2 version 4.1.0).

Definition at line 714 of file nmt_boot.c.