Lely core libraries 2.3.4
lss.c File Reference

This file is part of the CANopen library; it contains the implementation of the Layer Setting Services (LSS) and protocols functions. More...

#include "co.h"
#include <lely/co/lss.h>
#include <lely/co/nmt.h>
#include <lely/co/obj.h>
#include <lely/co/val.h>
#include <lely/util/endian.h>
#include <lely/util/errnum.h>
#include <lely/util/time.h>
#include <assert.h>
#include <stdlib.h>
Include dependency graph for lss.c:

Go to the source code of this file.

Data Structures

struct  __co_lss
 A CANopen LSS master/slave service. More...
 
struct  __co_lss_state
 A CANopen LSS state. More...
 

Typedefs

typedef const struct __co_lss_state co_lss_state_t
 An opaque CANopen LSS state type.
 

Functions

static int co_lss_recv (const struct can_msg *msg, void *data)
 The CAN receive callback function for an LSS service. More...
 
static int co_lss_timer (const struct timespec *tp, void *data)
 The CAN timer callback function for an LSS service. More...
 
static void co_lss_enter (co_lss_t *lss, co_lss_state_t *next)
 Enters the specified state of an LSS service and invokes the exit and entry functions.
 
static void co_lss_emit_recv (co_lss_t *lss, const struct can_msg *msg)
 Invokes the 'CAN frame received' transition function of the current state of an LSS service. More...
 
static void co_lss_emit_time (co_lss_t *lss, const struct timespec *tp)
 Invokes the 'timeout' transition function of the current state of an LSS service. More...
 
static co_lss_state_tco_lss_wait_on_enter (co_lss_t *lss)
 The entry function of the 'waiting' state an LSS master or slave.
 
static co_lss_state_tco_lss_wait_slave_on_enter (co_lss_t *lss)
 The entry function of the 'waiting' state of an LSS slave.
 
static co_lss_state_tco_lss_wait_slave_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'waiting' state of an LSS slave.
 
static co_lss_state_tco_lss_cfg_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the 'configuration' state of an LSS slave.
 
static co_lss_state_tco_lss_cs_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the command received state.
 
static co_lss_state_tco_lss_cs_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the command received state.
 
static co_lss_state_tco_lss_cs_fini_on_enter (co_lss_t *lss)
 The entry function of the command received finalization state.
 
static void co_lss_cs_fini_on_leave (co_lss_t *lss)
 The exit function of the command received finalization state.
 
static co_lss_state_tco_lss_switch_sel_on_enter (co_lss_t *lss)
 The entry function of the 'switch state selective' state.
 
static co_lss_state_tco_lss_switch_sel_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the 'switch state selective' state.
 
static co_lss_state_tco_lss_err_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the error received state.
 
static co_lss_state_tco_lss_err_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the error received state.
 
static void co_lss_err_on_leave (co_lss_t *lss)
 The exit function of the error received state.
 
static co_lss_state_tco_lss_lssid_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the inquire identity state.
 
static co_lss_state_tco_lss_lssid_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the inquire identity state.
 
static void co_lss_lssid_on_leave (co_lss_t *lss)
 The exit function of the inquire identity state.
 
static co_lss_state_tco_lss_nid_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the inquire node-ID state.
 
static co_lss_state_tco_lss_nid_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the inquire node-ID state.
 
static void co_lss_nid_on_leave (co_lss_t *lss)
 The exit function of the inquire node-ID state.
 
static co_lss_state_tco_lss_id_slave_on_enter (co_lss_t *lss)
 The entry function of the 'identify remote slave' state.
 
static co_lss_state_tco_lss_id_slave_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the 'identify remote slave' state.
 
static co_lss_state_tco_lss_slowscan_init_on_enter (co_lss_t *lss)
 The entry function of the Slowscan initialization state.
 
static co_lss_state_tco_lss_slowscan_init_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Slowscan initialization state.
 
static co_lss_state_tco_lss_slowscan_init_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Slowscan initialization state.
 
static co_lss_state_tco_lss_slowscan_scan_on_enter (co_lss_t *lss)
 The entry function of the Slowscan scanning state.
 
static co_lss_state_tco_lss_slowscan_scan_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Slowscan scanning state.
 
static co_lss_state_tco_lss_slowscan_scan_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Slowscan scanning state.
 
