mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-02-06 11:51:45 +08:00
Separated slave state machines.
This commit is contained in:
@@ -36,7 +36,8 @@ obj-m := ec_master.o
|
||||
ec_master-objs := module.o master.o device.o pdo.o sync.o fmmu_config.o \
|
||||
slave.o slave_config.o pdo_mapping.o datagram.o domain.o mailbox.o \
|
||||
canopen.o fsm_sii.o fsm_change.o fsm_coe.o fsm_coe_map.o \
|
||||
fsm_pdo_mapping.o fsm_pdo_config.o fsm_slave.o fsm_master.o xmldev.o
|
||||
fsm_pdo_mapping.o fsm_pdo_config.o fsm_slave_scan.o fsm_slave_config.o \
|
||||
fsm_master.o xmldev.o
|
||||
|
||||
ifeq (@ENABLE_EOE@,1)
|
||||
ec_master-objs += ethernet.o
|
||||
|
||||
@@ -49,7 +49,8 @@ EXTRA_DIST = \
|
||||
fsm_coe_map.c fsm_coe_map.h \
|
||||
fsm_pdo_mapping.c fsm_pdo_mapping.h \
|
||||
fsm_pdo_config.c fsm_pdo_config.h \
|
||||
fsm_slave.c fsm_slave.h \
|
||||
fsm_slave_scan.c fsm_slave_scan.h \
|
||||
fsm_slave_config.c fsm_slave_config.h \
|
||||
fsm_master.c fsm_master.h \
|
||||
globals.h \
|
||||
mailbox.c mailbox.h \
|
||||
|
||||
@@ -87,7 +87,8 @@ void ec_fsm_master_init(ec_fsm_master_t *fsm, /**< master state machine */
|
||||
fsm->tainted = 0;
|
||||
|
||||
// init sub-state-machines
|
||||
ec_fsm_slave_init(&fsm->fsm_slave, fsm->datagram);
|
||||
ec_fsm_slave_config_init(&fsm->fsm_slave_config, fsm->datagram);
|
||||
ec_fsm_slave_scan_init(&fsm->fsm_slave_scan, fsm->datagram);
|
||||
ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram);
|
||||
ec_fsm_change_init(&fsm->fsm_change, fsm->datagram);
|
||||
ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
|
||||
@@ -103,7 +104,8 @@ void ec_fsm_master_init(ec_fsm_master_t *fsm, /**< master state machine */
|
||||
void ec_fsm_master_clear(ec_fsm_master_t *fsm /**< master state machine */)
|
||||
{
|
||||
// clear sub-state machines
|
||||
ec_fsm_slave_clear(&fsm->fsm_slave);
|
||||
ec_fsm_slave_config_clear(&fsm->fsm_slave_config);
|
||||
ec_fsm_slave_scan_clear(&fsm->fsm_slave_scan);
|
||||
ec_fsm_sii_clear(&fsm->fsm_sii);
|
||||
ec_fsm_change_clear(&fsm->fsm_change);
|
||||
ec_fsm_coe_clear(&fsm->fsm_coe);
|
||||
@@ -453,8 +455,8 @@ int ec_fsm_master_action_configure(
|
||||
fsm->idle = 0;
|
||||
fsm->slave = slave;
|
||||
fsm->state = ec_fsm_master_state_configure_slave;
|
||||
ec_fsm_slave_start_conf(&fsm->fsm_slave, slave);
|
||||
ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
|
||||
ec_fsm_slave_config_start(&fsm->fsm_slave_config, slave);
|
||||
ec_fsm_slave_config_exec(&fsm->fsm_slave_config); // execute immediately
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -864,8 +866,8 @@ void ec_fsm_master_state_clear_addresses(
|
||||
// begin scanning of slaves
|
||||
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
|
||||
fsm->state = ec_fsm_master_state_scan_slaves;
|
||||
ec_fsm_slave_start_scan(&fsm->fsm_slave, fsm->slave);
|
||||
ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
|
||||
ec_fsm_slave_scan_start(&fsm->fsm_slave_scan, fsm->slave);
|
||||
ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan); // execute immediately
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -882,7 +884,7 @@ void ec_fsm_master_state_scan_slaves(
|
||||
ec_master_t *master = fsm->master;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
|
||||
if (ec_fsm_slave_exec(&fsm->fsm_slave)) // execute slave state machine
|
||||
if (ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan)) // execute slave state machine
|
||||
return;
|
||||
|
||||
#ifdef EC_EOE
|
||||
@@ -907,8 +909,8 @@ void ec_fsm_master_state_scan_slaves(
|
||||
// another slave to fetch?
|
||||
if (slave->list.next != &master->slaves) {
|
||||
fsm->slave = list_entry(slave->list.next, ec_slave_t, list);
|
||||
ec_fsm_slave_start_scan(&fsm->fsm_slave, fsm->slave);
|
||||
ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
|
||||
ec_fsm_slave_scan_start(&fsm->fsm_slave_scan, fsm->slave);
|
||||
ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan); // execute immediately
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -940,10 +942,10 @@ void ec_fsm_master_state_configure_slave(ec_fsm_master_t *fsm
|
||||
/**< master state machine */
|
||||
)
|
||||
{
|
||||
if (ec_fsm_slave_exec(&fsm->fsm_slave)) // execute slave's state machine
|
||||
if (ec_fsm_slave_config_exec(&fsm->fsm_slave_config)) // execute slave's state machine
|
||||
return;
|
||||
|
||||
if (!ec_fsm_slave_success(&fsm->fsm_slave))
|
||||
if (!ec_fsm_slave_config_success(&fsm->fsm_slave_config))
|
||||
fsm->config_error = 1;
|
||||
|
||||
// configure next slave, if necessary
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
/**
|
||||
\file
|
||||
EtherCAT finite state machines.
|
||||
EtherCAT master state machine.
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -41,42 +41,35 @@
|
||||
#ifndef __EC_FSM_MASTER__
|
||||
#define __EC_FSM_MASTER__
|
||||
|
||||
#include "globals.h"
|
||||
#include "../include/ecrt.h"
|
||||
#include "datagram.h"
|
||||
//#include "slave.h"
|
||||
#include "canopen.h"
|
||||
|
||||
#include "fsm_slave.h"
|
||||
#include "globals.h"
|
||||
#include "datagram.h"
|
||||
#include "canopen.h"
|
||||
#include "fsm_slave_config.h"
|
||||
#include "fsm_slave_scan.h"
|
||||
#include "fsm_coe_map.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* EEPROM write request.
|
||||
/** EEPROM write request.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
struct list_head list; /**< list head */
|
||||
ec_slave_t *slave; /**< EtherCAT slave */
|
||||
off_t word_offset; /**< SII address in words */
|
||||
size_t word_size; /**< data size in words */
|
||||
const uint8_t *data; /**< pointer to the data */
|
||||
ec_request_state_t state; /**< state of the request */
|
||||
}
|
||||
ec_eeprom_write_request_t;
|
||||
} ec_eeprom_write_request_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct ec_fsm_master ec_fsm_master_t; /**< \see ec_fsm_master */
|
||||
|
||||
/**
|
||||
Finite state machine of an EtherCAT master.
|
||||
*/
|
||||
|
||||
struct ec_fsm_master
|
||||
{
|
||||
/** Finite state machine of an EtherCAT master.
|
||||
*/
|
||||
struct ec_fsm_master {
|
||||
ec_master_t *master; /**< master the FSM runs on */
|
||||
ec_datagram_t *datagram; /**< datagram used in the state machine */
|
||||
unsigned int retries; /**< retries on datagram timeout. */
|
||||
@@ -96,7 +89,8 @@ struct ec_fsm_master
|
||||
off_t eeprom_index; /**< index to EEPROM write request data */
|
||||
ec_sdo_request_t *sdo_request; /**< Sdo request to process */
|
||||
|
||||
ec_fsm_slave_t fsm_slave; /**< slave state machine */
|
||||
ec_fsm_slave_config_t fsm_slave_config; /**< slave state machine */
|
||||
ec_fsm_slave_scan_t fsm_slave_scan; /**< slave state machine */
|
||||
ec_fsm_sii_t fsm_sii; /**< SII state machine */
|
||||
ec_fsm_change_t fsm_change; /**< State change state machine */
|
||||
ec_fsm_coe_t fsm_coe; /**< CoE state machine */
|
||||
|
||||
1272
master/fsm_slave.c
1272
master/fsm_slave.c
File diff suppressed because it is too large
Load Diff
824
master/fsm_slave_config.c
Normal file
824
master/fsm_slave_config.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -33,19 +33,19 @@
|
||||
|
||||
/**
|
||||
\file
|
||||
EtherCAT finite state machines.
|
||||
EtherCAT slave configuration state machine.
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef __EC_FSM_SLAVE__
|
||||
#define __EC_FSM_SLAVE__
|
||||
#ifndef __EC_FSM_SLAVE_CONFIG__
|
||||
#define __EC_FSM_SLAVE_CONFIG__
|
||||
|
||||
#include "../include/ecrt.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "../include/ecrt.h"
|
||||
#include "datagram.h"
|
||||
#include "slave.h"
|
||||
#include "fsm_sii.h"
|
||||
#include "datagram.h"
|
||||
#include "fsm_change.h"
|
||||
#include "fsm_coe.h"
|
||||
#include "fsm_pdo_mapping.h"
|
||||
@@ -53,21 +53,19 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct ec_fsm_slave ec_fsm_slave_t; /**< \see ec_fsm_slave */
|
||||
/** \see ec_fsm_slave_config */
|
||||
typedef struct ec_fsm_slave_config ec_fsm_slave_config_t;
|
||||
|
||||
/** Finite state machine of an EtherCAT slave.
|
||||
/** Finite state machine to configure an EtherCAT slave.
|
||||
*/
|
||||
struct ec_fsm_slave
|
||||
struct ec_fsm_slave_config
|
||||
{
|
||||
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
||||
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
||||
unsigned int retries; /**< Retries on datagram timeout. */
|
||||
|
||||
void (*state)(ec_fsm_slave_t *); /**< State function. */
|
||||
void (*state)(ec_fsm_slave_config_t *); /**< State function. */
|
||||
ec_sdo_data_t *sdodata; /**< Sdo configuration data. */
|
||||
uint16_t sii_offset; /**< SII offset in words. */
|
||||
|
||||
ec_fsm_sii_t fsm_sii; /**< SII state machine. */
|
||||
ec_fsm_change_t fsm_change; /**< State change state machine. */
|
||||
ec_fsm_coe_t fsm_coe; /**< CoE state machine. */
|
||||
ec_fsm_pdo_mapping_t fsm_pdo_map; /**< Pdo mapping state machine. */
|
||||
@@ -76,14 +74,13 @@ struct ec_fsm_slave
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_fsm_slave_init(ec_fsm_slave_t *, ec_datagram_t *);
|
||||
void ec_fsm_slave_clear(ec_fsm_slave_t *);
|
||||
void ec_fsm_slave_config_init(ec_fsm_slave_config_t *, ec_datagram_t *);
|
||||
void ec_fsm_slave_config_clear(ec_fsm_slave_config_t *);
|
||||
|
||||
void ec_fsm_slave_start_scan(ec_fsm_slave_t *, ec_slave_t *);
|
||||
void ec_fsm_slave_start_conf(ec_fsm_slave_t *, ec_slave_t *);
|
||||
void ec_fsm_slave_config_start(ec_fsm_slave_config_t *, ec_slave_t *);
|
||||
|
||||
int ec_fsm_slave_exec(ec_fsm_slave_t *);
|
||||
int ec_fsm_slave_success(const ec_fsm_slave_t *);
|
||||
int ec_fsm_slave_config_exec(ec_fsm_slave_config_t *);
|
||||
int ec_fsm_slave_config_success(const ec_fsm_slave_config_t *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
590
master/fsm_slave_scan.c
Normal file
590
master/fsm_slave_scan.c
Normal file
File diff suppressed because it is too large
Load Diff
86
master/fsm_slave_scan.h
Normal file
86
master/fsm_slave_scan.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH
|
||||
*
|
||||
* This file is part of the IgH EtherCAT Master.
|
||||
*
|
||||
* The IgH EtherCAT Master is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The IgH EtherCAT Master is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the IgH EtherCAT Master; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* The right to use EtherCAT Technology is granted and comes free of
|
||||
* charge under condition of compatibility of product made by
|
||||
* Licensee. People intending to distribute/sell products based on the
|
||||
* code, have to sign an agreement to guarantee that products using
|
||||
* software based on IgH EtherCAT master stay compatible with the actual
|
||||
* EtherCAT specification (which are released themselves as an open
|
||||
* standard) as the (only) precondition to have the right to use EtherCAT
|
||||
* Technology, IP and trade marks.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
\file
|
||||
EtherCAT slave scanning state machine.
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef __EC_FSM_SLAVE_SCAN__
|
||||
#define __EC_FSM_SLAVE_SCAN__
|
||||
|
||||
#include "../include/ecrt.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "datagram.h"
|
||||
#include "slave.h"
|
||||
#include "fsm_sii.h"
|
||||
#include "fsm_change.h"
|
||||
#include "fsm_coe.h"
|
||||
#include "fsm_pdo_mapping.h"
|
||||
#include "fsm_pdo_config.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** \see ec_fsm_slave_scan */
|
||||
typedef struct ec_fsm_slave_scan ec_fsm_slave_scan_t;
|
||||
|
||||
/** Finite state machine for scanning an EtherCAT slave.
|
||||
*/
|
||||
struct ec_fsm_slave_scan
|
||||
{
|
||||
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
||||
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
||||
unsigned int retries; /**< Retries on datagram timeout. */
|
||||
|
||||
void (*state)(ec_fsm_slave_scan_t *); /**< State function. */
|
||||
uint16_t sii_offset; /**< SII offset in words. */
|
||||
|
||||
ec_fsm_sii_t fsm_sii; /**< SII state machine. */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_fsm_slave_scan_init(ec_fsm_slave_scan_t *, ec_datagram_t *);
|
||||
void ec_fsm_slave_scan_clear(ec_fsm_slave_scan_t *);
|
||||
|
||||
void ec_fsm_slave_scan_start(ec_fsm_slave_scan_t *, ec_slave_t *);
|
||||
|
||||
int ec_fsm_slave_scan_exec(ec_fsm_slave_scan_t *);
|
||||
int ec_fsm_slave_scan_success(const ec_fsm_slave_scan_t *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user