Lely core libraries
2.3.4
|
#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>
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_t * | co_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_t * | co_nmt_boot_abort_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'abort' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_nmt_boot_reset_comm_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'reset communication' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_nmt_boot_chk_sw_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'check software' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_nmt_boot_stop_prog_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'stop program' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_nmt_boot_clear_prog_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'clear program' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_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_t * | co_nmt_boot_dn_prog_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'download program' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_nmt_boot_start_prog_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'start program' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_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_t * | co_nmt_boot_up_cfg_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'update configuration' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_nmt_boot_ec_on_enter (co_nmt_boot_t *boot) |
The entry function of the 'start error control' state. | |
static co_nmt_boot_state_t * | co_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_t * | co_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_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. 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... | |
This file is part of the CANopen library; it contains the implementation of the NMT 'boot slave' functions.
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.
|
static |
The CAN receive callback function for a 'boot slave' service.
Definition at line 951 of file nmt_boot.c.
|
static |
The CAN timer callback function for a 'boot slave' service.
Definition at line 963 of file nmt_boot.c.
|
static |
The CANopen SDO download confirmation callback function for a 'boot slave' service.
Definition at line 975 of file nmt_boot.c.
|
static |
The CANopen SDO upload confirmation callback function for a 'boot slave' service.
Definition at line 988 of file nmt_boot.c.
|
static |
The CANopen NMT 'configuration request' confirmation callback function for a 'boot slave' service.
Definition at line 1001 of file nmt_boot.c.
|
inlinestatic |
Invokes the 'CAN frame received' transition function of the current state of a 'boot slave' service.
boot | a pointer to a 'boot slave' service. |
msg | a pointer to the received CAN frame. |
Definition at line 1029 of file nmt_boot.c.
|
inlinestatic |
Invokes the 'timeout' transition function of the current state of a 'boot slave' service.
boot | a pointer to a 'boot slave' service. |
tp | a pointer to the current time. |
Definition at line 1039 of file nmt_boot.c.
|
inlinestatic |
Invokes the 'SDO download confirmation' transition function of the current state of a 'boot slave' service.
boot | a pointer to a 'boot slave' service. |
ac | the SDO abort code (0 on success). |
Definition at line 1049 of file nmt_boot.c.
|
inlinestatic |
Invokes the 'SDO upload confirmation' transition function of the current state of a 'boot slave' service.
boot | a pointer to a 'boot slave' service. |
ac | the SDO abort code (0 on success). |
ptr | a pointer to the uploaded bytes. |
n | the number of bytes at ptr. |
Definition at line 1059 of file nmt_boot.c.
|
inlinestatic |
Invokes the 'configuration request confirmation' transition function of the current state of a 'boot slave' service.
boot | a pointer to a 'boot slave' service. |
ac | the SDO abort code (0 on success). |
Definition at line 1070 of file nmt_boot.c.
|
static |
Issues an SDO download request to the slave.
co_nmt_boot_dn_con() is called upon completion of the request.
boot | a pointer to a 'boot slave' service. |
idx | the remote object index. |
subidx | the remote object sub-index. |
type | the data type. |
val | the address of the value to be written. |
Definition at line 2196 of file nmt_boot.c.
|
static |
Issues an SDO upload request to the slave.
co_nmt_boot_up_con() is called upon completion of the request.
boot | a pointer to a 'boot slave' service. |
idx | the remote object index. |
subidx | the remote object sub-index. |
Definition at line 2206 of file nmt_boot.c.
|
static |
Compares the result of an SDO upload request to the value of a local sub-object.
boot | a pointer to a 'boot slave' service. |
idx | the local object index. |
subidx | the local object sub-index. |
ptr | a pointer to the uploaded bytes. |
n | the number of bytes at ptr. |
Definition at line 2215 of file nmt_boot.c.
|
static |
Sends a node guarding RTR to the slave.
Definition at line 2235 of file nmt_boot.c.
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.
net | a pointer to a CAN network. |
dev | a pointer to a CANopen device. |
nmt | a pointer to an NMT master service. |
Definition at line 885 of file nmt_boot.c.
void co_nmt_boot_destroy | ( | co_nmt_boot_t * | boot | ) |
Destroys a CANopen NMT 'boot slave' service.
Definition at line 910 of file nmt_boot.c.
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.
boot | a pointer to an NMT 'boot slave' service. |
id | the node-ID. |
timeout | the SDO timeout (in milliseconds). |
dn_ind | a pointer to the SDO download progress indication function (can be NULL). |
up_ind | a pointer to the SDO upload progress indication function (can be NULL). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to dn_ind and up_ind. |
Definition at line 919 of file nmt_boot.c.
|
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.
|
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.
|
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.
|
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.