static co_lss_state_tco_lss_slowscan_wait_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Slowscan waiting state.
 
static co_lss_state_tco_lss_slowscan_wait_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Slowscan waiting state.
 
static co_lss_state_tco_lss_slowscan_switch_on_enter (co_lss_t *lss)
 The entry function of the Slowscan 'switch state selective' state.
 
static co_lss_state_tco_lss_slowscan_switch_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Slowscan 'switch state selective' state.
 
static co_lss_state_tco_lss_slowscan_switch_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Slowscan 'switch state selective' state.
 
static co_lss_state_tco_lss_slowscan_fini_on_enter (co_lss_t *lss)
 The entry function of the Slowscan finalization state.
 
static void co_lss_slowscan_fini_on_leave (co_lss_t *lss)
 The exit function of the Slowscan finalization state.
 
static co_lss_state_tco_lss_fastscan_init_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Fastscan initialization state.
 
static co_lss_state_tco_lss_fastscan_init_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Fastscan initialization state.
 
static co_lss_state_tco_lss_fastscan_scan_on_enter (co_lss_t *lss)
 The entry function of the Fastscan scanning state.
 
static co_lss_state_tco_lss_fastscan_scan_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Fastscan scanning state.
 
static co_lss_state_tco_lss_fastscan_scan_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Fastscan scanning state.
 
static co_lss_state_tco_lss_fastscan_wait_on_recv (co_lss_t *lss, const struct can_msg *msg)
 The 'CAN frame received' transition function of the Fastscan waiting state.
 
static co_lss_state_tco_lss_fastscan_wait_on_time (co_lss_t *lss, const struct timespec *tp)
 The 'timeout' transition function of the Fastscan waiting state.
 
static co_lss_state_tco_lss_fastscan_fini_on_enter (co_lss_t *lss)
 The entry function of the Fastscan finalization state.
 
static void co_lss_fastscan_fini_on_leave (co_lss_t *lss)
 The exit function of the Fastscan finalization state.
 
static co_lss_state_tco_lss_switch_sel (co_lss_t *lss, co_unsigned8_t cs, co_unsigned32_t id)
 Implements the switch state selective service for an LSS slave. More...
 
static void co_lss_id_slave (co_lss_t *lss, co_unsigned8_t cs, co_unsigned32_t id)
 Implements the LSS identify remote slave service for an LSS slave. More...
 
static void co_lss_id_non_cfg_slave (const co_lss_t *lss)
 Implements the LSS identify non-configured remote slave service for an LSS slave. More...
 
static co_lss_state_tco_lss_fastscan (co_lss_t *lss, co_unsigned32_t id, co_unsigned8_t bitchk, co_unsigned8_t lsssub, co_unsigned8_t lssnext)
 Implements the LSS fastscan service for an LSS slave. More...
 
static void co_lss_init_req (const co_lss_t *lss, struct can_msg *msg, co_unsigned8_t cs)
 Initializes an LSS request CAN frame. More...
 
static int co_lss_send_switch_sel_req (co_lss_t *lss, const struct co_id *id)
 Sends a single frame of a switch state selective request (see Fig. More...
 
static int co_lss_send_id_slave_req (co_lss_t *lss, const struct co_id *lo, const struct co_id *hi)
 Sends a single frame of an LSS identify remote slave request (see Fig. More...
 
static int co_lss_send_fastscan_req (const co_lss_t *lss, co_unsigned32_t id, co_unsigned8_t bitchk, co_unsigned8_t lsssub, co_unsigned8_t lssnext)
 Sends an LSS Fastscan request (see Fig. More...
 
static void co_lss_init_ind (co_lss_t *lss, co_unsigned8_t cs)
 Prepares an LSS master to receive an indication from a slave. More...
 
static co_unsigned32_t * co_id_sub (struct co_id *id, co_unsigned8_t sub)
 Returns a pointer to the specified number in an LSS address. More...
 
co_lss_tco_lss_create (co_nmt_t *nmt)
 Creates a new CANopen LSS master/slave service. More...
 
void co_lss_destroy (co_lss_t *lss)
 Destroys a CANopen LSS master/slave service. More...
 
int co_lss_start (co_lss_t *lss)
 Starts an LSS service. More...
 
void co_lss_stop (co_lss_t *lss)
 Stops an LSS service. More...
 
int co_lss_is_stopped (const co_lss_t *lss)
 Retuns 1 if the specified LSS service is stopped, and 0 if not. More...
 
co_nmt_tco_lss_get_nmt (const co_lss_t *lss)
 Returns a pointer to the NMT service of an LSS master/slave service.
 
void co_lss_get_rate_ind (const co_lss_t *lss, co_lss_rate_ind_t **pind, void **pdata)
 Retrieves the indication function invoked when an LSS 'activate bit timing' request is received. More...
 
void co_lss_set_rate_ind (co_lss_t *lss, co_lss_rate_ind_t *ind, void *data)
 Sets the indication function invoked when an LSS 'activate bit timing' request is received. More...
 
void co_lss_get_store_ind (const co_lss_t *lss, co_lss_store_ind_t **pind, void **pdata)
 Retrieves the indication function invoked when an LSS 'store configuration' request is received. More...
 
void co_lss_set_store_ind (co_lss_t *lss, co_lss_store_ind_t *ind, void *data)
 Sets the indication function invoked when an LSS 'store configuration' request is received. More...
 
co_unsigned16_t co_lss_get_inhibit (const co_lss_t *lss)
 Returns the inhibit time (in multiples of 100 microseconds) of an LSS master service. More...
 
void co_lss_set_inhibit (co_lss_t *lss, co_unsigned16_t inhibit)
 Sets the inhibit time between successive LSS messages of an LSS master service. More...
 
int co_lss_get_timeout (const co_lss_t *lss)
 Returns the timeout (in milliseconds) of an LSS master service. More...
 
void co_lss_set_timeout (co_lss_t *lss, int timeout)
 Sets the timeout of an LSS master service. More...
 
int co_lss_is_master (const co_lss_t *lss)
 Returns 1 if the specified CANopen LSS service is a master, and 0 if not.
 
int co_lss_is_idle (const co_lss_t *lss)
 Returns 1 if the specified LSS master is idle, and 0 if a request is ongoing.
 
void co_lss_abort_req (co_lss_t *lss)
 Aborts the current LSS master request. More...
 
int co_lss_switch_req (co_lss_t *lss, co_unsigned8_t mode)
 Requests the 'switch state global' service. More...
 
int co_lss_switch_sel_req (co_lss_t *lss, const struct co_id *id, co_lss_cs_ind_t *ind, void *data)
 Requests the 'switch state selective' service. More...
 
int co_lss_set_id_req (co_lss_t *lss, co_unsigned8_t id, co_lss_err_ind_t *ind, void *data)
 Requests the 'configure node-ID' service. More...
 
int co_lss_set_rate_req (co_lss_t *lss, co_unsigned16_t rate, co_lss_err_ind_t *ind, void *data)
 Requests the 'configure bit timing parameters' service. More...
 
int co_lss_switch_rate_req (co_lss_t *lss, int delay)
 Requests the 'activate bit timing parameters' service. More...
 
int co_lss_store_req (co_lss_t *lss, co_lss_err_ind_t *ind, void *data)
 Requests the 'store configuration' service. More...
 
int co_lss_get_vendor_id_req (co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
 Requests the 'inquire identity vendor-ID' service. More...
 
int co_lss_get_product_code_req (co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
 Requests the 'inquire identity product-code' service. More...
 
int co_lss_get_revision_req (co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
 Requests the 'inquire identity revision-number' service. More...
 
int co_lss_get_serial_nr_req (co_lss_t *lss, co_lss_lssid_ind_t *ind, void *data)
 Requests the 'inquire identity serial-number' service. More...
 
int co_lss_get_id_req (co_lss_t *lss, co_lss_nid_ind_t *ind, void *data)
 Requests the 'inquire node-ID' service. More...
 
int co_lss_id_slave_req (co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_cs_ind_t *ind, void *data)
 Requests the 'LSS identify remote slave' service. More...
 
int co_lss_id_non_cfg_slave_req (co_lss_t *lss, co_lss_cs_ind_t *ind, void *data)
 Requests the 'LSS identify non-configured remote slave' service. More...
 
int co_lss_slowscan_req (co_lss_t *lss, const struct co_id *lo, const struct co_id *hi, co_lss_scan_ind_t *ind, void *data)
 Requests the 'LSS Slowscan' service. More...
 
int co_lss_fastscan_req (co_lss_t *lss, const struct co_id *id, const struct co_id *mask, co_lss_scan_ind_t *ind, void *data)
 Requests the 'LSS Fastscan' service. More...
 

Variables

static co_lss_state_t *const co_lss_stopped_state = &(co_lss_state_t){ .on_recv = NULL }
 The 'stopped' state of an LSS master or slave.
 
static co_lss_state_t *const co_lss_wait_state = &(co_lss_state_t){ .on_enter = &co_lss_wait_on_enter }
 The 'waiting' state of an LSS master or slave.
 
static co_lss_state_t *const co_lss_wait_slave_state = &(co_lss_state_t){ .on_enter = &co_lss_wait_slave_on_enter, .on_recv = &co_lss_wait_slave_on_recv }
 The 'waiting' state of an LSS slave.
 
static co_lss_state_t *const co_lss_cfg_state = &(co_lss_state_t){ .on_recv = &co_lss_cfg_on_recv }
 The 'configuration' state of an LSS slave.
 
static co_lss_state_t *const co_lss_cs_state = &(co_lss_state_t){ .on_recv = &co_lss_cs_on_recv, .on_time = &co_lss_cs_on_time }
 The command received state.
 
static co_lss_state_t *const co_lss_cs_fini_state = &(co_lss_state_t){ .on_enter = &co_lss_cs_fini_on_enter, .on_leave = &co_lss_cs_fini_on_leave }
 The command received finalization state.
 
static co_lss_state_t *const co_lss_switch_sel_state = &(co_lss_state_t){ .on_enter = &co_lss_switch_sel_on_enter, .on_time = &co_lss_switch_sel_on_time }
 The 'switch state selective' state.
 
static co_lss_state_t *const co_lss_err_state = &(co_lss_state_t){ .on_recv = &co_lss_err_on_recv, .on_time = &co_lss_err_on_time, .on_leave = &co_lss_err_on_leave }
 The error received state.
 
static co_lss_state_t *const co_lss_lssid_state = &(co_lss_state_t){ .on_recv = &co_lss_lssid_on_recv, .on_time = &co_lss_lssid_on_time, .on_leave = &co_lss_lssid_on_leave }
 The inquire identity state.
 
static co_lss_state_t *const co_lss_nid_state = &(co_lss_state_t){ .on_recv = &co_lss_nid_on_recv, .on_time = &co_lss_nid_on_time, .on_leave = &co_lss_nid_on_leave }
 The inquire node-ID state.
 
static co_lss_state_t *const co_lss_id_slave_state = &(co_lss_state_t){ .on_enter = &co_lss_id_slave_on_enter, .on_time = &co_lss_id_slave_on_time }
 The 'identify remote slave' state.
 
static co_lss_state_t *const co_lss_slowscan_init_state = &(co_lss_state_t){ .on_enter = &co_lss_slowscan_init_on_enter, .on_recv = &co_lss_slowscan_init_on_recv, .on_time = &co_lss_slowscan_init_on_time }
 The Slowscan initialization state.
 
static co_lss_state_t *const co_lss_slowscan_scan_state = &(co_lss_state_t){ .on_enter = &co_lss_slowscan_scan_on_enter, .on_recv = &co_lss_slowscan_scan_on_recv, .on_time = &co_lss_slowscan_scan_on_time }
 The Slowscan scanning state.
 
static co_lss_state_t *const co_lss_slowscan_wait_state = &(co_lss_state_t){ .on_recv = &co_lss_slowscan_wait_on_recv, .on_time = &co_lss_slowscan_wait_on_time }
 The Slowscan waiting state.
 
static co_lss_state_t *const co_lss_slowscan_switch_state = &(co_lss_state_t){ .on_enter = &co_lss_slowscan_switch_on_enter, .on_recv = &co_lss_slowscan_switch_on_recv, .on_time = &co_lss_slowscan_switch_on_time }
 The Slowscan 'switch state selective' state.
 
static co_lss_state_t *const co_lss_slowscan_fini_state = &(co_lss_state_t){ .on_enter = &co_lss_slowscan_fini_on_enter, .on_leave = &co_lss_slowscan_fini_on_leave }
 The Slowscan finalization state.
 
static co_lss_state_t *const co_lss_fastscan_init_state = &(co_lss_state_t){ .on_recv = &co_lss_fastscan_init_on_recv, .on_time = &co_lss_fastscan_init_on_time }
 The Fastscan initialization state.
 
static co_lss_state_t *const co_lss_fastscan_scan_state = &(co_lss_state_t){ .on_enter = &co_lss_fastscan_scan_on_enter, .on_recv = &co_lss_fastscan_scan_on_recv, .on_time = &co_lss_fastscan_scan_on_time }
 The Fastscan scanning state.
 
static co_lss_state_t *const co_lss_fastscan_wait_state = &(co_lss_state_t){ .on_recv = &co_lss_fastscan_wait_on_recv, .on_time = &co_lss_fastscan_wait_on_time }
 The Fastscan waiting state.
 
static co_lss_state_t *const co_lss_fastscan_fini_state = &(co_lss_state_t){ .on_enter = &co_lss_fastscan_fini_on_enter, .on_leave = &co_lss_fastscan_fini_on_leave }
 The Fastscan finalization state.
 

Detailed Description

This file is part of the CANopen library; it contains the implementation of the Layer Setting Services (LSS) and protocols functions.

See also
lely/co/lss.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 lss.c.

Function Documentation

◆ co_lss_recv()

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

The CAN receive callback function for an LSS service.

See also
can_recv_func_t

Definition at line 1412 of file lss.c.

◆ co_lss_timer()

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

The CAN timer callback function for an LSS service.

See also
can_timer_func_t

Definition at line 1425 of file lss.c.

◆ co_lss_emit_recv()

static void co_lss_emit_recv ( co_lss_t lss,
const struct can_msg msg 
)
inlinestatic

Invokes the 'CAN frame received' transition function of the current state of an LSS service.

Parameters
lssa pointer to an LSS service.
msga pointer to the received CAN frame.

Definition at line 1454 of file lss.c.

◆ co_lss_emit_time()

static void co_lss_emit_time ( co_lss_t lss,
const struct timespec *  tp 
)
inlinestatic

Invokes the 'timeout' transition function of the current state of an LSS service.

Parameters
lssa pointer to an LSS service.
tpa pointer to the current time.

Definition at line 1465 of file lss.c.

◆ co_lss_switch_sel()

static co_lss_state_t * co_lss_switch_sel ( co_lss_t lss,
co_unsigned8_t  cs,
co_unsigned32_t  id 
)
static

Implements the switch state selective service for an LSS slave.

See Fig. 32 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS slave service.
csthe command specifier (in the range [0x40..0x43]).
idthe current LSS number to be checked.
Returns
a pointer to the next state.

Definition at line 2346 of file lss.c.

◆ co_lss_id_slave()

static void co_lss_id_slave ( co_lss_t lss,
co_unsigned8_t  cs,
co_unsigned32_t  id 
)
static

Implements the LSS identify remote slave service for an LSS slave.

See Fig. 42 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS slave service.
csthe command specifier (in the range [0x46..0x4b]).
idthe current LSS number to be checked.

Definition at line 2392 of file lss.c.

◆ co_lss_id_non_cfg_slave()

static void co_lss_id_non_cfg_slave ( const co_lss_t lss)
static

Implements the LSS identify non-configured remote slave service for an LSS slave.

See Fig. 44 in CiA 305 version 3.0.0.

Definition at line 2455 of file lss.c.

◆ co_lss_fastscan()

static co_lss_state_t * co_lss_fastscan ( co_lss_t lss,
co_unsigned32_t  id,
co_unsigned8_t  bitchk,
co_unsigned8_t  lsssub,
co_unsigned8_t  lssnext 
)
static

Implements the LSS fastscan service for an LSS slave.

See Fig. 46 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS slave service.
idthe value of LSS number which is currently determined by the LSS master.
bitchkthe least significant bit of id to be checked.
lsssubthe index of id in the LSS address (in the range [0..3]).
lssnextthe value if lsssub in the next request.
Returns
a pointer to the next state.

Definition at line 2477 of file lss.c.

◆ co_lss_init_req()

static void co_lss_init_req ( const co_lss_t lss,
struct can_msg msg,
co_unsigned8_t  cs 
)
static

Initializes an LSS request CAN frame.

Parameters
lssa pointer to an LSS service.
msga pointer to the CAN frame to be initialized.
csthe command specifier.

Definition at line 2515 of file lss.c.

◆ co_lss_send_switch_sel_req()

static int co_lss_send_switch_sel_req ( co_lss_t lss,
const struct co_id id 
)
static

Sends a single frame of a switch state selective request (see Fig.

32 in CiA 305 version 3.0.0). After the last frame has been sent, this function invokes co_lss_init_ind(lss, 0x44) to prepare the master for the response from the slave.

Parameters
lssa pointer to an LSS master service.
ida pointer to the LSS address of the slave to be configured.
Returns
0 on success, or -1 on error.

Definition at line 2529 of file lss.c.

◆ co_lss_send_id_slave_req()

static int co_lss_send_id_slave_req ( co_lss_t lss,
const struct co_id lo,
const struct co_id hi 
)
static

Sends a single frame of an LSS identify remote slave request (see Fig.

42 in CiA 305 version 3.0.0). After the last frame has been sent, this function invokes co_lss_init_ind(lss, 0x4f) to prepare the master for the response from the slave.

Parameters
lssa pointer to an LSS master service.
loa pointer to the lower bound of the LSS address.
hia pointer to the upper bound of the LSS address. The vendor-ID and product-code MUST be the same as in *lo.
Returns
0 on success, or -1 on error.

Definition at line 2573 of file lss.c.

◆ co_lss_send_fastscan_req()

static int co_lss_send_fastscan_req ( const co_lss_t lss,
co_unsigned32_t  id,
co_unsigned8_t  bitchk,
co_unsigned8_t  lsssub,
co_unsigned8_t  lssnext 
)
static

Sends an LSS Fastscan request (see Fig.

46 in CiA 305 version 3.0.0).

Parameters
lssa pointer to an LSS master service.
idthe current LSS number to be checked.
bitchkthe least-significant bit to be checked.
lsssubthe index of id.
lssnextthe index of the next LSS number to be checked.
Returns
0 on success, or -1 on error.

Definition at line 2631 of file lss.c.

◆ co_lss_init_ind()

static void co_lss_init_ind ( co_lss_t lss,
co_unsigned8_t  cs 
)
static

Prepares an LSS master to receive an indication from a slave.

Parameters
lssa pointer to an LSS master service.
csthe expected command specifier.

Definition at line 2646 of file lss.c.

◆ co_id_sub()

static co_unsigned32_t * co_id_sub ( struct co_id id,
co_unsigned8_t  sub 
)
inlinestatic

Returns a pointer to the specified number in an LSS address.

Parameters
ida pointer to an LSS address.
subthe index of the number (in the range [0..3]).
Returns
the address of the LSS number, or NULL on error.

Definition at line 2661 of file lss.c.

◆ co_lss_create()

co_lss_t * co_lss_create ( co_nmt_t nmt)

Creates a new CANopen LSS master/slave service.

The service is started as if by co_lss_start().

Parameters
nmta pointer to an NMT master/slave service.
Returns
a pointer to a new LSS service, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_lss_destroy()

Definition at line 783 of file lss.c.

◆ co_lss_destroy()

void co_lss_destroy ( co_lss_t lss)

Destroys a CANopen LSS master/slave service.

See also
co_lss_create()

Definition at line 810 of file lss.c.

◆ co_lss_start()

int co_lss_start ( co_lss_t lss)

Starts an LSS service.

Postcondition
on success, co_lss_is_stopped() returns 0.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_lss_stop()

Definition at line 820 of file lss.c.

◆ co_lss_stop()

void co_lss_stop ( co_lss_t lss)

Stops an LSS service.

Postcondition
co_lss_is_stopped() returns 1.
See also
co_lss_start()

Definition at line 833 of file lss.c.

◆ co_lss_is_stopped()

int co_lss_is_stopped ( const co_lss_t lss)

Retuns 1 if the specified LSS service is stopped, and 0 if not.

See also
co_lss_start, co_lss_stop()

Definition at line 849 of file lss.c.

◆ co_lss_get_rate_ind()

void co_lss_get_rate_ind ( const co_lss_t lss,
co_lss_rate_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked when an LSS 'activate bit timing' request is received.

Parameters
lssa pointer to an LSS slave service.
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_lss_set_rate_ind()

Definition at line 865 of file lss.c.

◆ co_lss_set_rate_ind()

void co_lss_set_rate_ind ( co_lss_t lss,
co_lss_rate_ind_t ind,
void *  data 
)

Sets the indication function invoked when an LSS 'activate bit timing' request is received.

Parameters
lssa pointer to an LSS slave service.
inda pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to ind.
See also
co_lss_get_rate_ind()

Definition at line 876 of file lss.c.

◆ co_lss_get_store_ind()

void co_lss_get_store_ind ( const co_lss_t lss,
co_lss_store_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked when an LSS 'store configuration' request is received.

Parameters
lssa pointer to an LSS slave service.
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_lss_set_store_ind()

Definition at line 885 of file lss.c.

◆ co_lss_set_store_ind()

void co_lss_set_store_ind ( co_lss_t lss,
co_lss_store_ind_t ind,
void *  data 
)

Sets the indication function invoked when an LSS 'store configuration' request is received.

Parameters
lssa pointer to an LSS slave service.
inda pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to ind.
See also
co_lss_get_store_ind()

Definition at line 897 of file lss.c.

◆ co_lss_get_inhibit()

co_unsigned16_t co_lss_get_inhibit ( const co_lss_t lss)

Returns the inhibit time (in multiples of 100 microseconds) of an LSS master service.

A return value of 0 means the inhibit time is disabled.

See also
co_lss_set_inhibit()

Definition at line 908 of file lss.c.

◆ co_lss_set_inhibit()

void co_lss_set_inhibit ( co_lss_t lss,
co_unsigned16_t  inhibit 
)

Sets the inhibit time between successive LSS messages of an LSS master service.

Parameters
lssa pointer to an LSS master service.
inhibitthe inhibit time (in multiples of 100 microseconds. A value of 0 disables the inhibit time.
See also
co_lss_get_inhibit()

Definition at line 916 of file lss.c.

◆ co_lss_get_timeout()

int co_lss_get_timeout ( const co_lss_t lss)

Returns the timeout (in milliseconds) of an LSS master service.

A return value of 0 means no timeout is being used.

See also
co_lss_set_timeout()

Definition at line 924 of file lss.c.

◆ co_lss_set_timeout()

void co_lss_set_timeout ( co_lss_t lss,
int  timeout 
)

Sets the timeout of an LSS master service.

Parameters
lssa pointer to an LSS master service.
timeoutthe timeout (in milliseconds). A value of 0 disables the timeout.
See also
co_lss_get_timeout()

Definition at line 932 of file lss.c.

◆ co_lss_abort_req()

void co_lss_abort_req ( co_lss_t lss)

Aborts the current LSS master request.

This function has no effect if the LSS service is idle (see co_lss_is_idle()).

Definition at line 969 of file lss.c.

◆ co_lss_switch_req()

int co_lss_switch_req ( co_lss_t lss,
co_unsigned8_t  mode 
)

Requests the 'switch state global' service.

See section 6.3.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
mode0 to switch to all slaves the LSS waiting state, 1 to switch all slaves to the LSS configuration state.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 977 of file lss.c.

◆ co_lss_switch_sel_req()

int co_lss_switch_sel_req ( co_lss_t lss,
const struct co_id id,
co_lss_cs_ind_t ind,
void *  data 
)

Requests the 'switch state selective' service.

See section 6.3.3 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
ida pointer to the LSS address of the slave to be configured.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 999 of file lss.c.

◆ co_lss_set_id_req()

int co_lss_set_id_req ( co_lss_t lss,
co_unsigned8_t  id,
co_lss_err_ind_t ind,
void *  data 
)

Requests the 'configure node-ID' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.4.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
idthe pending node-ID to be configured.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1021 of file lss.c.

◆ co_lss_set_rate_req()

int co_lss_set_rate_req ( co_lss_t lss,
co_unsigned16_t  rate,
co_lss_err_ind_t ind,
void *  data 
)

Requests the 'configure bit timing parameters' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.4.3 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
ratethe pending baudrate (in kbit/s), or 0 for automatic bit rate detection.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1053 of file lss.c.

◆ co_lss_switch_rate_req()

int co_lss_switch_rate_req ( co_lss_t lss,
int  delay 
)

Requests the 'activate bit timing parameters' service.

See section 6.4.4 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
delaythe delay (in milliseconds) before the switch and the delay after the switch during which CAN frames MUST NOT 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 1094 of file lss.c.

◆ co_lss_store_req()

int co_lss_store_req ( co_lss_t lss,
co_lss_err_ind_t ind,
void *  data 
)

Requests the 'store configuration' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.4.5 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1117 of file lss.c.

◆ co_lss_get_vendor_id_req()

int co_lss_get_vendor_id_req ( co_lss_t lss,
co_lss_lssid_ind_t ind,
void *  data 
)

Requests the 'inquire identity vendor-ID' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.5.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1142 of file lss.c.

◆ co_lss_get_product_code_req()

int co_lss_get_product_code_req ( co_lss_t lss,
co_lss_lssid_ind_t ind,
void *  data 
)

Requests the 'inquire identity product-code' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.5.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1167 of file lss.c.

◆ co_lss_get_revision_req()

int co_lss_get_revision_req ( co_lss_t lss,
co_lss_lssid_ind_t ind,
void *  data 
)

Requests the 'inquire identity revision-number' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.5.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1192 of file lss.c.

◆ co_lss_get_serial_nr_req()

int co_lss_get_serial_nr_req ( co_lss_t lss,
co_lss_lssid_ind_t ind,
void *  data 
)

Requests the 'inquire identity serial-number' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.5.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1218 of file lss.c.

◆ co_lss_get_id_req()

int co_lss_get_id_req ( co_lss_t lss,
co_lss_nid_ind_t ind,
void *  data 
)

Requests the 'inquire node-ID' service.

It is the responsibility of the LSS master to ensure that a single LSS slave is in the LSS configuration state.

See section 6.5.3 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1244 of file lss.c.

◆ co_lss_id_slave_req()

int co_lss_id_slave_req ( co_lss_t lss,
const struct co_id lo,
const struct co_id hi,
co_lss_cs_ind_t ind,
void *  data 
)

Requests the 'LSS identify remote slave' service.

The specified indication function is invoked as soon as the first slave responds.

See section 6.6.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
loa pointer to the lower bound of the LSS address.
hia pointer to the upper bound of the LSS address. The vendor-ID and product-code MUST be the same as in *lo.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1269 of file lss.c.

◆ co_lss_id_non_cfg_slave_req()

int co_lss_id_non_cfg_slave_req ( co_lss_t lss,
co_lss_cs_ind_t ind,
void *  data 
)

Requests the 'LSS identify non-configured remote slave' service.

The specified indication function is invoked as soon as the first slave responds.

See section 6.6.4 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1303 of file lss.c.

◆ co_lss_slowscan_req()

int co_lss_slowscan_req ( co_lss_t lss,
const struct co_id lo,
const struct co_id hi,
co_lss_scan_ind_t ind,
void *  data 
)

Requests the 'LSS Slowscan' service.

This service performs a binary search using the 'LSS identify remote slave' service to obtain a single LSS address, followed by the 'switch state selective' service. If the request completes with success, the identified slave is in the LSS configuration state.

See section 8.4.2 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
loa pointer to the lower bound of the LSS address.
hia pointer to the upper bound of the LSS address. The vendor-ID and product-code MUST be the same as in *lo.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1329 of file lss.c.

◆ co_lss_fastscan_req()

int co_lss_fastscan_req ( co_lss_t lss,
const struct co_id id,
const struct co_id mask,
co_lss_scan_ind_t ind,
void *  data 
)

Requests the 'LSS Fastscan' service.

If the request completes with success, the identified slave is in the LSS configuration state.

See section 6.7 in CiA 305 version 3.0.0.

Parameters
lssa pointer to an LSS master service.
ida pointer a struct containing the bits of the LSS address that are already known and can be skipped during scanning (can be NULL).
maska pointer to a struct containing the mask specifying which bits in *id are already known (can be NULL). If a bit in *mask is 1, the corresponding bit in *id is not checked.
inda pointer to the indication function (can be NULL).
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to 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 1365 of file lss.c.