merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
This commit is contained in:
parent
5ca3d24337
commit
826ae37b26
18
FEATURES
18
FEATURES
|
|
@ -29,11 +29,11 @@ General Features:
|
||||||
* Common API for Realtime-Applications in kernel- and userspace.
|
* Common API for Realtime-Applications in kernel- and userspace.
|
||||||
- Requesting and releasing masters.
|
- Requesting and releasing masters.
|
||||||
- Dynamic slave configuration, even for slaves that are offline.
|
- Dynamic slave configuration, even for slaves that are offline.
|
||||||
- Detailed configuration of the slaves' Pdos and Sdos.
|
- Detailed configuration of the slaves' PDOs and SDOs.
|
||||||
- Creation of process data domains (see below). Registration of Pdo entries
|
- Creation of process data domains (see below). Registration of PDO entries
|
||||||
for exchange within a domain.
|
for exchange within a domain.
|
||||||
- Monitoring the states of masters, slave configurations and domains.
|
- Monitoring the states of masters, slave configurations and domains.
|
||||||
- Sdo handlers for application-triggered CoE transfers (see below).
|
- SDO handlers for application-triggered CoE transfers (see below).
|
||||||
- VoE handlers for Vendor-specific mailbox protocols (see below).
|
- VoE handlers for Vendor-specific mailbox protocols (see below).
|
||||||
- Similar userspace implementation of the kernel API via a C-library.
|
- Similar userspace implementation of the kernel API via a C-library.
|
||||||
- Avoidance of unnecessary copy operations for process data.
|
- Avoidance of unnecessary copy operations for process data.
|
||||||
|
|
@ -51,17 +51,17 @@ General Features:
|
||||||
- Automatic configuration of slaves, if a application-layer state change is
|
- Automatic configuration of slaves, if a application-layer state change is
|
||||||
requested.
|
requested.
|
||||||
|
|
||||||
* Implementation of the CANopen-over-EtherCAT (CoE) mailbox protocol.
|
* Implementation of the CANopen over EtherCAT (CoE) mailbox protocol.
|
||||||
- Configuration of CoE-capable slaves.
|
- Configuration of CoE-capable slaves.
|
||||||
- Sdo information service (dictionary listing).
|
- SDO information service (dictionary listing).
|
||||||
- Sdo transfers both via the application interface and the command-line tool.
|
- SDO transfers both via the application interface and the command-line tool.
|
||||||
|
|
||||||
* Implementation of the Ethernet-over-EtherCAT (EoE) mailbox protocol.
|
* Implementation of the Ethernet over EtherCAT (EoE) mailbox protocol.
|
||||||
- Virtual network interface for any EoE-capable slave.
|
- Virtual network interface for any EoE-capable slave.
|
||||||
- Both a switched and a routed EoE network architecture is natively supported
|
- Both a switched and a routed EoE network architecture is natively supported
|
||||||
and configurable with standard tools.
|
and configurable with standard tools.
|
||||||
|
|
||||||
* Implementation of the Vendor-specific-over-EtherCAT (VoE) mailbox protocol.
|
* Implementation of the Vendor specific over EtherCAT (VoE) mailbox protocol.
|
||||||
- Communication with vendor-specific mailbox protocols via the API.
|
- Communication with vendor-specific mailbox protocols via the API.
|
||||||
|
|
||||||
* Userspace command-line tool 'ethercat'.
|
* Userspace command-line tool 'ethercat'.
|
||||||
|
|
@ -69,7 +69,7 @@ General Features:
|
||||||
- Reading/Writing alias addresses.
|
- Reading/Writing alias addresses.
|
||||||
- Listing slave configurations.
|
- Listing slave configurations.
|
||||||
- Viewing process data.
|
- Viewing process data.
|
||||||
- Sdo download/upload; listing Sdo dictionaries.
|
- SDO download/upload; listing SDO dictionaries.
|
||||||
- Access to slave registers.
|
- Access to slave registers.
|
||||||
- Slave SII (EEPROM) access.
|
- Slave SII (EEPROM) access.
|
||||||
- Controlling application-layer states.
|
- Controlling application-layer states.
|
||||||
|
|
|
||||||
44
NEWS
44
NEWS
|
|
@ -34,6 +34,8 @@ Changes since 1.4.0-rc3:
|
||||||
frame.
|
frame.
|
||||||
* Modified licence headers to avoid conflicts with the GPL.
|
* Modified licence headers to avoid conflicts with the GPL.
|
||||||
* Restricted licence to GPLv2 only.
|
* Restricted licence to GPLv2 only.
|
||||||
|
* Fixed spelling of 'PDO', 'SDO' (all uppercase) and 'xx over EtherCAT'
|
||||||
|
(without hyphens).
|
||||||
|
|
||||||
Changes in 1.4.0-rc3:
|
Changes in 1.4.0-rc3:
|
||||||
|
|
||||||
|
|
@ -42,7 +44,7 @@ Changes in 1.4.0-rc3:
|
||||||
semaphore was not released.
|
semaphore was not released.
|
||||||
* Minor fix in 'slaves' command that fixed duplicate display of supported
|
* Minor fix in 'slaves' command that fixed duplicate display of supported
|
||||||
mailbox protocols.
|
mailbox protocols.
|
||||||
* The Sdo Information Service is only queried, if the slave has the
|
* The SDO Information Service is only queried, if the slave has the
|
||||||
corresponding SII bit set.
|
corresponding SII bit set.
|
||||||
* Added some missing header files in the command-line-tool code.
|
* Added some missing header files in the command-line-tool code.
|
||||||
* Removed unstable e100, forcedeth, and r8169 drivers.
|
* Removed unstable e100, forcedeth, and r8169 drivers.
|
||||||
|
|
@ -73,18 +75,18 @@ Changes in version 1.4.0-rc1:
|
||||||
offers the possibility to use a shared-memory region. Therefore,
|
offers the possibility to use a shared-memory region. Therefore,
|
||||||
added the domain methods ecrt_domain_size() and
|
added the domain methods ecrt_domain_size() and
|
||||||
ecrt_domain_external_memory().
|
ecrt_domain_external_memory().
|
||||||
- Pdo entry registration functions do not return a process data pointer,
|
- PDO entry registration functions do not return a process data pointer,
|
||||||
but an offset in the domain's process data. In addition, an optional bit
|
but an offset in the domain's process data. In addition, an optional bit
|
||||||
position can be requested. This was necessary for the external domain
|
position can be requested. This was necessary for the external domain
|
||||||
memory. An additional advantage is, that the returned offset is
|
memory. An additional advantage is, that the returned offset is
|
||||||
immediately valid. If the domain's process data is allocated internally,
|
immediately valid. If the domain's process data is allocated internally,
|
||||||
the start address can be retrieved with ecrt_domain_data().
|
the start address can be retrieved with ecrt_domain_data().
|
||||||
- Replaced ecrt_slave_pdo_mapping/add/clear() with
|
- Replaced ecrt_slave_pdo_mapping/add/clear() with
|
||||||
ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
|
ecrt_slave_config_pdo_assign_add() to add a PDO to a sync manager's PDO
|
||||||
assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
|
assignment and ecrt_slave_config_pdo_mapping_add() to add a PDO entry to a
|
||||||
Pdo's mapping. ecrt_slave_config_pdos() is a convenience function
|
PDO's mapping. ecrt_slave_config_pdos() is a convenience function
|
||||||
for both, that uses the new data types ec_pdo_info_t and
|
for both, that uses the new data types ec_pdo_info_t and
|
||||||
ec_pdo_entry_info_t. Pdo entries, that are mapped with these functions
|
ec_pdo_entry_info_t. PDO entries, that are mapped with these functions
|
||||||
can now immediately be registered, even if the bus is offline.
|
can now immediately be registered, even if the bus is offline.
|
||||||
- Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and
|
- Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and
|
||||||
ec_master_state_t, respectively. Renamed ecrt_master_get_status() to
|
ec_master_state_t, respectively. Renamed ecrt_master_get_status() to
|
||||||
|
|
@ -92,15 +94,15 @@ Changes in version 1.4.0-rc1:
|
||||||
- Added ec_domain_state_t and ec_wc_state_t for a new output parameter
|
- Added ec_domain_state_t and ec_wc_state_t for a new output parameter
|
||||||
of ecrt_domain_state(). The domain state object does now contain
|
of ecrt_domain_state(). The domain state object does now contain
|
||||||
information, if the process data was exchanged completely.
|
information, if the process data was exchanged completely.
|
||||||
- Former "Pdo registration" meant Pdo entry registration in fact, therefore
|
- Former "PDO registration" meant PDO entry registration in fact, therefore
|
||||||
renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
||||||
to ecrt_slave_config_reg_pdo_entry().
|
to ecrt_slave_config_reg_pdo_entry().
|
||||||
- Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
- Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
||||||
be reached by specifying an explicit Pdo assignment/mapping and
|
be reached by specifying an explicit PDO assignment/mapping and
|
||||||
registering the mapped Pdo entries.
|
registering the mapped PDO entries.
|
||||||
- Added an Sdo access interface, working with Sdo requests. These can be
|
- Added an SDO access interface, working with SDO requests. These can be
|
||||||
scheduled for reading and writing during realtime operation.
|
scheduled for reading and writing during realtime operation.
|
||||||
- Exported ecrt_slave_config_sdo(), the generic Sdo configuration function.
|
- Exported ecrt_slave_config_sdo(), the generic SDO configuration function.
|
||||||
- Removed the bus_state and bus_tainted flags from ec_master_state_t.
|
- Removed the bus_state and bus_tainted flags from ec_master_state_t.
|
||||||
* Device interface changes:
|
* Device interface changes:
|
||||||
- Moved device output parameter of ecdev_offer() to return value.
|
- Moved device output parameter of ecdev_offer() to return value.
|
||||||
|
|
@ -113,10 +115,10 @@ Changes in version 1.4.0-rc1:
|
||||||
- Set the master's debug level.
|
- Set the master's debug level.
|
||||||
- Show domain information.
|
- Show domain information.
|
||||||
- Show master information.
|
- Show master information.
|
||||||
- List Pdo assignment/mapping.
|
- List PDO assignment/mapping.
|
||||||
- Write an Sdo entry.
|
- Write an SDO entry.
|
||||||
- List Sdo dictionaries.
|
- List SDO dictionaries.
|
||||||
- Read an Sdo entry.
|
- Read an SDO entry.
|
||||||
- Output a slave's SII contents.
|
- Output a slave's SII contents.
|
||||||
- Write slave's SII contents.
|
- Write slave's SII contents.
|
||||||
- Show slaves.
|
- Show slaves.
|
||||||
|
|
@ -125,11 +127,11 @@ Changes in version 1.4.0-rc1:
|
||||||
* Removed include/ecdb.h.
|
* Removed include/ecdb.h.
|
||||||
* Using the timestamp counter is now optional (configure --enable-cycles),
|
* Using the timestamp counter is now optional (configure --enable-cycles),
|
||||||
because it is only available on Intel architectures.
|
because it is only available on Intel architectures.
|
||||||
* Sdo dictionaries will now also be fetched in operation mode.
|
* SDO dictionaries will now also be fetched in operation mode.
|
||||||
* SII write requests will now also be processed in operation mode.
|
* SII write requests will now also be processed in operation mode.
|
||||||
* Mapping of Pdo entries is now supported.
|
* Mapping of PDO entries is now supported.
|
||||||
* Current Pdo assignment/mapping is now read via CoE during bus scan, using
|
* Current PDO assignment/mapping is now read via CoE during bus scan, using
|
||||||
direct Sdo access, independent of the dictionary.
|
direct SDO access, independent of the dictionary.
|
||||||
* Network driver news:
|
* Network driver news:
|
||||||
- Added 8139too driver for kernel 2.6.22, thanks to Erwin Burgstaller.
|
- Added 8139too driver for kernel 2.6.22, thanks to Erwin Burgstaller.
|
||||||
- Added 8139too driver for kernel 2.6.23, thanks to Richard Hacker.
|
- Added 8139too driver for kernel 2.6.23, thanks to Richard Hacker.
|
||||||
|
|
@ -151,8 +153,8 @@ Changes in version 1.4.0-rc1:
|
||||||
* Added support for slaves that do not support the LRW datagram type. Separate
|
* Added support for slaves that do not support the LRW datagram type. Separate
|
||||||
domains have to be used for inputs and output.
|
domains have to be used for inputs and output.
|
||||||
* CoE implementation:
|
* CoE implementation:
|
||||||
- Use expedites transfer type for Sdos <= 4 byte (thanks to J. Mohre).
|
- Use expedites transfer type for SDOs <= 4 byte (thanks to J. Mohre).
|
||||||
- Allow gaps in Pdo mapping (thanks to R. Roesch).
|
- Allow gaps in PDO mapping (thanks to R. Roesch).
|
||||||
- Added some transfer timeouts.
|
- Added some transfer timeouts.
|
||||||
- Ansynchronous handling of Emergency requests.
|
- Ansynchronous handling of Emergency requests.
|
||||||
- Bugfixes.
|
- Bugfixes.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
This file shall give additional information on how to set up a network
|
This file shall give additional information on how to set up a network
|
||||||
environment with Ethernet-over-EtherCAT devices.
|
environment with Ethernet over EtherCAT devices.
|
||||||
|
|
||||||
A virtual network interface will appear for every EoE-capable slave. The
|
A virtual network interface will appear for every EoE-capable slave. The
|
||||||
interface naming scheme is either eoeXsY, where X is the master index and Y is
|
interface naming scheme is either eoeXsY, where X is the master index and Y is
|
||||||
|
|
|
||||||
7
TODO
7
TODO
|
|
@ -11,8 +11,8 @@ vim: spelllang=en spell
|
||||||
Version 1.5.0:
|
Version 1.5.0:
|
||||||
|
|
||||||
* Remove ecrt_domain_state().
|
* Remove ecrt_domain_state().
|
||||||
* Segmented Sdo downloads.
|
* Segmented SDO downloads.
|
||||||
* Implement Sdo handlers in userspace library.
|
* Implement SDO handlers in userspace library.
|
||||||
* Clear slave list on link down.
|
* Clear slave list on link down.
|
||||||
* Check force_config flag before error.
|
* Check force_config flag before error.
|
||||||
* Remove allow_scanning flag.
|
* Remove allow_scanning flag.
|
||||||
|
|
@ -20,11 +20,10 @@ Version 1.5.0:
|
||||||
* Improve application-triggered SDO transfers by moving the statemachine into
|
* Improve application-triggered SDO transfers by moving the statemachine into
|
||||||
the SDO handlers.
|
the SDO handlers.
|
||||||
* External memory for SDO transfers.
|
* External memory for SDO transfers.
|
||||||
* Bus information via userspace library (slaves, sync managers, pdos, entries).
|
* Bus information via userspace library (slaves, sync managers, PDOs, entries).
|
||||||
* C++ implementation of the library.
|
* C++ implementation of the library.
|
||||||
* Distributed clocks.
|
* Distributed clocks.
|
||||||
* Bus simulator interface.
|
* Bus simulator interface.
|
||||||
* Pdo -> PDO. Sdo -> SDO "-over-"
|
|
||||||
|
|
||||||
Future issues:
|
Future issues:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ if test "x${debugring}" = "x1"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Ethernet-over-EtherCAT support
|
# Ethernet over EtherCAT support
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
AC_ARG_ENABLE([eoe],
|
AC_ARG_ENABLE([eoe],
|
||||||
|
|
|
||||||
|
|
@ -227,19 +227,19 @@ EtherCAT functionality (see chap.~\ref{chap:api}).
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\item CANopen-over-EtherCAT (CoE)
|
\item CANopen over EtherCAT (CoE)
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
|
||||||
\item Sdo upload, download and information service.
|
\item SDO upload, download and information service.
|
||||||
|
|
||||||
\item Slave configuration via Sdos.
|
\item Slave configuration via SDOs.
|
||||||
|
|
||||||
\item Sdo access from userspace and from the application.
|
\item SDO access from userspace and from the application.
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\item Ethernet-over-EtherCAT (EoE)
|
\item Ethernet over EtherCAT (EoE)
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
|
||||||
|
|
@ -254,12 +254,12 @@ EtherCAT functionality (see chap.~\ref{chap:api}).
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
|
||||||
\item Showing the current bus with slaves, Pdos and Sdos.
|
\item Showing the current bus with slaves, PDOs and SDOs.
|
||||||
\item Showing the bus configuration.
|
\item Showing the bus configuration.
|
||||||
\item Showing domains and process data.
|
\item Showing domains and process data.
|
||||||
\item Setting the master's debug level.
|
\item Setting the master's debug level.
|
||||||
\item Writing alias addresses.
|
\item Writing alias addresses.
|
||||||
\item Sdo uploading/downloading.
|
\item SDO uploading/downloading.
|
||||||
\item Reading/writing a slave's SII.
|
\item Reading/writing a slave's SII.
|
||||||
\item Setting slave states.
|
\item Setting slave states.
|
||||||
\item Generate slave description XML.
|
\item Generate slave description XML.
|
||||||
|
|
@ -457,7 +457,7 @@ possible until then.
|
||||||
an Ethernet device, but is not requested by any application yet. The master
|
an Ethernet device, but is not requested by any application yet. The master
|
||||||
runs its state machine (see sec.~\ref{sec:fsm-master}), that automatically
|
runs its state machine (see sec.~\ref{sec:fsm-master}), that automatically
|
||||||
scans the bus for slaves and executes pending operations from the userspace
|
scans the bus for slaves and executes pending operations from the userspace
|
||||||
interface (for example Sdo access). The command-line tool can be used to
|
interface (for example SDO access). The command-line tool can be used to
|
||||||
access the bus, but there is no process data exchange because of the missing
|
access the bus, but there is no process data exchange because of the missing
|
||||||
bus configuration.
|
bus configuration.
|
||||||
|
|
||||||
|
|
@ -478,12 +478,12 @@ process data.
|
||||||
\index{Process data}
|
\index{Process data}
|
||||||
|
|
||||||
Slaves offer their inputs and outputs by presenting the master so-called
|
Slaves offer their inputs and outputs by presenting the master so-called
|
||||||
``Process Data Objects'' (Pdos\index{Pdo}). The available Pdos can be either
|
``Process Data Objects'' (PDOs\index{PDO}). The available PDOs can be either
|
||||||
determined by reading out the slave's TXPDO and RXPDO SII categories from the
|
determined by reading out the slave's TXPDO and RXPDO SII categories from the
|
||||||
E$^2$PROM (in case of fixed Pdos) or by reading out the appropriate CoE
|
E$^2$PROM (in case of fixed PDOs) or by reading out the appropriate CoE
|
||||||
objects (see sec.~\ref{sec:coe}), if available. The application can register
|
objects (see sec.~\ref{sec:coe}), if available. The application can register
|
||||||
the Pdos' entries for exchange during cyclic operation. The sum of all
|
the PDOs' entries for exchange during cyclic operation. The sum of all
|
||||||
registered Pdo entries defines the ``process data image'', which is exchanged
|
registered PDO entries defines the ``process data image'', which is exchanged
|
||||||
via datagrams with ``logical'' memory access (like LWR, LRD or LRW) introduced
|
via datagrams with ``logical'' memory access (like LWR, LRD or LRW) introduced
|
||||||
in~\cite[sec.~5.4]{dlspec}.
|
in~\cite[sec.~5.4]{dlspec}.
|
||||||
|
|
||||||
|
|
@ -491,8 +491,8 @@ in~\cite[sec.~5.4]{dlspec}.
|
||||||
\index{Domain}
|
\index{Domain}
|
||||||
|
|
||||||
The process data image can be easily managed by creating so-called
|
The process data image can be easily managed by creating so-called
|
||||||
``domains'', which allow grouped Pdo exchange. They also take care of managing
|
``domains'', which allow grouped PDO exchange. They also take care of managing
|
||||||
the datagram structures needed to exchange the Pdos. Domains are mandatory for
|
the datagram structures needed to exchange the PDOs. Domains are mandatory for
|
||||||
process data exchange, so there has to be at least one. They were introduced
|
process data exchange, so there has to be at least one. They were introduced
|
||||||
for the following reasons:
|
for the following reasons:
|
||||||
|
|
||||||
|
|
@ -506,10 +506,10 @@ image exceeds this limit, multiple frames have to be sent, and the image has
|
||||||
to be partitioned for the use of multiple datagrams. A domain manages this
|
to be partitioned for the use of multiple datagrams. A domain manages this
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
\item Not every Pdo has to be exchanged with the same frequency: The values of
|
\item Not every PDO has to be exchanged with the same frequency: The values of
|
||||||
Pdos can vary slowly over time (for example temperature values), so exchanging
|
PDOs can vary slowly over time (for example temperature values), so exchanging
|
||||||
them with a high frequency would just waste bus bandwidth. For this reason,
|
them with a high frequency would just waste bus bandwidth. For this reason,
|
||||||
multiple domains can be created, to group different Pdos and so allow separate
|
multiple domains can be created, to group different PDOs and so allow separate
|
||||||
exchange.
|
exchange.
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
@ -521,21 +521,21 @@ limited by the slaves.
|
||||||
\paragraph{FMMU Configuration}
|
\paragraph{FMMU Configuration}
|
||||||
\index{FMMU!Configuration}
|
\index{FMMU!Configuration}
|
||||||
|
|
||||||
An application can register Pdo entries for exchange. Every Pdo entry and its
|
An application can register PDO entries for exchange. Every PDO entry and its
|
||||||
parent Pdo is part of a memory area in the slave's physical memory, that is
|
parent PDO is part of a memory area in the slave's physical memory, that is
|
||||||
protected by a sync manager \cite[sec.~6.7]{dlspec} for synchronized access.
|
protected by a sync manager \cite[sec.~6.7]{dlspec} for synchronized access.
|
||||||
In order to make a sync manager react on a datagram accessing its memory, it
|
In order to make a sync manager react on a datagram accessing its memory, it
|
||||||
is necessary to access the last byte covered by the sync manager. Otherwise
|
is necessary to access the last byte covered by the sync manager. Otherwise
|
||||||
the sync manager will not react on the datagram and no data will be exchanged.
|
the sync manager will not react on the datagram and no data will be exchanged.
|
||||||
That is why the whole synchronized memory area has to be included into the
|
That is why the whole synchronized memory area has to be included into the
|
||||||
process data image: For example, if a certain Pdo entry of a slave is
|
process data image: For example, if a certain PDO entry of a slave is
|
||||||
registered for exchange with a certain domain, one FMMU will be configured to
|
registered for exchange with a certain domain, one FMMU will be configured to
|
||||||
map the complete sync-manager-protected memory, the Pdo entry resides in. If a
|
map the complete sync-manager-protected memory, the PDO entry resides in. If a
|
||||||
second Pdo entry of the same slave is registered for process data exchange
|
second PDO entry of the same slave is registered for process data exchange
|
||||||
within the same domain, and it resides in the same sync-manager-protected
|
within the same domain, and it resides in the same sync-manager-protected
|
||||||
memory as the first one, the FMMU configuration is not altered, because the
|
memory as the first one, the FMMU configuration is not altered, because the
|
||||||
desired memory is already part of the domain's process data image. If the
|
desired memory is already part of the domain's process data image. If the
|
||||||
second Pdo entry would belong to another sync-manager-protected area, this
|
second PDO entry would belong to another sync-manager-protected area, this
|
||||||
complete area would also be included into the domains process data image.
|
complete area would also be included into the domains process data image.
|
||||||
|
|
||||||
Figure~\ref{fig:fmmus} gives an overview, how FMMUs are configured to map
|
Figure~\ref{fig:fmmus} gives an overview, how FMMUs are configured to map
|
||||||
|
|
@ -559,11 +559,11 @@ physical memory to logical process data images.
|
||||||
% Interface version
|
% Interface version
|
||||||
% Master Requesting and Releasing
|
% Master Requesting and Releasing
|
||||||
% Master Locking
|
% Master Locking
|
||||||
% Configuring Pdo assignment and mapping
|
% Configuring PDO assignment and mapping
|
||||||
% Domains (memory)
|
% Domains (memory)
|
||||||
% Pdo entry registration
|
% PDO entry registration
|
||||||
% Sdo configuration
|
% SDO configuration
|
||||||
% Sdo access
|
% SDO access
|
||||||
|
|
||||||
The application interface provides functions and data structures for
|
The application interface provides functions and data structures for
|
||||||
applications to access an EtherCAT master. The complete documentation of the
|
applications to access an EtherCAT master. The complete documentation of the
|
||||||
|
|
@ -580,7 +580,7 @@ Every application should use the master in two steps:
|
||||||
\begin{description}
|
\begin{description}
|
||||||
|
|
||||||
\item[Configuration] The master is requested and the configuration is applied.
|
\item[Configuration] The master is requested and the configuration is applied.
|
||||||
For example, domains are created, slaves are configured and Pdo entries are
|
For example, domains are created, slaves are configured and PDO entries are
|
||||||
registered (see sec.~\ref{sec:masterconfig}).
|
registered (see sec.~\ref{sec:masterconfig}).
|
||||||
|
|
||||||
\item[Operation] Cyclic code is run and process data are exchanged (see
|
\item[Operation] Cyclic code is run and process data are exchanged (see
|
||||||
|
|
@ -1470,7 +1470,7 @@ monitored. If a slave is not in the state it supposed to be, the slave is
|
||||||
|
|
||||||
\item[Request handling] Requests (either originating from the application or
|
\item[Request handling] Requests (either originating from the application or
|
||||||
from external sources) are handled. A request is a job that the master shall
|
from external sources) are handled. A request is a job that the master shall
|
||||||
process asynchronously, for example an SII access, Sdo access, or similar.
|
process asynchronously, for example an SII access, SDO access, or similar.
|
||||||
|
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
|
|
@ -1512,10 +1512,10 @@ image memory.
|
||||||
|
|
||||||
\item[PREOP] If the slave supports CoE, it is set to PREOP state using the
|
\item[PREOP] If the slave supports CoE, it is set to PREOP state using the
|
||||||
State change FSM (see sec.~\ref{sec:fsm-change}) to enable mailbox
|
State change FSM (see sec.~\ref{sec:fsm-change}) to enable mailbox
|
||||||
communication and read the Pdo configuration via CoE.
|
communication and read the PDO configuration via CoE.
|
||||||
|
|
||||||
\item[Pdos] The Pdos are read via CoE (if supported) using the Pdo Reading FSM
|
\item[PDOs] The PDOs are read via CoE (if supported) using the PDO Reading FSM
|
||||||
(see sec.~\ref{sec:fsm-pdo}). If this is successful, the Pdo information from
|
(see sec.~\ref{sec:fsm-pdo}). If this is successful, the PDO information from
|
||||||
the SII (if any) is overwritten.
|
the SII (if any) is overwritten.
|
||||||
|
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
@ -1554,18 +1554,18 @@ is skipped.
|
||||||
\item[PREOP] The state change FSM is used to bring the slave to PREOP state.
|
\item[PREOP] The state change FSM is used to bring the slave to PREOP state.
|
||||||
If this is the requested state, the state machine is finished.
|
If this is the requested state, the state machine is finished.
|
||||||
|
|
||||||
\item[Sdo Configuration] If there is a slave configuration attached (see
|
\item[SDO Configuration] If there is a slave configuration attached (see
|
||||||
sec.~\ref{sec:masterconfig}), and there are any Sdo configurations are
|
sec.~\ref{sec:masterconfig}), and there are any SDO configurations are
|
||||||
provided by the application, these are sent to the slave.
|
provided by the application, these are sent to the slave.
|
||||||
|
|
||||||
\item[Pdo Configuration] The Pdo configuration state machine is executed to
|
\item[PDO Configuration] The PDO configuration state machine is executed to
|
||||||
apply all necessary Pdo configurations.
|
apply all necessary PDO configurations.
|
||||||
|
|
||||||
\item[Pdo Sync Manager Configuration] If any Pdo sync managers exist, they are
|
\item[PDO Sync Manager Configuration] If any PDO sync managers exist, they are
|
||||||
configured.
|
configured.
|
||||||
|
|
||||||
\item[FMMU Configuration] If there are FMMUs configurations supplied by the
|
\item[FMMU Configuration] If there are FMMUs configurations supplied by the
|
||||||
application (i.\,e.\ if the application registered Pdo entries), they are
|
application (i.\,e.\ if the application registered PDO entries), they are
|
||||||
applied.
|
applied.
|
||||||
|
|
||||||
\item[SAFEOP] The state change FSM is used to bring the slave to SAFEOP state.
|
\item[SAFEOP] The state change FSM is used to bring the slave to SAFEOP state.
|
||||||
|
|
@ -1677,60 +1677,60 @@ this state to avoid that another write operation is issued too early.
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\section{The Pdo State Machines}
|
\section{The PDO State Machines}
|
||||||
\label{sec:fsm-pdo}
|
\label{sec:fsm-pdo}
|
||||||
\index{FSM!Pdo}
|
\index{FSM!PDO}
|
||||||
|
|
||||||
The Pdo state machines are a set of state machines that read or write the Pdo
|
The PDO state machines are a set of state machines that read or write the PDO
|
||||||
assignment and the Pdo mapping via the ``CoE Communication Area'' described in
|
assignment and the PDO mapping via the ``CoE Communication Area'' described in
|
||||||
\cite[sec. 5.6.7.4]{alspec}. For the object access, the CANopen-over-EtherCAT
|
\cite[sec. 5.6.7.4]{alspec}. For the object access, the CANopen over EtherCAT
|
||||||
access primitives are used (see sec.~\ref{sec:coe}), so the slave must support
|
access primitives are used (see sec.~\ref{sec:coe}), so the slave must support
|
||||||
the CoE mailbox protocol.
|
the CoE mailbox protocol.
|
||||||
|
|
||||||
\paragraph{Pdo Reading FSM} This state machine (fig.~\ref{fig:fsm-pdo-read})
|
\paragraph{PDO Reading FSM} This state machine (fig.~\ref{fig:fsm-pdo-read})
|
||||||
has the purpose to read the complete Pdo configuration of a slave. It reads
|
has the purpose to read the complete PDO configuration of a slave. It reads
|
||||||
the Pdo assignment for each Sync Manager and uses the Pdo Entry Reading FSM
|
the PDO assignment for each Sync Manager and uses the PDO Entry Reading FSM
|
||||||
(fig.~\ref{fig:fsm-pdo-entry-read}) to read the mapping for each assigned Pdo.
|
(fig.~\ref{fig:fsm-pdo-entry-read}) to read the mapping for each assigned PDO.
|
||||||
|
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_read}
|
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_read}
|
||||||
\caption{Transition Diagram of the Pdo Reading State Machine}
|
\caption{Transition Diagram of the PDO Reading State Machine}
|
||||||
\label{fig:fsm-pdo-read}
|
\label{fig:fsm-pdo-read}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
Basically it reads the every Sync manager's Pdo assignment Sdo's
|
Basically it reads the every Sync manager's PDO assignment SDO's
|
||||||
(\lstinline+0x1C1x+) number of elements to determine the number of assigned
|
(\lstinline+0x1C1x+) number of elements to determine the number of assigned
|
||||||
Pdos for this sync manager and then reads out the subindices of the Sdo to get
|
PDOs for this sync manager and then reads out the subindices of the SDO to get
|
||||||
the assigned Pdo's indices. When a Pdo index is read, the Pdo Entry Reading
|
the assigned PDO's indices. When a PDO index is read, the PDO Entry Reading
|
||||||
FSM is executed to read the Pdo's mapped Pdo entries.
|
FSM is executed to read the PDO's mapped PDO entries.
|
||||||
|
|
||||||
\paragraph{Pdo Entry Reading FSM} This state machine
|
\paragraph{PDO Entry Reading FSM} This state machine
|
||||||
(fig.~\ref{fig:fsm-pdo-entry-read}) reads the Pdo mapping (the Pdo entries) of
|
(fig.~\ref{fig:fsm-pdo-entry-read}) reads the PDO mapping (the PDO entries) of
|
||||||
a Pdo. It reads the respective mapping Sdo (\lstinline+0x1600+ --
|
a PDO. It reads the respective mapping SDO (\lstinline+0x1600+ --
|
||||||
\lstinline+0x17ff+, or \lstinline+0x1a00+ -- \lstinline+0x1bff+) for the given
|
\lstinline+0x17ff+, or \lstinline+0x1a00+ -- \lstinline+0x1bff+) for the given
|
||||||
Pdo by reading first the subindex zero (number of elements) to determine the
|
PDO by reading first the subindex zero (number of elements) to determine the
|
||||||
number of mapped Pdo entries. After that, each subindex is read to get the
|
number of mapped PDO entries. After that, each subindex is read to get the
|
||||||
mapped Pdo entry index, subindex and bit size.
|
mapped PDO entry index, subindex and bit size.
|
||||||
|
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_entry_read}
|
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_entry_read}
|
||||||
\caption{Transition Diagram of the Pdo Entry Reading State Machine}
|
\caption{Transition Diagram of the PDO Entry Reading State Machine}
|
||||||
\label{fig:fsm-pdo-entry-read}
|
\label{fig:fsm-pdo-entry-read}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=.9\textwidth]{graphs/fsm_pdo_conf}
|
\includegraphics[width=.9\textwidth]{graphs/fsm_pdo_conf}
|
||||||
\caption{Transition Diagram of the Pdo Configuration State Machine}
|
\caption{Transition Diagram of the PDO Configuration State Machine}
|
||||||
\label{fig:fsm-pdo-conf}
|
\label{fig:fsm-pdo-conf}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_entry_conf}
|
\includegraphics[width=.4\textwidth]{graphs/fsm_pdo_entry_conf}
|
||||||
\caption{Transition Diagram of the Pdo Entry Configuration State Machine}
|
\caption{Transition Diagram of the PDO Entry Configuration State Machine}
|
||||||
\label{fig:fsm-pdo-entry-conf}
|
\label{fig:fsm-pdo-entry-conf}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
|
|
@ -1744,12 +1744,12 @@ protocols. See the below section for details.
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\section{Ethernet-over-EtherCAT (EoE)}
|
\section{Ethernet over EtherCAT (EoE)}
|
||||||
\label{sec:eoe}
|
\label{sec:eoe}
|
||||||
\index{EoE}
|
\index{EoE}
|
||||||
|
|
||||||
The EtherCAT master implements the
|
The EtherCAT master implements the
|
||||||
Ethernet-over-EtherCAT\nomenclature{EoE}{Ethernet-over-EtherCAT, Mailbox
|
Ethernet over EtherCAT\nomenclature{EoE}{Ethernet over EtherCAT, Mailbox
|
||||||
Protocol} mailbox protocol~\cite[sec.~5.7]{alspec} to enable the tunneling of
|
Protocol} mailbox protocol~\cite[sec.~5.7]{alspec} to enable the tunneling of
|
||||||
Ethernet frames to special slaves, that can either have physical Ethernet
|
Ethernet frames to special slaves, that can either have physical Ethernet
|
||||||
ports to forward the frames to, or have an own IP stack to receive the frames.
|
ports to forward the frames to, or have an own IP stack to receive the frames.
|
||||||
|
|
@ -1903,11 +1903,11 @@ application-layer state is automatically set to OP.
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\section{CANopen-over-EtherCAT (CoE)}
|
\section{CANopen over EtherCAT (CoE)}
|
||||||
\label{sec:coe}
|
\label{sec:coe}
|
||||||
\index{CoE}
|
\index{CoE}
|
||||||
|
|
||||||
The CANopen-over-EtherCAT\nomenclature{CoE}{CANopen-over-EtherCAT, Mailbox
|
The CANopen over EtherCAT\nomenclature{CoE}{CANopen over EtherCAT, Mailbox
|
||||||
Protocol} protocol~\cite[sec.~5.6]{alspec} is used to configure slaves and
|
Protocol} protocol~\cite[sec.~5.6]{alspec} is used to configure slaves and
|
||||||
exchange data objects on application level.
|
exchange data objects on application level.
|
||||||
|
|
||||||
|
|
@ -1916,23 +1916,23 @@ exchange data objects on application level.
|
||||||
% Download / Upload
|
% Download / Upload
|
||||||
% Expedited / Normal
|
% Expedited / Normal
|
||||||
% Segmenting
|
% Segmenting
|
||||||
% Sdo Info Services
|
% SDO Info Services
|
||||||
%
|
%
|
||||||
|
|
||||||
\ldots
|
\ldots
|
||||||
|
|
||||||
\paragraph{Sdo Download State Machine}
|
\paragraph{SDO Download State Machine}
|
||||||
|
|
||||||
The best time to apply Sdo configurations is during the slave's PREOP state,
|
The best time to apply SDO configurations is during the slave's PREOP state,
|
||||||
because mailbox communication is already possible and slave's application will
|
because mailbox communication is already possible and slave's application will
|
||||||
start with updating input data in the succeeding SAFEOP state. Therefore the
|
start with updating input data in the succeeding SAFEOP state. Therefore the
|
||||||
Sdo configuration has to be part of the slave configuration state machine (see
|
SDO configuration has to be part of the slave configuration state machine (see
|
||||||
sec.~\ref{sec:fsm-conf}): It is implemented via an Sdo download state machine,
|
sec.~\ref{sec:fsm-conf}): It is implemented via an SDO download state machine,
|
||||||
that is executed just before entering the slave's SAFEOP state. In this way,
|
that is executed just before entering the slave's SAFEOP state. In this way,
|
||||||
it is guaranteed that the Sdo configurations are applied each time, the slave
|
it is guaranteed that the SDO configurations are applied each time, the slave
|
||||||
is reconfigured.
|
is reconfigured.
|
||||||
|
|
||||||
The transition diagram of the Sdo Download state machine can be seen
|
The transition diagram of the SDO Download state machine can be seen
|
||||||
in figure~\ref{fig:fsm-coedown}.
|
in figure~\ref{fig:fsm-coedown}.
|
||||||
|
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
|
|
@ -1946,7 +1946,7 @@ in figure~\ref{fig:fsm-coedown}.
|
||||||
|
|
||||||
\begin{description}
|
\begin{description}
|
||||||
\item[START] The beginning state of the CoE download state
|
\item[START] The beginning state of the CoE download state
|
||||||
machine. The ``Sdo Download Normal Request'' mailbox command is
|
machine. The ``SDO Download Normal Request'' mailbox command is
|
||||||
sent. $\rightarrow$~REQUEST
|
sent. $\rightarrow$~REQUEST
|
||||||
|
|
||||||
\item[REQUEST] It is checked, if the CoE download request has been
|
\item[REQUEST] It is checked, if the CoE download request has been
|
||||||
|
|
@ -1955,7 +1955,7 @@ in figure~\ref{fig:fsm-coedown}.
|
||||||
|
|
||||||
\item[CHECK] If no mailbox data is available, the timer is checked.
|
\item[CHECK] If no mailbox data is available, the timer is checked.
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item If it timed out, the Sdo download is aborted.
|
\item If it timed out, the SDO download is aborted.
|
||||||
$\rightarrow$~ERROR
|
$\rightarrow$~ERROR
|
||||||
\item Otherwise, the mailbox is queried again.
|
\item Otherwise, the mailbox is queried again.
|
||||||
$\rightarrow$~CHECK
|
$\rightarrow$~CHECK
|
||||||
|
|
@ -1965,22 +1965,22 @@ in figure~\ref{fig:fsm-coedown}.
|
||||||
$\rightarrow$~RESPONSE
|
$\rightarrow$~RESPONSE
|
||||||
|
|
||||||
\item[RESPONSE] If the mailbox response could not be fetched, the data
|
\item[RESPONSE] If the mailbox response could not be fetched, the data
|
||||||
is invalid, the wrong protocol was received, or a ``Abort Sdo
|
is invalid, the wrong protocol was received, or a ``Abort SDO
|
||||||
Transfer Request'' was received, the Sdo download is aborted.
|
Transfer Request'' was received, the SDO download is aborted.
|
||||||
$\rightarrow$~ERROR
|
$\rightarrow$~ERROR
|
||||||
|
|
||||||
If a ``Sdo Download Normal Response'' acknowledgement was received,
|
If a ``SDO Download Normal Response'' acknowledgement was received,
|
||||||
the Sdo download was successful. $\rightarrow$~END
|
the SDO download was successful. $\rightarrow$~END
|
||||||
|
|
||||||
\item[END] The Sdo download was successful.
|
\item[END] The SDO download was successful.
|
||||||
|
|
||||||
\item[ERROR] The Sdo download was aborted due to an error.
|
\item[ERROR] The SDO download was aborted due to an error.
|
||||||
|
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\section{Vendor-specific-over-EtherCAT (VoE)}
|
\section{Vendor specific over EtherCAT (VoE)}
|
||||||
\label{sec:voe}
|
\label{sec:voe}
|
||||||
\index{VoE}
|
\index{VoE}
|
||||||
|
|
||||||
|
|
@ -2087,19 +2087,19 @@ sec.~\ref{sec:autonode} for how to install and configure it.
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\subsection{Sync Managers, Pdos and Pdo Entries}
|
\subsection{Sync Managers, PDOs and PDO Entries}
|
||||||
|
|
||||||
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_pdos}
|
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_pdos}
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\subsection{Sdo Dictionary}
|
\subsection{SDO Dictionary}
|
||||||
|
|
||||||
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sdos}
|
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sdos}
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
|
|
||||||
\subsection{Sdo Access}
|
\subsection{SDO Access}
|
||||||
|
|
||||||
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_download}
|
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_download}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ digraph pdo_conf {
|
||||||
start -> end [fontname="Helvetica",label="No config"]
|
start -> end [fontname="Helvetica",label="No config"]
|
||||||
|
|
||||||
action_next_sync [shape=point,label=""]
|
action_next_sync [shape=point,label=""]
|
||||||
action_next_sync -> action_check_assignment [fontname="Helvetica",label="No Pdos"]
|
action_next_sync -> action_check_assignment [fontname="Helvetica",label="No PDOs"]
|
||||||
action_next_sync -> action_pdo_mapping [fontname="Helvetica",label="First Pdo",weight=10]
|
action_next_sync -> action_pdo_mapping [fontname="Helvetica",label="First PDO",weight=10]
|
||||||
action_next_sync -> end [fontname="Helvetica",label="No more SMs"]
|
action_next_sync -> end [fontname="Helvetica",label="No more SMs"]
|
||||||
|
|
||||||
action_pdo_mapping [shape=point,label=""]
|
action_pdo_mapping [shape=point,label=""]
|
||||||
|
|
@ -29,22 +29,22 @@ digraph pdo_conf {
|
||||||
action_next_pdo_mapping [shape=point,label=""]
|
action_next_pdo_mapping [shape=point,label=""]
|
||||||
action_next_pdo_mapping -> action_check_assignment [weight=10]
|
action_next_pdo_mapping -> action_check_assignment [weight=10]
|
||||||
action_next_pdo_mapping -> action_pdo_mapping
|
action_next_pdo_mapping -> action_pdo_mapping
|
||||||
[fontname="Helvetica",label="Next Pdo"]
|
[fontname="Helvetica",label="Next PDO"]
|
||||||
|
|
||||||
action_check_assignment [shape=point,label=""]
|
action_check_assignment [shape=point,label=""]
|
||||||
action_check_assignment -> action_next_sync [fontname="Helvetica",label="Assign ok"]
|
action_check_assignment -> action_next_sync [fontname="Helvetica",label="Assign ok"]
|
||||||
action_check_assignment -> zero_pdo_count [weight=10]
|
action_check_assignment -> zero_pdo_count [weight=10]
|
||||||
|
|
||||||
zero_pdo_count [fontname="Helvetica"]
|
zero_pdo_count [fontname="Helvetica"]
|
||||||
zero_pdo_count -> action_next_sync [fontname="Helvetica",label="No Pdos"]
|
zero_pdo_count -> action_next_sync [fontname="Helvetica",label="No PDOs"]
|
||||||
zero_pdo_count -> action_assign_pdo [fontname="Helvetica",label="First Pdo", weight=10]
|
zero_pdo_count -> action_assign_pdo [fontname="Helvetica",label="First PDO", weight=10]
|
||||||
|
|
||||||
action_assign_pdo [shape=point,label=""]
|
action_assign_pdo [shape=point,label=""]
|
||||||
action_assign_pdo -> assign_pdo [weight=10]
|
action_assign_pdo -> assign_pdo [weight=10]
|
||||||
|
|
||||||
assign_pdo [fontname="Helvetica"]
|
assign_pdo [fontname="Helvetica"]
|
||||||
assign_pdo -> set_pdo_count [fontname="Helvetica",label="No more Pdos", weight=10]
|
assign_pdo -> set_pdo_count [fontname="Helvetica",label="No more PDOs", weight=10]
|
||||||
assign_pdo -> action_assign_pdo [fontname="Helvetica",label="Next Pdo"]
|
assign_pdo -> action_assign_pdo [fontname="Helvetica",label="Next PDO"]
|
||||||
|
|
||||||
set_pdo_count [fontname="Helvetica"]
|
set_pdo_count [fontname="Helvetica"]
|
||||||
set_pdo_count -> action_next_sync
|
set_pdo_count -> action_next_sync
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ digraph pdo_read {
|
||||||
pdo_count -> action_next_pdo [weight=5]
|
pdo_count -> action_next_pdo [weight=5]
|
||||||
|
|
||||||
action_next_pdo [shape=point,label=""]
|
action_next_pdo [shape=point,label=""]
|
||||||
action_next_pdo -> pdo [fontname="Helvetica", label="Next Pdo", weight=5]
|
action_next_pdo -> pdo [fontname="Helvetica", label="Next PDO", weight=5]
|
||||||
action_next_pdo -> action_next_sync [fontname="Helvetica", label="No more Pdos"]
|
action_next_pdo -> action_next_sync [fontname="Helvetica", label="No more PDOs"]
|
||||||
|
|
||||||
pdo [fontname="Helvetica"]
|
pdo [fontname="Helvetica"]
|
||||||
pdo -> pdo_entries [weight=5]
|
pdo -> pdo_entries [weight=5]
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ digraph slaveconf {
|
||||||
preop -> enter_sdo_conf [weight=10]
|
preop -> enter_sdo_conf [weight=10]
|
||||||
|
|
||||||
enter_sdo_conf [shape=point, label=""]
|
enter_sdo_conf [shape=point, label=""]
|
||||||
enter_sdo_conf -> enter_pdo_conf [fontname="Helvetica", label="No Sdos\nconfigured"]
|
enter_sdo_conf -> enter_pdo_conf [fontname="Helvetica", label="No SDOs\nconfigured"]
|
||||||
enter_sdo_conf -> sdo_conf [weight=10]
|
enter_sdo_conf -> sdo_conf [weight=10]
|
||||||
|
|
||||||
sdo_conf [fontname="Helvetica"]
|
sdo_conf [fontname="Helvetica"]
|
||||||
|
|
@ -46,7 +46,7 @@ digraph slaveconf {
|
||||||
pdo_conf -> enter_pdo_sync [weight=10]
|
pdo_conf -> enter_pdo_sync [weight=10]
|
||||||
|
|
||||||
enter_pdo_sync [shape=point, label=""]
|
enter_pdo_sync [shape=point, label=""]
|
||||||
enter_pdo_sync -> enter_fmmu [fontname="Helvetica", label="No Pdo SMs"]
|
enter_pdo_sync -> enter_fmmu [fontname="Helvetica", label="No PDO SMs"]
|
||||||
enter_pdo_sync -> pdo_sync [weight=10]
|
enter_pdo_sync -> pdo_sync [weight=10]
|
||||||
|
|
||||||
pdo_sync [fontname="Helvetica"]
|
pdo_sync [fontname="Helvetica"]
|
||||||
|
|
|
||||||
|
|
@ -95,16 +95,16 @@ Single
|
||||||
4 0 0 50 -1 18 12 0.0000 4 180 1290 3735 2025 Sync Manager\001
|
4 0 0 50 -1 18 12 0.0000 4 180 1290 3735 2025 Sync Manager\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 2385 Index\001
|
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 2385 Index\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 750 3735 2610 Direction\001
|
4 0 0 50 -1 16 12 0.0000 4 135 750 3735 2610 Direction\001
|
||||||
4 0 0 50 -1 18 12 0.0000 4 180 1575 3735 3420 Sdo Configuration\001
|
4 0 0 50 -1 18 12 0.0000 4 180 1575 3735 3420 SDO Configuration\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 3780 Index\001
|
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 3780 Index\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 780 3735 4005 Subindex\001
|
4 0 0 50 -1 16 12 0.0000 4 135 780 3735 4005 Subindex\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 390 3735 4230 Data\001
|
4 0 0 50 -1 16 12 0.0000 4 135 390 3735 4230 Data\001
|
||||||
4 0 0 50 -1 18 12 0.0000 4 180 1140 3735 5040 Sdo Request\001
|
4 0 0 50 -1 18 12 0.0000 4 180 1140 3735 5040 SDO Request\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 5310 Index\001
|
4 0 0 50 -1 16 12 0.0000 4 135 450 3735 5310 Index\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 780 3735 5535 Subindex\001
|
4 0 0 50 -1 16 12 0.0000 4 135 780 3735 5535 Subindex\001
|
||||||
4 0 0 50 -1 18 12 0.0000 4 135 330 6210 2025 Pdo\001
|
4 0 0 50 -1 18 12 0.0000 4 135 330 6210 2025 PDO\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 450 6210 2385 Index\001
|
4 0 0 50 -1 16 12 0.0000 4 135 450 6210 2385 Index\001
|
||||||
4 0 0 50 -1 18 12 0.0000 4 180 885 7785 2025 Pdo Entry\001
|
4 0 0 50 -1 18 12 0.0000 4 180 885 7785 2025 PDO Entry\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 450 7785 2340 Index\001
|
4 0 0 50 -1 16 12 0.0000 4 135 450 7785 2340 Index\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 135 780 7785 2565 Subindex\001
|
4 0 0 50 -1 16 12 0.0000 4 135 780 7785 2565 Subindex\001
|
||||||
4 0 0 50 -1 16 12 0.0000 4 180 720 7785 2790 Bitlength\001
|
4 0 0 50 -1 16 12 0.0000 4 180 720 7785 2790 Bitlength\001
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Single
|
||||||
6 3465 4455 5640 4680
|
6 3465 4455 5640 4680
|
||||||
2 2 0 1 0 7 50 -1 42 0.000 0 0 -1 0 0 5
|
2 2 0 1 0 7 50 -1 42 0.000 0 0 -1 0 0 5
|
||||||
3465 4455 3645 4455 3645 4680 3465 4680 3465 4455
|
3465 4455 3645 4455 3645 4680 3465 4680 3465 4455
|
||||||
4 0 0 50 -1 16 12 0.0000 4 180 1905 3735 4635 Registered Pdo Entries\001
|
4 0 0 50 -1 16 12 0.0000 4 180 1905 3735 4635 Registered PDO Entries\001
|
||||||
-6
|
-6
|
||||||
2 1 1 1 0 7 52 -1 46 4.000 0 0 -1 0 0 2
|
2 1 1 1 0 7 52 -1 46 4.000 0 0 -1 0 0 2
|
||||||
1215 1665 1620 3870
|
1215 1665 1620 3870
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ static uint8_t *domain1_pd; // process data memory
|
||||||
#define Beckhoff_EL3152 0x00000002, 0x0c503052
|
#define Beckhoff_EL3152 0x00000002, 0x0c503052
|
||||||
#define Beckhoff_EL4102 0x00000002, 0x10063052
|
#define Beckhoff_EL4102 0x00000002, 0x10063052
|
||||||
|
|
||||||
// offsets for Pdo entries
|
// offsets for PDO entries
|
||||||
static unsigned int off_ana_in;
|
static unsigned int off_ana_in;
|
||||||
static unsigned int off_ana_out;
|
static unsigned int off_ana_out;
|
||||||
static unsigned int off_dig_out;
|
static unsigned int off_dig_out;
|
||||||
|
|
@ -255,12 +255,12 @@ void read_sdo(void)
|
||||||
printk(KERN_INFO PFX "Still busy...\n");
|
printk(KERN_INFO PFX "Still busy...\n");
|
||||||
break;
|
break;
|
||||||
case EC_REQUEST_SUCCESS:
|
case EC_REQUEST_SUCCESS:
|
||||||
printk(KERN_INFO PFX "Sdo value: 0x%04X\n",
|
printk(KERN_INFO PFX "SDO value: 0x%04X\n",
|
||||||
EC_READ_U16(ecrt_sdo_request_data(sdo)));
|
EC_READ_U16(ecrt_sdo_request_data(sdo)));
|
||||||
ecrt_sdo_request_read(sdo); // trigger next read
|
ecrt_sdo_request_read(sdo); // trigger next read
|
||||||
break;
|
break;
|
||||||
case EC_REQUEST_ERROR:
|
case EC_REQUEST_ERROR:
|
||||||
printk(KERN_INFO PFX "Failed to read Sdo!\n");
|
printk(KERN_INFO PFX "Failed to read SDO!\n");
|
||||||
ecrt_sdo_request_read(sdo); // retry reading
|
ecrt_sdo_request_read(sdo); // retry reading
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +320,7 @@ void cyclic_task(unsigned long data)
|
||||||
check_slave_config_states();
|
check_slave_config_states();
|
||||||
|
|
||||||
#if SDO_ACCESS
|
#if SDO_ACCESS
|
||||||
// read process data Sdo
|
// read process data SDO
|
||||||
read_sdo();
|
read_sdo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -394,9 +394,9 @@ int __init init_mini_module(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIGURE_PDOS
|
#if CONFIGURE_PDOS
|
||||||
printk(KERN_INFO PFX "Configuring Pdos...\n");
|
printk(KERN_INFO PFX "Configuring PDOs...\n");
|
||||||
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) {
|
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) {
|
||||||
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
|
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -407,7 +407,7 @@ int __init init_mini_module(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) {
|
if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) {
|
||||||
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
|
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,15 +418,15 @@ int __init init_mini_module(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
||||||
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
|
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SDO_ACCESS
|
#if SDO_ACCESS
|
||||||
printk(KERN_INFO PFX "Creating Sdo requests...\n");
|
printk(KERN_INFO PFX "Creating SDO requests...\n");
|
||||||
if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) {
|
if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) {
|
||||||
printk(KERN_ERR PFX "Failed to create Sdo request.\n");
|
printk(KERN_ERR PFX "Failed to create SDO request.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
ecrt_sdo_request_timeout(sdo, 500); // ms
|
ecrt_sdo_request_timeout(sdo, 500); // ms
|
||||||
|
|
@ -440,9 +440,9 @@ int __init init_mini_module(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printk(KERN_INFO PFX "Registering Pdo entries...\n");
|
printk(KERN_INFO PFX "Registering PDO entries...\n");
|
||||||
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
||||||
printk(KERN_ERR PFX "Pdo entry registration failed!\n");
|
printk(KERN_ERR PFX "PDO entry registration failed!\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ static uint8_t *domain1_pd; // process data memory
|
||||||
#define Beckhoff_EL2004 0x00000002, 0x07D43052
|
#define Beckhoff_EL2004 0x00000002, 0x07D43052
|
||||||
#define Beckhoff_EL3162 0x00000002, 0x0C5A3052
|
#define Beckhoff_EL3162 0x00000002, 0x0C5A3052
|
||||||
|
|
||||||
static unsigned int off_ana_in; // offsets for Pdo entries
|
static unsigned int off_ana_in; // offsets for PDO entries
|
||||||
static unsigned int off_dig_out;
|
static unsigned int off_dig_out;
|
||||||
|
|
||||||
const static ec_pdo_entry_reg_t domain1_regs[] = {
|
const static ec_pdo_entry_reg_t domain1_regs[] = {
|
||||||
|
|
@ -297,9 +297,9 @@ int __init init_mod(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIGURE_PDOS
|
#ifdef CONFIGURE_PDOS
|
||||||
printk(KERN_INFO PFX "Configuring Pdos...\n");
|
printk(KERN_INFO PFX "Configuring PDOs...\n");
|
||||||
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
|
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
|
||||||
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
|
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,14 +309,14 @@ int __init init_mod(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
||||||
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
|
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printk(KERN_INFO PFX "Registering Pdo entries...\n");
|
printk(KERN_INFO PFX "Registering PDO entries...\n");
|
||||||
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
||||||
printk(KERN_ERR PFX "Pdo entry registration failed!\n");
|
printk(KERN_ERR PFX "PDO entry registration failed!\n");
|
||||||
goto out_release_master;
|
goto out_release_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ static uint8_t *domain1_pd = NULL;
|
||||||
#define Beckhoff_EL3152 0x00000002, 0x0c503052
|
#define Beckhoff_EL3152 0x00000002, 0x0c503052
|
||||||
#define Beckhoff_EL4102 0x00000002, 0x10063052
|
#define Beckhoff_EL4102 0x00000002, 0x10063052
|
||||||
|
|
||||||
// offsets for Pdo entries
|
// offsets for PDO entries
|
||||||
static unsigned int off_ana_in_status;
|
static unsigned int off_ana_in_status;
|
||||||
static unsigned int off_ana_in_value;
|
static unsigned int off_ana_in_value;
|
||||||
static unsigned int off_ana_out;
|
static unsigned int off_ana_out;
|
||||||
|
|
@ -293,9 +293,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIGURE_PDOS
|
#if CONFIGURE_PDOS
|
||||||
printf("Configuring Pdos...\n");
|
printf("Configuring PDOs...\n");
|
||||||
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) {
|
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) {
|
||||||
fprintf(stderr, "Failed to configure Pdos.\n");
|
fprintf(stderr, "Failed to configure PDOs.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,7 +306,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) {
|
if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) {
|
||||||
fprintf(stderr, "Failed to configure Pdos.\n");
|
fprintf(stderr, "Failed to configure PDOs.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +317,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
|
||||||
fprintf(stderr, "Failed to configure Pdos.\n");
|
fprintf(stderr, "Failed to configure PDOs.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -328,7 +328,7 @@ int main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
||||||
fprintf(stderr, "Pdo entry registration failed!\n");
|
fprintf(stderr, "PDO entry registration failed!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
178
include/ecrt.h
178
include/ecrt.h
|
|
@ -56,18 +56,18 @@
|
||||||
* offers the possibility to use a shared-memory region. Therefore,
|
* offers the possibility to use a shared-memory region. Therefore,
|
||||||
* added the domain methods ecrt_domain_size() and
|
* added the domain methods ecrt_domain_size() and
|
||||||
* ecrt_domain_external_memory().
|
* ecrt_domain_external_memory().
|
||||||
* - Pdo entry registration functions do not return a process data pointer,
|
* - PDO entry registration functions do not return a process data pointer,
|
||||||
* but an offset in the domain's process data. In addition, an optional bit
|
* but an offset in the domain's process data. In addition, an optional bit
|
||||||
* position can be requested. This was necessary for the external domain
|
* position can be requested. This was necessary for the external domain
|
||||||
* memory. An additional advantage is, that the returned offset is
|
* memory. An additional advantage is, that the returned offset is
|
||||||
* immediately valid. If the domain's process data is allocated internally,
|
* immediately valid. If the domain's process data is allocated internally,
|
||||||
* the start address can be retrieved with ecrt_domain_data().
|
* the start address can be retrieved with ecrt_domain_data().
|
||||||
* - Replaced ecrt_slave_pdo_mapping/add/clear() with
|
* - Replaced ecrt_slave_pdo_mapping/add/clear() with
|
||||||
* ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
|
* ecrt_slave_config_pdo_assign_add() to add a PDO to a sync manager's PDO
|
||||||
* assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
|
* assignment and ecrt_slave_config_pdo_mapping_add() to add a PDO entry to a
|
||||||
* Pdo's mapping. ecrt_slave_config_pdos() is a convenience function
|
* PDO's mapping. ecrt_slave_config_pdos() is a convenience function
|
||||||
* for both, that uses the new data types ec_pdo_info_t and
|
* for both, that uses the new data types ec_pdo_info_t and
|
||||||
* ec_pdo_entry_info_t. Pdo entries, that are mapped with these functions
|
* ec_pdo_entry_info_t. PDO entries, that are mapped with these functions
|
||||||
* can now immediately be registered, even if the bus is offline.
|
* can now immediately be registered, even if the bus is offline.
|
||||||
* - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and
|
* - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and
|
||||||
* ec_master_state_t, respectively. Renamed ecrt_master_get_status() to
|
* ec_master_state_t, respectively. Renamed ecrt_master_get_status() to
|
||||||
|
|
@ -75,15 +75,15 @@
|
||||||
* - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter
|
* - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter
|
||||||
* of ecrt_domain_state(). The domain state object does now contain
|
* of ecrt_domain_state(). The domain state object does now contain
|
||||||
* information, if the process data was exchanged completely.
|
* information, if the process data was exchanged completely.
|
||||||
* - Former "Pdo registration" meant Pdo entry registration in fact, therefore
|
* - Former "PDO registration" meant PDO entry registration in fact, therefore
|
||||||
* renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
* renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
||||||
* to ecrt_slave_config_reg_pdo_entry().
|
* to ecrt_slave_config_reg_pdo_entry().
|
||||||
* - Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
* - Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
||||||
* be reached by specifying an explicit Pdo assignment/mapping and
|
* be reached by specifying an explicit PDO assignment/mapping and
|
||||||
* registering the mapped Pdo entries.
|
* registering the mapped PDO entries.
|
||||||
* - Added an Sdo access interface, working with Sdo requests. These can be
|
* - Added an SDO access interface, working with SDO requests. These can be
|
||||||
* scheduled for reading and writing during realtime operation.
|
* scheduled for reading and writing during realtime operation.
|
||||||
* - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function.
|
* - Exported ecrt_slave_config_sdo(), the generic SDO configuration function.
|
||||||
* - Removed the bus_state and bus_tainted flags from ec_master_state_t.
|
* - Removed the bus_state and bus_tainted flags from ec_master_state_t.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
|
|
@ -223,7 +223,7 @@ typedef struct {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Direction type for Pdo assignment functions.
|
/** Direction type for PDO assignment functions.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */
|
EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */
|
||||||
|
|
@ -234,33 +234,33 @@ typedef enum {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo entry configuration information.
|
/** PDO entry configuration information.
|
||||||
*
|
*
|
||||||
* This is the data type of the \a entries field in ec_pdo_info_t.
|
* This is the data type of the \a entries field in ec_pdo_info_t.
|
||||||
*
|
*
|
||||||
* \see ecrt_slave_config_pdos().
|
* \see ecrt_slave_config_pdos().
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t index; /**< Pdo entry index. */
|
uint16_t index; /**< PDO entry index. */
|
||||||
uint8_t subindex; /**< Pdo entry subindex. */
|
uint8_t subindex; /**< PDO entry subindex. */
|
||||||
uint8_t bit_length; /**< Size of the Pdo entry in bit. */
|
uint8_t bit_length; /**< Size of the PDO entry in bit. */
|
||||||
} ec_pdo_entry_info_t;
|
} ec_pdo_entry_info_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo configuration information.
|
/** PDO configuration information.
|
||||||
*
|
*
|
||||||
* This is the data type of the \a pdos field in ec_sync_info_t.
|
* This is the data type of the \a pdos field in ec_sync_info_t.
|
||||||
*
|
*
|
||||||
* \see ecrt_slave_config_pdos().
|
* \see ecrt_slave_config_pdos().
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t index; /**< Pdo index. */
|
uint16_t index; /**< PDO index. */
|
||||||
unsigned int n_entries; /**< Number of Pdo entries in \a entries to map.
|
unsigned int n_entries; /**< Number of PDO entries in \a entries to map.
|
||||||
Zero means, that the default mapping shall be
|
Zero means, that the default mapping shall be
|
||||||
used (this can only be done if the slave is
|
used (this can only be done if the slave is
|
||||||
present at bus configuration time). */
|
present at bus configuration time). */
|
||||||
ec_pdo_entry_info_t *entries; /**< Array of Pdo entries to map. Can either
|
ec_pdo_entry_info_t *entries; /**< Array of PDO entries to map. Can either
|
||||||
be \a NULL, or must contain at
|
be \a NULL, or must contain at
|
||||||
least \a n_entries values. */
|
least \a n_entries values. */
|
||||||
} ec_pdo_info_t;
|
} ec_pdo_info_t;
|
||||||
|
|
@ -269,8 +269,8 @@ typedef struct {
|
||||||
|
|
||||||
/** Sync manager configuration information.
|
/** Sync manager configuration information.
|
||||||
*
|
*
|
||||||
* This can be use to configure multiple sync managers including the Pdo
|
* This can be use to configure multiple sync managers including the PDO
|
||||||
* assignment and Pdo mapping. It is used as an input parameter type in
|
* assignment and PDO mapping. It is used as an input parameter type in
|
||||||
* ecrt_slave_config_pdos().
|
* ecrt_slave_config_pdos().
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -278,14 +278,14 @@ typedef struct {
|
||||||
than #EC_MAX_SYNC_MANAGERS for a valid sync manager,
|
than #EC_MAX_SYNC_MANAGERS for a valid sync manager,
|
||||||
but can also be \a 0xff to mark the end of the list. */
|
but can also be \a 0xff to mark the end of the list. */
|
||||||
ec_direction_t dir; /**< Sync manager direction. */
|
ec_direction_t dir; /**< Sync manager direction. */
|
||||||
unsigned int n_pdos; /**< Number of Pdos in \a pdos. */
|
unsigned int n_pdos; /**< Number of PDOs in \a pdos. */
|
||||||
ec_pdo_info_t *pdos; /**< Array with Pdos to assign. This must contain
|
ec_pdo_info_t *pdos; /**< Array with PDOs to assign. This must contain
|
||||||
at least \a n_pdos Pdos. */
|
at least \a n_pdos PDOs. */
|
||||||
} ec_sync_info_t;
|
} ec_sync_info_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** List record type for Pdo entry mass-registration.
|
/** List record type for PDO entry mass-registration.
|
||||||
*
|
*
|
||||||
* This type is used for the array parameter of the
|
* This type is used for the array parameter of the
|
||||||
* ecrt_domain_reg_pdo_entry_list()
|
* ecrt_domain_reg_pdo_entry_list()
|
||||||
|
|
@ -295,14 +295,14 @@ typedef struct {
|
||||||
uint16_t position; /**< Slave position. */
|
uint16_t position; /**< Slave position. */
|
||||||
uint32_t vendor_id; /**< Slave vendor ID. */
|
uint32_t vendor_id; /**< Slave vendor ID. */
|
||||||
uint32_t product_code; /**< Slave product code. */
|
uint32_t product_code; /**< Slave product code. */
|
||||||
uint16_t index; /**< Pdo entry index. */
|
uint16_t index; /**< PDO entry index. */
|
||||||
uint8_t subindex; /**< Pdo entry subindex. */
|
uint8_t subindex; /**< PDO entry subindex. */
|
||||||
unsigned int *offset; /**< Pointer to a variable to store the Pdo entry's
|
unsigned int *offset; /**< Pointer to a variable to store the PDO entry's
|
||||||
(byte-)offset in the process data. */
|
(byte-)offset in the process data. */
|
||||||
unsigned int *bit_position; /**< Pointer to a variable to store a bit
|
unsigned int *bit_position; /**< Pointer to a variable to store a bit
|
||||||
position (0-7) within the \a offset. Can be
|
position (0-7) within the \a offset. Can be
|
||||||
NULL, in which case an error is raised if the
|
NULL, in which case an error is raised if the
|
||||||
Pdo entry does not byte-align. */
|
PDO entry does not byte-align. */
|
||||||
} ec_pdo_entry_reg_t;
|
} ec_pdo_entry_reg_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -389,7 +389,7 @@ void ecrt_master_callbacks(
|
||||||
*
|
*
|
||||||
* For process data exchange, at least one process data domain is needed.
|
* For process data exchange, at least one process data domain is needed.
|
||||||
* This method creates a new process data domain and returns a pointer to the
|
* This method creates a new process data domain and returns a pointer to the
|
||||||
* new domain object. This object can be used for registering Pdos and
|
* new domain object. This object can be used for registering PDOs and
|
||||||
* exchanging them in cyclic operation.
|
* exchanging them in cyclic operation.
|
||||||
*
|
*
|
||||||
* \return Pointer to the new domain on success, else NULL.
|
* \return Pointer to the new domain on success, else NULL.
|
||||||
|
|
@ -506,7 +506,7 @@ int ecrt_slave_config_sync_manager(
|
||||||
ec_direction_t dir /**< Input/Output. */
|
ec_direction_t dir /**< Input/Output. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Add a Pdo to a sync manager's Pdo assignment.
|
/** Add a PDO to a sync manager's PDO assignment.
|
||||||
*
|
*
|
||||||
* \see ecrt_slave_config_pdos()
|
* \see ecrt_slave_config_pdos()
|
||||||
* \return zero on success, else non-zero
|
* \return zero on success, else non-zero
|
||||||
|
|
@ -515,12 +515,12 @@ int ecrt_slave_config_pdo_assign_add(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint8_t sync_index, /**< Sync manager index. Must be less
|
uint8_t sync_index, /**< Sync manager index. Must be less
|
||||||
than #EC_MAX_SYNC_MANAGERS. */
|
than #EC_MAX_SYNC_MANAGERS. */
|
||||||
uint16_t index /**< Index of the Pdo to assign. */
|
uint16_t index /**< Index of the PDO to assign. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Clear a sync manager's Pdo assignment.
|
/** Clear a sync manager's PDO assignment.
|
||||||
*
|
*
|
||||||
* This can be called before assigning Pdos via
|
* This can be called before assigning PDOs via
|
||||||
* ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a
|
* ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a
|
||||||
* sync manager.
|
* sync manager.
|
||||||
*
|
*
|
||||||
|
|
@ -532,34 +532,34 @@ void ecrt_slave_config_pdo_assign_clear(
|
||||||
than #EC_MAX_SYNC_MANAGERS. */
|
than #EC_MAX_SYNC_MANAGERS. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Add a Pdo entry to the given Pdo's mapping.
|
/** Add a PDO entry to the given PDO's mapping.
|
||||||
*
|
*
|
||||||
* \see ecrt_slave_config_pdos()
|
* \see ecrt_slave_config_pdos()
|
||||||
* \return zero on success, else non-zero
|
* \return zero on success, else non-zero
|
||||||
*/
|
*/
|
||||||
int ecrt_slave_config_pdo_mapping_add(
|
int ecrt_slave_config_pdo_mapping_add(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint16_t pdo_index, /**< Index of the Pdo. */
|
uint16_t pdo_index, /**< Index of the PDO. */
|
||||||
uint16_t entry_index, /**< Index of the Pdo entry to add to the Pdo's
|
uint16_t entry_index, /**< Index of the PDO entry to add to the PDO's
|
||||||
mapping. */
|
mapping. */
|
||||||
uint8_t entry_subindex, /**< Subindex of the Pdo entry to add to the
|
uint8_t entry_subindex, /**< Subindex of the PDO entry to add to the
|
||||||
Pdo's mapping. */
|
PDO's mapping. */
|
||||||
uint8_t entry_bit_length /**< Size of the Pdo entry in bit. */
|
uint8_t entry_bit_length /**< Size of the PDO entry in bit. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Clear the mapping of a given Pdo.
|
/** Clear the mapping of a given PDO.
|
||||||
*
|
*
|
||||||
* This can be called before mapping Pdo entries via
|
* This can be called before mapping PDO entries via
|
||||||
* ecrt_slave_config_pdo_mapping_add(), to clear the default mapping.
|
* ecrt_slave_config_pdo_mapping_add(), to clear the default mapping.
|
||||||
*
|
*
|
||||||
* \see ecrt_slave_config_pdos()
|
* \see ecrt_slave_config_pdos()
|
||||||
*/
|
*/
|
||||||
void ecrt_slave_config_pdo_mapping_clear(
|
void ecrt_slave_config_pdo_mapping_clear(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint16_t pdo_index /**< Index of the Pdo. */
|
uint16_t pdo_index /**< Index of the PDO. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Specify a complete Pdo configuration.
|
/** Specify a complete PDO configuration.
|
||||||
*
|
*
|
||||||
* This function is a convenience wrapper for the functions
|
* This function is a convenience wrapper for the functions
|
||||||
* ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(),
|
* ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(),
|
||||||
|
|
@ -568,7 +568,7 @@ void ecrt_slave_config_pdo_mapping_clear(
|
||||||
* automatic code generation.
|
* automatic code generation.
|
||||||
*
|
*
|
||||||
* The following example shows, how to specify a complete configuration,
|
* The following example shows, how to specify a complete configuration,
|
||||||
* including the Pdo mappings. With this information, the master is able to
|
* including the PDO mappings. With this information, the master is able to
|
||||||
* reserve the complete process data, even if the slave is not present at
|
* reserve the complete process data, even if the slave is not present at
|
||||||
* configuration time:
|
* configuration time:
|
||||||
*
|
*
|
||||||
|
|
@ -599,9 +599,9 @@ void ecrt_slave_config_pdo_mapping_clear(
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* The next example shows, how to configure the Pdo assignment only. The
|
* The next example shows, how to configure the PDO assignment only. The
|
||||||
* entries for each assigned Pdo are taken from the Pdo's default mapping.
|
* entries for each assigned PDO are taken from the PDO's default mapping.
|
||||||
* Please note, that Pdo entry registration will fail, if the Pdo
|
* Please note, that PDO entry registration will fail, if the PDO
|
||||||
* configuration is left empty and the slave is offline.
|
* configuration is left empty and the slave is offline.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
|
|
@ -635,44 +635,44 @@ int ecrt_slave_config_pdos(
|
||||||
configurations. */
|
configurations. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Registers a Pdo entry for process data exchange in a domain.
|
/** Registers a PDO entry for process data exchange in a domain.
|
||||||
*
|
*
|
||||||
* Searches the assigned Pdos for the given Pdo entry. An error is raised, if
|
* Searches the assigned PDOs for the given PDO entry. An error is raised, if
|
||||||
* the given entry is not mapped. Otherwise, the corresponding sync manager
|
* the given entry is not mapped. Otherwise, the corresponding sync manager
|
||||||
* and FMMU configurations are provided for slave configuration and the
|
* and FMMU configurations are provided for slave configuration and the
|
||||||
* respective sync manager's assigned Pdos are appended to the given domain,
|
* respective sync manager's assigned PDOs are appended to the given domain,
|
||||||
* if not already done. The offset of the requested Pdo entry's data inside
|
* if not already done. The offset of the requested PDO entry's data inside
|
||||||
* the domain's process data is returned. Optionally, the Pdo entry bit
|
* the domain's process data is returned. Optionally, the PDO entry bit
|
||||||
* position (0-7) can be retrieved via the \a bit_position output parameter.
|
* position (0-7) can be retrieved via the \a bit_position output parameter.
|
||||||
* This pointer may be \a NULL, in this case an error is raised if the Pdo
|
* This pointer may be \a NULL, in this case an error is raised if the PDO
|
||||||
* entry does not byte-align.
|
* entry does not byte-align.
|
||||||
*
|
*
|
||||||
* \retval >=0 Success: Offset of the Pdo entry's process data.
|
* \retval >=0 Success: Offset of the PDO entry's process data.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
*/
|
*/
|
||||||
int ecrt_slave_config_reg_pdo_entry(
|
int ecrt_slave_config_reg_pdo_entry(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint16_t entry_index, /**< Index of the Pdo entry to register. */
|
uint16_t entry_index, /**< Index of the PDO entry to register. */
|
||||||
uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
|
uint8_t entry_subindex, /**< Subindex of the PDO entry to register. */
|
||||||
ec_domain_t *domain, /**< Domain. */
|
ec_domain_t *domain, /**< Domain. */
|
||||||
unsigned int *bit_position /**< Optional address if bit addressing
|
unsigned int *bit_position /**< Optional address if bit addressing
|
||||||
is desired */
|
is desired */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Add an Sdo configuration.
|
/** Add an SDO configuration.
|
||||||
*
|
*
|
||||||
* An Sdo configuration is stored in the slave configuration object and is
|
* An SDO configuration is stored in the slave configuration object and is
|
||||||
* downloaded to the slave whenever the slave is being configured by the
|
* downloaded to the slave whenever the slave is being configured by the
|
||||||
* master. This usually happens once on master activation, but can be repeated
|
* master. This usually happens once on master activation, but can be repeated
|
||||||
* subsequently, for example after the slave's power supply failed.
|
* subsequently, for example after the slave's power supply failed.
|
||||||
*
|
*
|
||||||
* \attention The Sdos for Pdo assignment (\p 0x1C10 - \p 0x1C2F) and Pdo
|
* \attention The SDOs for PDO assignment (\p 0x1C10 - \p 0x1C2F) and PDO
|
||||||
* mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be
|
* mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be
|
||||||
* configured with this function, because they are part of the slave
|
* configured with this function, because they are part of the slave
|
||||||
* configuration done by the master. Please use ecrt_slave_config_pdos() and
|
* configuration done by the master. Please use ecrt_slave_config_pdos() and
|
||||||
* friends instead.
|
* friends instead.
|
||||||
*
|
*
|
||||||
* This is the generic function for adding an Sdo configuration. Please note
|
* This is the generic function for adding an SDO configuration. Please note
|
||||||
* that the this function does not do any endianess correction. If
|
* that the this function does not do any endianess correction. If
|
||||||
* datatype-specific functions are needed (that automatically correct the
|
* datatype-specific functions are needed (that automatically correct the
|
||||||
* endianess), have a look at ecrt_slave_config_sdo8(),
|
* endianess), have a look at ecrt_slave_config_sdo8(),
|
||||||
|
|
@ -683,8 +683,8 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
*/
|
*/
|
||||||
int ecrt_slave_config_sdo(
|
int ecrt_slave_config_sdo(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint16_t index, /**< Index of the Sdo to configure. */
|
uint16_t index, /**< Index of the SDO to configure. */
|
||||||
uint8_t subindex, /**< Subindex of the Sdo to configure. */
|
uint8_t subindex, /**< Subindex of the SDO to configure. */
|
||||||
const uint8_t *data, /**< Pointer to the data. */
|
const uint8_t *data, /**< Pointer to the data. */
|
||||||
size_t size /**< Size of the \a data. */
|
size_t size /**< Size of the \a data. */
|
||||||
);
|
);
|
||||||
|
|
@ -731,15 +731,15 @@ int ecrt_slave_config_sdo32(
|
||||||
uint32_t value /**< Value to set. */
|
uint32_t value /**< Value to set. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Create an Sdo request to exchange Sdos during realtime operation.
|
/** Create an SDO request to exchange SDOs during realtime operation.
|
||||||
*
|
*
|
||||||
* The created Sdo request object is freed automatically when the master is
|
* The created SDO request object is freed automatically when the master is
|
||||||
* released.
|
* released.
|
||||||
*/
|
*/
|
||||||
ec_sdo_request_t *ecrt_slave_config_create_sdo_request(
|
ec_sdo_request_t *ecrt_slave_config_create_sdo_request(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
uint16_t index, /**< Sdo index. */
|
uint16_t index, /**< SDO index. */
|
||||||
uint8_t subindex, /**< Sdo subindex. */
|
uint8_t subindex, /**< SDO subindex. */
|
||||||
size_t size /**< Data size to reserve. */
|
size_t size /**< Data size to reserve. */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -771,7 +771,7 @@ void ecrt_slave_config_state(
|
||||||
* Domain methods
|
* Domain methods
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** Registers a bunch of Pdo entries for a domain.
|
/** Registers a bunch of PDO entries for a domain.
|
||||||
*
|
*
|
||||||
* \todo doc
|
* \todo doc
|
||||||
* \attention The registration array has to be terminated with an empty
|
* \attention The registration array has to be terminated with an empty
|
||||||
|
|
@ -780,7 +780,7 @@ void ecrt_slave_config_state(
|
||||||
*/
|
*/
|
||||||
int ecrt_domain_reg_pdo_entry_list(
|
int ecrt_domain_reg_pdo_entry_list(
|
||||||
ec_domain_t *domain, /**< Domain. */
|
ec_domain_t *domain, /**< Domain. */
|
||||||
const ec_pdo_entry_reg_t *pdo_entry_regs /**< Array of Pdo
|
const ec_pdo_entry_reg_t *pdo_entry_regs /**< Array of PDO
|
||||||
registrations. */
|
registrations. */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -796,11 +796,11 @@ size_t ecrt_domain_size(
|
||||||
|
|
||||||
/** Provide external memory to store the domain's process data.
|
/** Provide external memory to store the domain's process data.
|
||||||
*
|
*
|
||||||
* Call this after all Pdo entries have been registered and before activating
|
* Call this after all PDO entries have been registered and before activating
|
||||||
* the master.
|
* the master.
|
||||||
*
|
*
|
||||||
* The size of the allocated memory must be at least ecrt_domain_size(), after
|
* The size of the allocated memory must be at least ecrt_domain_size(), after
|
||||||
* all Pdo entries have been registered.
|
* all PDO entries have been registered.
|
||||||
*/
|
*/
|
||||||
void ecrt_domain_external_memory(
|
void ecrt_domain_external_memory(
|
||||||
ec_domain_t *domain, /**< Domain. */
|
ec_domain_t *domain, /**< Domain. */
|
||||||
|
|
@ -858,10 +858,10 @@ void ecrt_domain_state(
|
||||||
);
|
);
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Sdo request methods.
|
* SDO request methods.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/** Set the timeout for an Sdo request.
|
/** Set the timeout for an SDO request.
|
||||||
*
|
*
|
||||||
* If the request cannot be processed in the specified time, if will be marked
|
* If the request cannot be processed in the specified time, if will be marked
|
||||||
* as failed.
|
* as failed.
|
||||||
|
|
@ -870,14 +870,14 @@ void ecrt_domain_state(
|
||||||
* the next call of this method.
|
* the next call of this method.
|
||||||
*/
|
*/
|
||||||
void ecrt_sdo_request_timeout(
|
void ecrt_sdo_request_timeout(
|
||||||
ec_sdo_request_t *req, /**< Sdo request. */
|
ec_sdo_request_t *req, /**< SDO request. */
|
||||||
uint32_t timeout /**< Timeout in milliseconds. Zero means no
|
uint32_t timeout /**< Timeout in milliseconds. Zero means no
|
||||||
timeout. */
|
timeout. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Access to the Sdo request's data.
|
/** Access to the SDO request's data.
|
||||||
*
|
*
|
||||||
* This function returns a pointer to the request's internal Sdo data memory.
|
* This function returns a pointer to the request's internal SDO data memory.
|
||||||
*
|
*
|
||||||
* - After a read operation was successful, integer data can be evaluated using
|
* - After a read operation was successful, integer data can be evaluated using
|
||||||
* the EC_READ_*() macros as usual. Example:
|
* the EC_READ_*() macros as usual. Example:
|
||||||
|
|
@ -893,45 +893,45 @@ void ecrt_sdo_request_timeout(
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \attention The return value can be invalid during a read operation, because
|
* \attention The return value can be invalid during a read operation, because
|
||||||
* the internal Sdo data memory could be re-allocated if the read Sdo data do
|
* the internal SDO data memory could be re-allocated if the read SDO data do
|
||||||
* not fit inside.
|
* not fit inside.
|
||||||
*
|
*
|
||||||
* \return Pointer to the internal Sdo data memory.
|
* \return Pointer to the internal SDO data memory.
|
||||||
*/
|
*/
|
||||||
uint8_t *ecrt_sdo_request_data(
|
uint8_t *ecrt_sdo_request_data(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Returns the current Sdo data size.
|
/** Returns the current SDO data size.
|
||||||
*
|
*
|
||||||
* When the Sdo request is created, the data size is set to the size of the
|
* When the SDO request is created, the data size is set to the size of the
|
||||||
* reserved memory. After a read operation the size is set to the size of the
|
* reserved memory. After a read operation the size is set to the size of the
|
||||||
* read data. The size is not modified in any other situation.
|
* read data. The size is not modified in any other situation.
|
||||||
*
|
*
|
||||||
* \return Sdo data size in bytes.
|
* \return SDO data size in bytes.
|
||||||
*/
|
*/
|
||||||
size_t ecrt_sdo_request_data_size(
|
size_t ecrt_sdo_request_data_size(
|
||||||
const ec_sdo_request_t *req /**< Sdo request. */
|
const ec_sdo_request_t *req /**< SDO request. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Get the current state of the Sdo request.
|
/** Get the current state of the SDO request.
|
||||||
*
|
*
|
||||||
* \return Request state.
|
* \return Request state.
|
||||||
*/
|
*/
|
||||||
ec_request_state_t ecrt_sdo_request_state(
|
ec_request_state_t ecrt_sdo_request_state(
|
||||||
const ec_sdo_request_t *req /**< Sdo request. */
|
const ec_sdo_request_t *req /**< SDO request. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Schedule an Sdo write operation.
|
/** Schedule an SDO write operation.
|
||||||
*
|
*
|
||||||
* \attention This method may not be called while ecrt_sdo_request_state()
|
* \attention This method may not be called while ecrt_sdo_request_state()
|
||||||
* returns EC_SDO_REQUEST_BUSY.
|
* returns EC_SDO_REQUEST_BUSY.
|
||||||
*/
|
*/
|
||||||
void ecrt_sdo_request_write(
|
void ecrt_sdo_request_write(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Schedule an Sdo read operation.
|
/** Schedule an SDO read operation.
|
||||||
*
|
*
|
||||||
* \attention This method may not be called while ecrt_sdo_request_state()
|
* \attention This method may not be called while ecrt_sdo_request_state()
|
||||||
* returns EC_SDO_REQUEST_BUSY.
|
* returns EC_SDO_REQUEST_BUSY.
|
||||||
|
|
@ -941,7 +941,7 @@ void ecrt_sdo_request_write(
|
||||||
* ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY.
|
* ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY.
|
||||||
*/
|
*/
|
||||||
void ecrt_sdo_request_read(
|
void ecrt_sdo_request_read(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
|
||||||
data.index = pdo_index;
|
data.index = pdo_index;
|
||||||
|
|
||||||
if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_PDO, &data) == -1) {
|
if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_PDO, &data) == -1) {
|
||||||
fprintf(stderr, "Failed to add Pdo: %s\n",
|
fprintf(stderr, "Failed to add PDO: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1; // FIXME
|
return -1; // FIXME
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc,
|
||||||
data.sync_index = sync_index;
|
data.sync_index = sync_index;
|
||||||
|
|
||||||
if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_PDOS, &data) == -1) {
|
if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_PDOS, &data) == -1) {
|
||||||
fprintf(stderr, "Failed to clear Pdos: %s\n",
|
fprintf(stderr, "Failed to clear PDOs: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
|
||||||
data.entry_bit_length = entry_bit_length;
|
data.entry_bit_length = entry_bit_length;
|
||||||
|
|
||||||
if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_ENTRY, &data) == -1) {
|
if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_ENTRY, &data) == -1) {
|
||||||
fprintf(stderr, "Failed to add Pdo entry: %s\n",
|
fprintf(stderr, "Failed to add PDO entry: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1; // FIXME
|
return -1; // FIXME
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +131,7 @@ void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
|
||||||
data.index = pdo_index;
|
data.index = pdo_index;
|
||||||
|
|
||||||
if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_ENTRIES, &data) == -1) {
|
if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_ENTRIES, &data) == -1) {
|
||||||
fprintf(stderr, "Failed to clear Pdo entries: %s\n",
|
fprintf(stderr, "Failed to clear PDO entries: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +219,7 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
|
|
||||||
ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data);
|
ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
fprintf(stderr, "Failed to register Pdo entry: %s\n",
|
fprintf(stderr, "Failed to register PDO entry: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -2; // FIXME
|
return -2; // FIXME
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +228,7 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
*bit_position = data.bit_position;
|
*bit_position = data.bit_position;
|
||||||
} else {
|
} else {
|
||||||
if (data.bit_position) {
|
if (data.bit_position) {
|
||||||
fprintf(stderr, "Pdo entry 0x%04X:%02X does not byte-align "
|
fprintf(stderr, "PDO entry 0x%04X:%02X does not byte-align "
|
||||||
"in config %u:%u.\n", index, subindex,
|
"in config %u:%u.\n", index, subindex,
|
||||||
sc->alias, sc->position);
|
sc->alias, sc->position);
|
||||||
return -3; // FIXME
|
return -3; // FIXME
|
||||||
|
|
@ -252,7 +252,7 @@ int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
|
||||||
data.size = size;
|
data.size = size;
|
||||||
|
|
||||||
if (ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data) == -1) {
|
if (ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data) == -1) {
|
||||||
fprintf(stderr, "Failed to configure Sdo.\n");
|
fprintf(stderr, "Failed to configure SDO.\n");
|
||||||
return -1; // FIXME
|
return -1; // FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* Vendor-specific-over-EtherCAT protocol handler functions.
|
* Vendor specific over EtherCAT protocol handler functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ int ec_cdev_ioctl_slave_sync(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave sync manager Pdo information.
|
/** Get slave sync manager PDO information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sync_pdo(
|
int ec_cdev_ioctl_slave_sync_pdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -343,7 +343,7 @@ int ec_cdev_ioctl_slave_sync_pdo(
|
||||||
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const(
|
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const(
|
||||||
&sync->pdos, data.pdo_pos))) {
|
&sync->pdos, data.pdo_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sync manager %u does not contain a Pdo with "
|
EC_ERR("Sync manager %u does not contain a PDO with "
|
||||||
"position %u in slave %u!\n", data.sync_index,
|
"position %u in slave %u!\n", data.sync_index,
|
||||||
data.pdo_pos, data.slave_position);
|
data.pdo_pos, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -363,7 +363,7 @@ int ec_cdev_ioctl_slave_sync_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave sync manager Pdo entry information.
|
/** Get slave sync manager PDO entry information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sync_pdo_entry(
|
int ec_cdev_ioctl_slave_sync_pdo_entry(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -401,7 +401,7 @@ int ec_cdev_ioctl_slave_sync_pdo_entry(
|
||||||
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const(
|
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const(
|
||||||
&sync->pdos, data.pdo_pos))) {
|
&sync->pdos, data.pdo_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sync manager %u does not contain a Pdo with "
|
EC_ERR("Sync manager %u does not contain a PDO with "
|
||||||
"position %u in slave %u!\n", data.sync_index,
|
"position %u in slave %u!\n", data.sync_index,
|
||||||
data.pdo_pos, data.slave_position);
|
data.pdo_pos, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -410,7 +410,7 @@ int ec_cdev_ioctl_slave_sync_pdo_entry(
|
||||||
if (!(entry = ec_pdo_find_entry_by_pos_const(
|
if (!(entry = ec_pdo_find_entry_by_pos_const(
|
||||||
pdo, data.entry_pos))) {
|
pdo, data.entry_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Pdo 0x%04X does not contain an entry with "
|
EC_ERR("PDO 0x%04X does not contain an entry with "
|
||||||
"position %u in slave %u!\n", data.pdo_pos,
|
"position %u in slave %u!\n", data.pdo_pos,
|
||||||
data.entry_pos, data.slave_position);
|
data.entry_pos, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -604,7 +604,7 @@ int ec_cdev_ioctl_slave_state(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave Sdo information.
|
/** Get slave SDO information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sdo(
|
int ec_cdev_ioctl_slave_sdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -632,7 +632,7 @@ int ec_cdev_ioctl_slave_sdo(
|
||||||
if (!(sdo = ec_slave_get_sdo_by_pos_const(
|
if (!(sdo = ec_slave_get_sdo_by_pos_const(
|
||||||
slave, data.sdo_position))) {
|
slave, data.sdo_position))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sdo %u does not exist in slave %u!\n",
|
EC_ERR("SDO %u does not exist in slave %u!\n",
|
||||||
data.sdo_position, data.slave_position);
|
data.sdo_position, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -651,7 +651,7 @@ int ec_cdev_ioctl_slave_sdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave Sdo entry information.
|
/** Get slave SDO entry information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sdo_entry(
|
int ec_cdev_ioctl_slave_sdo_entry(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -681,7 +681,7 @@ int ec_cdev_ioctl_slave_sdo_entry(
|
||||||
if (!(sdo = ec_slave_get_sdo_by_pos_const(
|
if (!(sdo = ec_slave_get_sdo_by_pos_const(
|
||||||
slave, -data.sdo_spec))) {
|
slave, -data.sdo_spec))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sdo %u does not exist in slave %u!\n",
|
EC_ERR("SDO %u does not exist in slave %u!\n",
|
||||||
-data.sdo_spec, data.slave_position);
|
-data.sdo_spec, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -689,7 +689,7 @@ int ec_cdev_ioctl_slave_sdo_entry(
|
||||||
if (!(sdo = ec_slave_get_sdo_const(
|
if (!(sdo = ec_slave_get_sdo_const(
|
||||||
slave, data.sdo_spec))) {
|
slave, data.sdo_spec))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sdo 0x%04X does not exist in slave %u!\n",
|
EC_ERR("SDO 0x%04X does not exist in slave %u!\n",
|
||||||
data.sdo_spec, data.slave_position);
|
data.sdo_spec, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -698,7 +698,7 @@ int ec_cdev_ioctl_slave_sdo_entry(
|
||||||
if (!(entry = ec_sdo_get_entry_const(
|
if (!(entry = ec_sdo_get_entry_const(
|
||||||
sdo, data.sdo_entry_subindex))) {
|
sdo, data.sdo_entry_subindex))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Sdo entry 0x%04X:%02X does not exist "
|
EC_ERR("SDO entry 0x%04X:%02X does not exist "
|
||||||
"in slave %u!\n", sdo->index,
|
"in slave %u!\n", sdo->index,
|
||||||
data.sdo_entry_subindex, data.slave_position);
|
data.sdo_entry_subindex, data.slave_position);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -718,7 +718,7 @@ int ec_cdev_ioctl_slave_sdo_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Upload Sdo.
|
/** Upload SDO.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sdo_upload(
|
int ec_cdev_ioctl_slave_sdo_upload(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -803,7 +803,7 @@ int ec_cdev_ioctl_slave_sdo_upload(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Download Sdo.
|
/** Download SDO.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_slave_sdo_download(
|
int ec_cdev_ioctl_slave_sdo_download(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1219,7 +1219,7 @@ int ec_cdev_ioctl_config(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave configuration Pdo information.
|
/** Get slave configuration PDO information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_config_pdo(
|
int ec_cdev_ioctl_config_pdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1255,7 +1255,7 @@ int ec_cdev_ioctl_config_pdo(
|
||||||
&sc->sync_configs[data.sync_index].pdos,
|
&sc->sync_configs[data.sync_index].pdos,
|
||||||
data.pdo_pos))) {
|
data.pdo_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Invalid Pdo position!\n");
|
EC_ERR("Invalid PDO position!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1273,7 +1273,7 @@ int ec_cdev_ioctl_config_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave configuration Pdo entry information.
|
/** Get slave configuration PDO entry information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_config_pdo_entry(
|
int ec_cdev_ioctl_config_pdo_entry(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1310,7 +1310,7 @@ int ec_cdev_ioctl_config_pdo_entry(
|
||||||
&sc->sync_configs[data.sync_index].pdos,
|
&sc->sync_configs[data.sync_index].pdos,
|
||||||
data.pdo_pos))) {
|
data.pdo_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Invalid Pdo position!\n");
|
EC_ERR("Invalid PDO position!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1336,7 +1336,7 @@ int ec_cdev_ioctl_config_pdo_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get slave configuration Sdo information.
|
/** Get slave configuration SDO information.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_config_sdo(
|
int ec_cdev_ioctl_config_sdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1365,7 +1365,7 @@ int ec_cdev_ioctl_config_sdo(
|
||||||
if (!(req = ec_slave_config_get_sdo_by_pos_const(
|
if (!(req = ec_slave_config_get_sdo_by_pos_const(
|
||||||
sc, data.sdo_pos))) {
|
sc, data.sdo_pos))) {
|
||||||
up(&master->master_sem);
|
up(&master->master_sem);
|
||||||
EC_ERR("Invalid Sdo position!\n");
|
EC_ERR("Invalid SDO position!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1642,7 +1642,7 @@ out_return:
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add a Pdo to the assignment.
|
/** Add a PDO to the assignment.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_add_pdo(
|
int ec_cdev_ioctl_sc_add_pdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1674,7 +1674,7 @@ int ec_cdev_ioctl_sc_add_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Clears the Pdo assignment.
|
/** Clears the PDO assignment.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_clear_pdos(
|
int ec_cdev_ioctl_sc_clear_pdos(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1707,7 +1707,7 @@ int ec_cdev_ioctl_sc_clear_pdos(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add an entry to a Pdo's mapping.
|
/** Add an entry to a PDO's mapping.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_add_entry(
|
int ec_cdev_ioctl_sc_add_entry(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1740,7 +1740,7 @@ int ec_cdev_ioctl_sc_add_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Clears the mapping of a Pdo.
|
/** Clears the mapping of a PDO.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_clear_entries(
|
int ec_cdev_ioctl_sc_clear_entries(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1773,7 +1773,7 @@ int ec_cdev_ioctl_sc_clear_entries(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Registers a Pdo entry.
|
/** Registers a PDO entry.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_reg_pdo_entry(
|
int ec_cdev_ioctl_sc_reg_pdo_entry(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
@ -1818,7 +1818,7 @@ int ec_cdev_ioctl_sc_reg_pdo_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Configures an Sdo.
|
/** Configures an SDO.
|
||||||
*/
|
*/
|
||||||
int ec_cdev_ioctl_sc_sdo(
|
int ec_cdev_ioctl_sc_sdo(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
Ethernet-over-EtherCAT (EoE).
|
Ethernet over EtherCAT (EoE).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
Ethernet-over-EtherCAT (EoE)
|
Ethernet over EtherCAT (EoE)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -56,7 +56,7 @@ ec_eoe_frame_t;
|
||||||
typedef struct ec_eoe ec_eoe_t; /**< \see ec_eoe */
|
typedef struct ec_eoe ec_eoe_t; /**< \see ec_eoe */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ethernet-over-EtherCAT (EoE) handler.
|
Ethernet over EtherCAT (EoE) handler.
|
||||||
The master creates one of these objects for each slave that supports the
|
The master creates one of these objects for each slave that supports the
|
||||||
EoE protocol.
|
EoE protocol.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
/** FMMU configuration constructor.
|
/** FMMU configuration constructor.
|
||||||
*
|
*
|
||||||
* Inits an FMMU configuration, sets the logical start address and adds the
|
* Inits an FMMU configuration, sets the logical start address and adds the
|
||||||
* process data size for the mapped Pdos of the given direction to the domain
|
* process data size for the mapped PDOs of the given direction to the domain
|
||||||
* data size.
|
* data size.
|
||||||
*/
|
*/
|
||||||
void ec_fmmu_config_init(
|
void ec_fmmu_config_init(
|
||||||
|
|
@ -49,7 +49,7 @@ void ec_fmmu_config_init(
|
||||||
ec_slave_config_t *sc, /**< EtherCAT slave configuration. */
|
ec_slave_config_t *sc, /**< EtherCAT slave configuration. */
|
||||||
ec_domain_t *domain, /**< EtherCAT domain. */
|
ec_domain_t *domain, /**< EtherCAT domain. */
|
||||||
uint8_t sync_index, /**< Sync manager index to use. */
|
uint8_t sync_index, /**< Sync manager index to use. */
|
||||||
ec_direction_t dir /**< Pdo direction. */
|
ec_direction_t dir /**< PDO direction. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&fmmu->list);
|
INIT_LIST_HEAD(&fmmu->list);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ typedef struct {
|
||||||
uint8_t sync_index; /**< Index of sync manager to use. */
|
uint8_t sync_index; /**< Index of sync manager to use. */
|
||||||
ec_direction_t dir; /**< FMMU direction. */
|
ec_direction_t dir; /**< FMMU direction. */
|
||||||
uint32_t logical_start_address; /**< Logical start address. */
|
uint32_t logical_start_address; /**< Logical start address. */
|
||||||
unsigned int data_size; /**< Covered Pdo size. */
|
unsigned int data_size; /**< Covered PDO size. */
|
||||||
} ec_fmmu_config_t;
|
} ec_fmmu_config_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
206
master/fsm_coe.c
206
master/fsm_coe.c
|
|
@ -74,24 +74,24 @@ void ec_fsm_coe_error(ec_fsm_coe_t *);
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sdo abort messages.
|
SDO abort messages.
|
||||||
The "abort Sdo transfer request" supplies an abort code,
|
The "abort SDO transfer request" supplies an abort code,
|
||||||
which can be translated to clear text. This table does
|
which can be translated to clear text. This table does
|
||||||
the mapping of the codes and messages.
|
the mapping of the codes and messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ec_code_msg_t sdo_abort_messages[] = {
|
const ec_code_msg_t sdo_abort_messages[] = {
|
||||||
{0x05030000, "Toggle bit not changed"},
|
{0x05030000, "Toggle bit not changed"},
|
||||||
{0x05040000, "Sdo protocol timeout"},
|
{0x05040000, "SDO protocol timeout"},
|
||||||
{0x05040001, "Client/Server command specifier not valid or unknown"},
|
{0x05040001, "Client/Server command specifier not valid or unknown"},
|
||||||
{0x05040005, "Out of memory"},
|
{0x05040005, "Out of memory"},
|
||||||
{0x06010000, "Unsupported access to an object"},
|
{0x06010000, "Unsupported access to an object"},
|
||||||
{0x06010001, "Attempt to read a write-only object"},
|
{0x06010001, "Attempt to read a write-only object"},
|
||||||
{0x06010002, "Attempt to write a read-only object"},
|
{0x06010002, "Attempt to write a read-only object"},
|
||||||
{0x06020000, "This object does not exist in the object directory"},
|
{0x06020000, "This object does not exist in the object directory"},
|
||||||
{0x06040041, "The object cannot be mapped into the Pdo"},
|
{0x06040041, "The object cannot be mapped into the PDO"},
|
||||||
{0x06040042, "The number and length of the objects to be mapped would"
|
{0x06040042, "The number and length of the objects to be mapped would"
|
||||||
" exceed the Pdo length"},
|
" exceed the PDO length"},
|
||||||
{0x06040043, "General parameter incompatibility reason"},
|
{0x06040043, "General parameter incompatibility reason"},
|
||||||
{0x06040047, "Gerneral internal incompatibility in device"},
|
{0x06040047, "Gerneral internal incompatibility in device"},
|
||||||
{0x06060000, "Access failure due to a hardware error"},
|
{0x06060000, "Access failure due to a hardware error"},
|
||||||
|
|
@ -120,7 +120,7 @@ const ec_code_msg_t sdo_abort_messages[] = {
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Outputs an Sdo abort message.
|
Outputs an SDO abort message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ec_canopen_abort_msg(uint32_t abort_code)
|
void ec_canopen_abort_msg(uint32_t abort_code)
|
||||||
|
|
@ -129,13 +129,13 @@ void ec_canopen_abort_msg(uint32_t abort_code)
|
||||||
|
|
||||||
for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) {
|
for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) {
|
||||||
if (abort_msg->code == abort_code) {
|
if (abort_msg->code == abort_code) {
|
||||||
EC_ERR("Sdo abort message 0x%08X: \"%s\".\n",
|
EC_ERR("SDO abort message 0x%08X: \"%s\".\n",
|
||||||
abort_msg->code, abort_msg->message);
|
abort_msg->code, abort_msg->message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_ERR("Unknown Sdo abort code 0x%08X.\n", abort_code);
|
EC_ERR("Unknown SDO abort code 0x%08X.\n", abort_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -165,7 +165,7 @@ void ec_fsm_coe_clear(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Starts reading a slaves' Sdo dictionary.
|
Starts reading a slaves' SDO dictionary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ec_fsm_coe_dictionary(ec_fsm_coe_t *fsm, /**< finite state machine */
|
void ec_fsm_coe_dictionary(ec_fsm_coe_t *fsm, /**< finite state machine */
|
||||||
|
|
@ -179,13 +179,13 @@ void ec_fsm_coe_dictionary(ec_fsm_coe_t *fsm, /**< finite state machine */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Starts to transfer an Sdo to/from a slave.
|
Starts to transfer an SDO to/from a slave.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ec_fsm_coe_transfer(
|
void ec_fsm_coe_transfer(
|
||||||
ec_fsm_coe_t *fsm, /**< State machine. */
|
ec_fsm_coe_t *fsm, /**< State machine. */
|
||||||
ec_slave_t *slave, /**< EtherCAT slave. */
|
ec_slave_t *slave, /**< EtherCAT slave. */
|
||||||
ec_sdo_request_t *request /**< Sdo request. */
|
ec_sdo_request_t *request /**< SDO request. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->slave = slave;
|
fsm->slave = slave;
|
||||||
|
|
@ -275,7 +275,7 @@ void ec_fsm_coe_dict_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave->sii.has_general && !slave->sii.coe_details.enable_sdo_info) {
|
if (slave->sii.has_general && !slave->sii.coe_details.enable_sdo_info) {
|
||||||
EC_ERR("Slave %u does not support Sdo information service!\n",
|
EC_ERR("Slave %u does not support SDO information service!\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
|
|
@ -287,11 +287,11 @@ void ec_fsm_coe_dict_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x8 << 12); // Sdo information
|
EC_WRITE_U16(data, 0x8 << 12); // SDO information
|
||||||
EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request
|
EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request
|
||||||
EC_WRITE_U8 (data + 3, 0x00);
|
EC_WRITE_U8 (data + 3, 0x00);
|
||||||
EC_WRITE_U16(data + 4, 0x0000);
|
EC_WRITE_U16(data + 4, 0x0000);
|
||||||
EC_WRITE_U16(data + 6, 0x0001); // deliver all Sdos!
|
EC_WRITE_U16(data + 6, 0x0001); // deliver all SDOs!
|
||||||
|
|
||||||
fsm->retries = EC_FSM_RETRIES;
|
fsm->retries = EC_FSM_RETRIES;
|
||||||
fsm->state = ec_fsm_coe_dict_request;
|
fsm->state = ec_fsm_coe_dict_request;
|
||||||
|
|
@ -370,7 +370,7 @@ void ec_fsm_coe_dict_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo dictionary list response "
|
EC_ERR("Timeout while waiting for SDO dictionary list response "
|
||||||
"on slave %u.\n", slave->ring_position);
|
"on slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -443,18 +443,18 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 3) {
|
if (rec_size < 3) {
|
||||||
EC_ERR("Received corrupted Sdo dictionary response (size %u).\n",
|
EC_ERR("Received corrupted SDO dictionary response (size %u).\n",
|
||||||
rec_size);
|
rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x8 && // Sdo information
|
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
|
||||||
(EC_READ_U8(data + 2) & 0x7F) == 0x07) { // error response
|
(EC_READ_U8(data + 2) & 0x7F) == 0x07) { // error response
|
||||||
EC_ERR("Sdo information error response at slave %u!\n",
|
EC_ERR("SDO information error response at slave %u!\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
if (rec_size < 10) {
|
if (rec_size < 10) {
|
||||||
EC_ERR("Incomplete Sdo information error response:\n");
|
EC_ERR("Incomplete SDO information error response:\n");
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
} else {
|
} else {
|
||||||
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
||||||
|
|
@ -463,10 +463,10 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x8 || // Sdo information
|
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
|
||||||
(EC_READ_U8 (data + 2) & 0x7F) != 0x02) { // Get OD List response
|
(EC_READ_U8 (data + 2) & 0x7F) != 0x02) { // Get OD List response
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid Sdo list response at slave %u! Retrying...\n",
|
EC_DBG("Invalid SDO list response at slave %u! Retrying...\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -489,13 +489,13 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
sdo_index = EC_READ_U16(data + 8 + i * 2);
|
sdo_index = EC_READ_U16(data + 8 + i * 2);
|
||||||
if (!sdo_index) {
|
if (!sdo_index) {
|
||||||
if (slave->master->debug_level)
|
if (slave->master->debug_level)
|
||||||
EC_WARN("Sdo dictionary of slave %u contains index 0x0000.\n",
|
EC_WARN("SDO dictionary of slave %u contains index 0x0000.\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_KERNEL))) {
|
if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate memory for Sdo!\n");
|
EC_ERR("Failed to allocate memory for SDO!\n");
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -506,7 +506,7 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
|
|
||||||
fragments_left = EC_READ_U16(data + 4);
|
fragments_left = EC_READ_U16(data + 4);
|
||||||
if (slave->master->debug_level && fragments_left) {
|
if (slave->master->debug_level && fragments_left) {
|
||||||
EC_DBG("Sdo list fragments left: %u\n", fragments_left);
|
EC_DBG("SDO list fragments left: %u\n", fragments_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U8(data + 2) & 0x80 || fragments_left) { // more messages waiting. check again.
|
if (EC_READ_U8(data + 2) & 0x80 || fragments_left) { // more messages waiting. check again.
|
||||||
|
|
@ -518,12 +518,12 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_empty(&slave->sdo_dictionary)) {
|
if (list_empty(&slave->sdo_dictionary)) {
|
||||||
// no Sdos in dictionary. finished.
|
// no SDOs in dictionary. finished.
|
||||||
fsm->state = ec_fsm_coe_end; // success
|
fsm->state = ec_fsm_coe_end; // success
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch Sdo descriptions
|
// fetch SDO descriptions
|
||||||
fsm->sdo = list_entry(slave->sdo_dictionary.next, ec_sdo_t, list);
|
fsm->sdo = list_entry(slave->sdo_dictionary.next, ec_sdo_t, list);
|
||||||
|
|
||||||
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8);
|
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8);
|
||||||
|
|
@ -532,11 +532,11 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x8 << 12); // Sdo information
|
EC_WRITE_U16(data, 0x8 << 12); // SDO information
|
||||||
EC_WRITE_U8 (data + 2, 0x03); // Get object description request
|
EC_WRITE_U8 (data + 2, 0x03); // Get object description request
|
||||||
EC_WRITE_U8 (data + 3, 0x00);
|
EC_WRITE_U8 (data + 3, 0x00);
|
||||||
EC_WRITE_U16(data + 4, 0x0000);
|
EC_WRITE_U16(data + 4, 0x0000);
|
||||||
EC_WRITE_U16(data + 6, fsm->sdo->index); // Sdo index
|
EC_WRITE_U16(data + 6, fsm->sdo->index); // SDO index
|
||||||
|
|
||||||
fsm->retries = EC_FSM_RETRIES;
|
fsm->retries = EC_FSM_RETRIES;
|
||||||
fsm->state = ec_fsm_coe_dict_desc_request;
|
fsm->state = ec_fsm_coe_dict_desc_request;
|
||||||
|
|
@ -559,7 +559,7 @@ void ec_fsm_coe_dict_desc_request(ec_fsm_coe_t *fsm /**< finite state machine */
|
||||||
|
|
||||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Failed to receive CoE Sdo description request datagram for"
|
EC_ERR("Failed to receive CoE SDO description request datagram for"
|
||||||
" slave %u (datagram state %u).\n",
|
" slave %u (datagram state %u).\n",
|
||||||
slave->ring_position, datagram->state);
|
slave->ring_position, datagram->state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -567,7 +567,7 @@ void ec_fsm_coe_dict_desc_request(ec_fsm_coe_t *fsm /**< finite state machine */
|
||||||
|
|
||||||
if (datagram->working_counter != 1) {
|
if (datagram->working_counter != 1) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Reception of CoE Sdo description"
|
EC_ERR("Reception of CoE SDO description"
|
||||||
" request failed on slave %u: ", slave->ring_position);
|
" request failed on slave %u: ", slave->ring_position);
|
||||||
ec_datagram_print_wc_error(datagram);
|
ec_datagram_print_wc_error(datagram);
|
||||||
return;
|
return;
|
||||||
|
|
@ -615,7 +615,7 @@ void ec_fsm_coe_dict_desc_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo object description "
|
EC_ERR("Timeout while waiting for SDO object description "
|
||||||
"response on slave %u.\n", slave->ring_position);
|
"response on slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -652,7 +652,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Failed to receive CoE Sdo description response datagram from"
|
EC_ERR("Failed to receive CoE SDO description response datagram from"
|
||||||
" slave %u (datagram state %u).\n",
|
" slave %u (datagram state %u).\n",
|
||||||
slave->ring_position, datagram->state);
|
slave->ring_position, datagram->state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -660,7 +660,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->working_counter != 1) {
|
if (datagram->working_counter != 1) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Reception of CoE Sdo description"
|
EC_ERR("Reception of CoE SDO description"
|
||||||
" response failed on slave %u: ", slave->ring_position);
|
" response failed on slave %u: ", slave->ring_position);
|
||||||
ec_datagram_print_wc_error(datagram);
|
ec_datagram_print_wc_error(datagram);
|
||||||
return;
|
return;
|
||||||
|
|
@ -687,16 +687,16 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 3) {
|
if (rec_size < 3) {
|
||||||
EC_ERR("Received corrupted Sdo description response (size %u).\n",
|
EC_ERR("Received corrupted SDO description response (size %u).\n",
|
||||||
rec_size);
|
rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x8 && // Sdo information
|
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
|
||||||
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response
|
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response
|
||||||
EC_ERR("Sdo information error response at slave %u while"
|
EC_ERR("SDO information error response at slave %u while"
|
||||||
" fetching Sdo 0x%04X!\n", slave->ring_position,
|
" fetching SDO 0x%04X!\n", slave->ring_position,
|
||||||
sdo->index);
|
sdo->index);
|
||||||
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
|
|
@ -704,18 +704,18 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 8) {
|
if (rec_size < 8) {
|
||||||
EC_ERR("Received corrupted Sdo description response (size %u).\n",
|
EC_ERR("Received corrupted SDO description response (size %u).\n",
|
||||||
rec_size);
|
rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x8 || // Sdo information
|
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
|
||||||
(EC_READ_U8 (data + 2) & 0x7F) != 0x04 || // Object desc. response
|
(EC_READ_U8 (data + 2) & 0x7F) != 0x04 || // Object desc. response
|
||||||
EC_READ_U16(data + 6) != sdo->index) { // Sdo index
|
EC_READ_U16(data + 6) != sdo->index) { // SDO index
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid object description response at slave %u while"
|
EC_DBG("Invalid object description response at slave %u while"
|
||||||
" fetching Sdo 0x%04X!\n", slave->ring_position,
|
" fetching SDO 0x%04X!\n", slave->ring_position,
|
||||||
sdo->index);
|
sdo->index);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -739,7 +739,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
name_size = rec_size - 12;
|
name_size = rec_size - 12;
|
||||||
if (name_size) {
|
if (name_size) {
|
||||||
if (!(sdo->name = kmalloc(name_size + 1, GFP_KERNEL))) {
|
if (!(sdo->name = kmalloc(name_size + 1, GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Sdo name!\n");
|
EC_ERR("Failed to allocate SDO name!\n");
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -764,12 +764,12 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x8 << 12); // Sdo information
|
EC_WRITE_U16(data, 0x8 << 12); // SDO information
|
||||||
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request
|
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request
|
||||||
EC_WRITE_U8 (data + 3, 0x00);
|
EC_WRITE_U8 (data + 3, 0x00);
|
||||||
EC_WRITE_U16(data + 4, 0x0000);
|
EC_WRITE_U16(data + 4, 0x0000);
|
||||||
EC_WRITE_U16(data + 6, sdo->index); // Sdo index
|
EC_WRITE_U16(data + 6, sdo->index); // SDO index
|
||||||
EC_WRITE_U8 (data + 8, fsm->subindex); // Sdo subindex
|
EC_WRITE_U8 (data + 8, fsm->subindex); // SDO subindex
|
||||||
EC_WRITE_U8 (data + 9, 0x00); // value info (no values)
|
EC_WRITE_U8 (data + 9, 0x00); // value info (no values)
|
||||||
|
|
||||||
fsm->retries = EC_FSM_RETRIES;
|
fsm->retries = EC_FSM_RETRIES;
|
||||||
|
|
@ -794,7 +794,7 @@ void ec_fsm_coe_dict_entry_request(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Failed to receive CoE Sdo entry request datagram for"
|
EC_ERR("Failed to receive CoE SDO entry request datagram for"
|
||||||
" slave %u (datagram state %u).\n",
|
" slave %u (datagram state %u).\n",
|
||||||
slave->ring_position, datagram->state);
|
slave->ring_position, datagram->state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -802,7 +802,7 @@ void ec_fsm_coe_dict_entry_request(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->working_counter != 1) {
|
if (datagram->working_counter != 1) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Reception of CoE Sdo entry request failed on slave %u: ",
|
EC_ERR("Reception of CoE SDO entry request failed on slave %u: ",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_datagram_print_wc_error(datagram);
|
ec_datagram_print_wc_error(datagram);
|
||||||
return;
|
return;
|
||||||
|
|
@ -851,7 +851,7 @@ void ec_fsm_coe_dict_entry_check(ec_fsm_coe_t *fsm
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
if (diff_ms >= EC_FSM_COE_DICT_TIMEOUT) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo entry description response "
|
EC_ERR("Timeout while waiting for SDO entry description response "
|
||||||
"on slave %u.\n", slave->ring_position);
|
"on slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -889,7 +889,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Failed to receive CoE Sdo description response datagram from"
|
EC_ERR("Failed to receive CoE SDO description response datagram from"
|
||||||
" slave %u (datagram state %u).\n",
|
" slave %u (datagram state %u).\n",
|
||||||
slave->ring_position, datagram->state);
|
slave->ring_position, datagram->state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -897,7 +897,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
|
|
||||||
if (datagram->working_counter != 1) {
|
if (datagram->working_counter != 1) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Reception of CoE Sdo description"
|
EC_ERR("Reception of CoE SDO description"
|
||||||
" response failed on slave %u: ", slave->ring_position);
|
" response failed on slave %u: ", slave->ring_position);
|
||||||
ec_datagram_print_wc_error(datagram);
|
ec_datagram_print_wc_error(datagram);
|
||||||
return;
|
return;
|
||||||
|
|
@ -924,16 +924,16 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 3) {
|
if (rec_size < 3) {
|
||||||
EC_ERR("Received corrupted Sdo entry description response "
|
EC_ERR("Received corrupted SDO entry description response "
|
||||||
"(size %u).\n", rec_size);
|
"(size %u).\n", rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x8 && // Sdo information
|
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
|
||||||
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response
|
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response
|
||||||
EC_ERR("Sdo information error response at slave %u while"
|
EC_ERR("SDO information error response at slave %u while"
|
||||||
" fetching Sdo entry 0x%04X:%02X!\n", slave->ring_position,
|
" fetching SDO entry 0x%04X:%02X!\n", slave->ring_position,
|
||||||
sdo->index, fsm->subindex);
|
sdo->index, fsm->subindex);
|
||||||
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
ec_canopen_abort_msg(EC_READ_U32(data + 6));
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
|
|
@ -941,19 +941,19 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 9) {
|
if (rec_size < 9) {
|
||||||
EC_ERR("Received corrupted Sdo entry description response "
|
EC_ERR("Received corrupted SDO entry description response "
|
||||||
"(size %u).\n", rec_size);
|
"(size %u).\n", rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x8 || // Sdo information
|
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
|
||||||
(EC_READ_U8(data + 2) & 0x7F) != 0x06 || // Entry desc. response
|
(EC_READ_U8(data + 2) & 0x7F) != 0x06 || // Entry desc. response
|
||||||
EC_READ_U16(data + 6) != sdo->index || // Sdo index
|
EC_READ_U16(data + 6) != sdo->index || // SDO index
|
||||||
EC_READ_U8(data + 8) != fsm->subindex) { // Sdo subindex
|
EC_READ_U8(data + 8) != fsm->subindex) { // SDO subindex
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid entry description response at slave %u while"
|
EC_DBG("Invalid entry description response at slave %u while"
|
||||||
" fetching Sdo entry 0x%04X:%02X!\n", slave->ring_position,
|
" fetching SDO entry 0x%04X:%02X!\n", slave->ring_position,
|
||||||
sdo->index, fsm->subindex);
|
sdo->index, fsm->subindex);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -987,7 +987,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
if (data_size) {
|
if (data_size) {
|
||||||
uint8_t *desc;
|
uint8_t *desc;
|
||||||
if (!(desc = kmalloc(data_size + 1, GFP_KERNEL))) {
|
if (!(desc = kmalloc(data_size + 1, GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Sdo entry name!\n");
|
EC_ERR("Failed to allocate SDO entry name!\n");
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1007,12 +1007,12 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x8 << 12); // Sdo information
|
EC_WRITE_U16(data, 0x8 << 12); // SDO information
|
||||||
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request
|
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request
|
||||||
EC_WRITE_U8 (data + 3, 0x00);
|
EC_WRITE_U8 (data + 3, 0x00);
|
||||||
EC_WRITE_U16(data + 4, 0x0000);
|
EC_WRITE_U16(data + 4, 0x0000);
|
||||||
EC_WRITE_U16(data + 6, sdo->index); // Sdo index
|
EC_WRITE_U16(data + 6, sdo->index); // SDO index
|
||||||
EC_WRITE_U8 (data + 8, fsm->subindex); // Sdo subindex
|
EC_WRITE_U8 (data + 8, fsm->subindex); // SDO subindex
|
||||||
EC_WRITE_U8 (data + 9, 0x00); // value info (no values)
|
EC_WRITE_U8 (data + 9, 0x00); // value info (no values)
|
||||||
|
|
||||||
fsm->retries = EC_FSM_RETRIES;
|
fsm->retries = EC_FSM_RETRIES;
|
||||||
|
|
@ -1020,7 +1020,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// another Sdo description to fetch?
|
// another SDO description to fetch?
|
||||||
if (fsm->sdo->list.next != &slave->sdo_dictionary) {
|
if (fsm->sdo->list.next != &slave->sdo_dictionary) {
|
||||||
fsm->sdo = list_entry(fsm->sdo->list.next, ec_sdo_t, list);
|
fsm->sdo = list_entry(fsm->sdo->list.next, ec_sdo_t, list);
|
||||||
|
|
||||||
|
|
@ -1030,11 +1030,11 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x8 << 12); // Sdo information
|
EC_WRITE_U16(data, 0x8 << 12); // SDO information
|
||||||
EC_WRITE_U8 (data + 2, 0x03); // Get object description request
|
EC_WRITE_U8 (data + 2, 0x03); // Get object description request
|
||||||
EC_WRITE_U8 (data + 3, 0x00);
|
EC_WRITE_U8 (data + 3, 0x00);
|
||||||
EC_WRITE_U16(data + 4, 0x0000);
|
EC_WRITE_U16(data + 4, 0x0000);
|
||||||
EC_WRITE_U16(data + 6, fsm->sdo->index); // Sdo index
|
EC_WRITE_U16(data + 6, fsm->sdo->index); // SDO index
|
||||||
|
|
||||||
fsm->retries = EC_FSM_RETRIES;
|
fsm->retries = EC_FSM_RETRIES;
|
||||||
fsm->state = ec_fsm_coe_dict_desc_request;
|
fsm->state = ec_fsm_coe_dict_desc_request;
|
||||||
|
|
@ -1061,7 +1061,7 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Downloading Sdo 0x%04X:%02X to slave %u.\n",
|
EC_DBG("Downloading SDO 0x%04X:%02X to slave %u.\n",
|
||||||
request->index, request->subindex, slave->ring_position);
|
request->index, request->subindex, slave->ring_position);
|
||||||
ec_print_data(request->data, request->data_size);
|
ec_print_data(request->data, request->data_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1081,7 +1081,7 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
|
|
||||||
size = 4 - request->data_size;
|
size = 4 - request->data_size;
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x2 << 12); // Sdo request
|
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||||
EC_WRITE_U8 (data + 2, (0x3 // size specified, expedited
|
EC_WRITE_U8 (data + 2, (0x3 // size specified, expedited
|
||||||
| size << 2
|
| size << 2
|
||||||
| 0x1 << 5)); // Download request
|
| 0x1 << 5)); // Download request
|
||||||
|
|
@ -1096,7 +1096,7 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
}
|
}
|
||||||
else { // request->data_size > 4, use normal transfer type
|
else { // request->data_size > 4, use normal transfer type
|
||||||
if (slave->sii.rx_mailbox_size < 6 + 10 + request->data_size) {
|
if (slave->sii.rx_mailbox_size < 6 + 10 + request->data_size) {
|
||||||
EC_ERR("Sdo fragmenting not supported yet!\n");
|
EC_ERR("SDO fragmenting not supported yet!\n");
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1108,7 +1108,7 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x2 << 12); // Sdo request
|
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||||
EC_WRITE_U8 (data + 2, (0x1 // size indicator, normal
|
EC_WRITE_U8 (data + 2, (0x1 // size indicator, normal
|
||||||
| 0x1 << 5)); // Download request
|
| 0x1 << 5)); // Download request
|
||||||
EC_WRITE_U16(data + 3, request->index);
|
EC_WRITE_U16(data + 3, request->index);
|
||||||
|
|
@ -1156,7 +1156,7 @@ void ec_fsm_coe_down_request(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
|
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
|
||||||
if (diff_ms < fsm->request->response_timeout) {
|
if (diff_ms < fsm->request->response_timeout) {
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Slave %u did not respond to Sdo download request. "
|
EC_DBG("Slave %u did not respond to SDO download request. "
|
||||||
"Retrying after %u ms...\n",
|
"Retrying after %u ms...\n",
|
||||||
slave->ring_position, (u32) diff_ms);
|
slave->ring_position, (u32) diff_ms);
|
||||||
}
|
}
|
||||||
|
|
@ -1213,7 +1213,7 @@ void ec_fsm_coe_down_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= fsm->request->response_timeout) {
|
if (diff_ms >= fsm->request->response_timeout) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo download response on "
|
EC_ERR("Timeout while waiting for SDO download response on "
|
||||||
"slave %u.\n", slave->ring_position);
|
"slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1295,10 +1295,10 @@ void ec_fsm_coe_down_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x2 && // Sdo request
|
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
|
||||||
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort Sdo transfer request
|
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Sdo download 0x%04X:%02X (%u bytes) aborted on slave %u.\n",
|
EC_ERR("SDO download 0x%04X:%02X (%u bytes) aborted on slave %u.\n",
|
||||||
request->index, request->subindex, request->data_size,
|
request->index, request->subindex, request->data_size,
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
if (rec_size < 10) {
|
if (rec_size < 10) {
|
||||||
|
|
@ -1311,12 +1311,12 @@ void ec_fsm_coe_down_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x3 || // Sdo response
|
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
|
||||||
EC_READ_U8 (data + 2) >> 5 != 0x3 || // Download response
|
EC_READ_U8 (data + 2) >> 5 != 0x3 || // Download response
|
||||||
EC_READ_U16(data + 3) != request->index || // index
|
EC_READ_U16(data + 3) != request->index || // index
|
||||||
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
||||||
if (slave->master->debug_level) {
|
if (slave->master->debug_level) {
|
||||||
EC_DBG("Invalid Sdo download response at slave %u! Retrying...\n",
|
EC_DBG("Invalid SDO download response at slave %u! Retrying...\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1345,7 +1345,7 @@ void ec_fsm_coe_up_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|
||||||
if (master->debug_level)
|
if (master->debug_level)
|
||||||
EC_DBG("Uploading Sdo 0x%04X:%02X from slave %u.\n",
|
EC_DBG("Uploading SDO 0x%04X:%02X from slave %u.\n",
|
||||||
request->index, request->subindex, slave->ring_position);
|
request->index, request->subindex, slave->ring_position);
|
||||||
|
|
||||||
if (!(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
|
if (!(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
|
||||||
|
|
@ -1360,7 +1360,7 @@ void ec_fsm_coe_up_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x2 << 12); // Sdo request
|
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||||
EC_WRITE_U8 (data + 2, 0x2 << 5); // initiate upload request
|
EC_WRITE_U8 (data + 2, 0x2 << 5); // initiate upload request
|
||||||
EC_WRITE_U16(data + 3, request->index);
|
EC_WRITE_U16(data + 3, request->index);
|
||||||
EC_WRITE_U8 (data + 5, request->subindex);
|
EC_WRITE_U8 (data + 5, request->subindex);
|
||||||
|
|
@ -1405,7 +1405,7 @@ void ec_fsm_coe_up_request(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
|
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
|
||||||
if (diff_ms < fsm->request->response_timeout) {
|
if (diff_ms < fsm->request->response_timeout) {
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Slave %u did not respond to Sdo upload request. "
|
EC_DBG("Slave %u did not respond to SDO upload request. "
|
||||||
"Retrying after %u ms...\n",
|
"Retrying after %u ms...\n",
|
||||||
slave->ring_position, (u32) diff_ms);
|
slave->ring_position, (u32) diff_ms);
|
||||||
}
|
}
|
||||||
|
|
@ -1462,7 +1462,7 @@ void ec_fsm_coe_up_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= fsm->request->response_timeout) {
|
if (diff_ms >= fsm->request->response_timeout) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo upload response on "
|
EC_ERR("Timeout while waiting for SDO upload response on "
|
||||||
"slave %u.\n", slave->ring_position);
|
"slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1542,14 +1542,14 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
|
|
||||||
if (rec_size < 3) {
|
if (rec_size < 3) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Received currupted Sdo upload response (%u bytes)!\n", rec_size);
|
EC_ERR("Received currupted SDO upload response (%u bytes)!\n", rec_size);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x2 && // Sdo request
|
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
|
||||||
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort Sdo transfer request
|
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request
|
||||||
EC_ERR("Sdo upload 0x%04X:%02X aborted on slave %u.\n",
|
EC_ERR("SDO upload 0x%04X:%02X aborted on slave %u.\n",
|
||||||
request->index, request->subindex, slave->ring_position);
|
request->index, request->subindex, slave->ring_position);
|
||||||
if (rec_size >= 10) {
|
if (rec_size >= 10) {
|
||||||
request->abort_code = EC_READ_U32(data + 6);
|
request->abort_code = EC_READ_U32(data + 6);
|
||||||
|
|
@ -1567,18 +1567,18 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
if (expedited) {
|
if (expedited) {
|
||||||
if (rec_size < 7) {
|
if (rec_size < 7) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Received currupted Sdo expedited upload"
|
EC_ERR("Received currupted SDO expedited upload"
|
||||||
" response (only %u bytes)!\n", rec_size);
|
" response (only %u bytes)!\n", rec_size);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x3 || // Sdo response
|
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
|
||||||
EC_READ_U8 (data + 2) >> 5 != 0x2 || // upload response
|
EC_READ_U8 (data + 2) >> 5 != 0x2 || // upload response
|
||||||
EC_READ_U16(data + 3) != request->index || // index
|
EC_READ_U16(data + 3) != request->index || // index
|
||||||
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid Sdo upload expedited response at slave %u!\n",
|
EC_DBG("Invalid SDO upload expedited response at slave %u!\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1598,7 +1598,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
|
|
||||||
if (rec_size < 6 + complete_size) {
|
if (rec_size < 6 + complete_size) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Received currupted Sdo expedited upload"
|
EC_ERR("Received currupted SDO expedited upload"
|
||||||
" response (only %u bytes)!\n", rec_size);
|
" response (only %u bytes)!\n", rec_size);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1611,18 +1611,18 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
} else { // normal
|
} else { // normal
|
||||||
if (rec_size < 10) {
|
if (rec_size < 10) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Received currupted Sdo normal upload"
|
EC_ERR("Received currupted SDO normal upload"
|
||||||
" response (only %u bytes)!\n", rec_size);
|
" response (only %u bytes)!\n", rec_size);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x3 || // Sdo response
|
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
|
||||||
EC_READ_U8 (data + 2) >> 5 != 0x2 || // upload response
|
EC_READ_U8 (data + 2) >> 5 != 0x2 || // upload response
|
||||||
EC_READ_U16(data + 3) != request->index || // index
|
EC_READ_U16(data + 3) != request->index || // index
|
||||||
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
EC_READ_U8 (data + 5) != request->subindex) { // subindex
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid Sdo normal upload response at slave %u!\n",
|
EC_DBG("Invalid SDO normal upload response at slave %u!\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1656,7 +1656,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
fsm->toggle = 0;
|
fsm->toggle = 0;
|
||||||
|
|
||||||
if (data_size < complete_size) {
|
if (data_size < complete_size) {
|
||||||
EC_WARN("Sdo data incomplete (%u / %u).\n",
|
EC_WARN("SDO data incomplete (%u / %u).\n",
|
||||||
data_size, complete_size);
|
data_size, complete_size);
|
||||||
|
|
||||||
data = ec_slave_mbox_prepare_send(slave, datagram,
|
data = ec_slave_mbox_prepare_send(slave, datagram,
|
||||||
|
|
@ -1666,7 +1666,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x2 << 12); // Sdo request
|
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||||
EC_WRITE_U8 (data + 2, (fsm->toggle << 4 // toggle
|
EC_WRITE_U8 (data + 2, (fsm->toggle << 4 // toggle
|
||||||
| 0x3 << 5)); // upload segment request
|
| 0x3 << 5)); // upload segment request
|
||||||
|
|
||||||
|
|
@ -1762,7 +1762,7 @@ void ec_fsm_coe_up_seg_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||||
if (diff_ms >= fsm->request->response_timeout) {
|
if (diff_ms >= fsm->request->response_timeout) {
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
EC_ERR("Timeout while waiting for Sdo upload segment response "
|
EC_ERR("Timeout while waiting for SDO upload segment response "
|
||||||
"on slave %u.\n", slave->ring_position);
|
"on slave %u.\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1842,15 +1842,15 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_size < 10) {
|
if (rec_size < 10) {
|
||||||
EC_ERR("Received currupted Sdo upload segment response!\n");
|
EC_ERR("Received currupted SDO upload segment response!\n");
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
fsm->state = ec_fsm_coe_error;
|
fsm->state = ec_fsm_coe_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 == 0x2 && // Sdo request
|
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
|
||||||
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort Sdo transfer request
|
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request
|
||||||
EC_ERR("Sdo upload 0x%04X:%02X aborted on slave %u.\n",
|
EC_ERR("SDO upload 0x%04X:%02X aborted on slave %u.\n",
|
||||||
request->index, request->subindex, slave->ring_position);
|
request->index, request->subindex, slave->ring_position);
|
||||||
request->abort_code = EC_READ_U32(data + 6);
|
request->abort_code = EC_READ_U32(data + 6);
|
||||||
ec_canopen_abort_msg(request->abort_code);
|
ec_canopen_abort_msg(request->abort_code);
|
||||||
|
|
@ -1858,10 +1858,10 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC_READ_U16(data) >> 12 != 0x3 || // Sdo response
|
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
|
||||||
EC_READ_U8 (data + 2) >> 5 != 0x0) { // upload segment response
|
EC_READ_U8 (data + 2) >> 5 != 0x0) { // upload segment response
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Invalid Sdo upload segment response at slave %u!\n",
|
EC_DBG("Invalid SDO upload segment response at slave %u!\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
ec_print_data(data, rec_size);
|
ec_print_data(data, rec_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1877,7 +1877,7 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
data_size = rec_size - 10;
|
data_size = rec_size - 10;
|
||||||
|
|
||||||
if (data_size != seg_size) {
|
if (data_size != seg_size) {
|
||||||
EC_WARN("Sdo segment data invalid (%u / %u)"
|
EC_WARN("SDO segment data invalid (%u / %u)"
|
||||||
" - Fragmenting not implemented.\n",
|
" - Fragmenting not implemented.\n",
|
||||||
data_size, seg_size);
|
data_size, seg_size);
|
||||||
}
|
}
|
||||||
|
|
@ -1894,7 +1894,7 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_WRITE_U16(data, 0x2 << 12); // Sdo request
|
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||||
EC_WRITE_U8 (data + 2, (fsm->toggle << 4 // toggle
|
EC_WRITE_U8 (data + 2, (fsm->toggle << 4 // toggle
|
||||||
| 0x3 << 5)); // upload segment request
|
| 0x3 << 5)); // upload segment request
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
typedef struct ec_fsm_coe ec_fsm_coe_t; /**< \see ec_fsm_coe */
|
typedef struct ec_fsm_coe ec_fsm_coe_t; /**< \see ec_fsm_coe */
|
||||||
|
|
||||||
/** Finite state machines for the CANopen-over-EtherCAT protocol.
|
/** Finite state machines for the CANopen over EtherCAT protocol.
|
||||||
*/
|
*/
|
||||||
struct ec_fsm_coe {
|
struct ec_fsm_coe {
|
||||||
ec_slave_t *slave; /**< slave the FSM runs on */
|
ec_slave_t *slave; /**< slave the FSM runs on */
|
||||||
|
|
@ -53,9 +53,9 @@ struct ec_fsm_coe {
|
||||||
|
|
||||||
void (*state)(ec_fsm_coe_t *); /**< CoE state function */
|
void (*state)(ec_fsm_coe_t *); /**< CoE state function */
|
||||||
unsigned long jiffies_start; /**< CoE timestamp. */
|
unsigned long jiffies_start; /**< CoE timestamp. */
|
||||||
ec_sdo_t *sdo; /**< current Sdo */
|
ec_sdo_t *sdo; /**< current SDO */
|
||||||
uint8_t subindex; /**< current subindex */
|
uint8_t subindex; /**< current subindex */
|
||||||
ec_sdo_request_t *request; /**< Sdo request */
|
ec_sdo_request_t *request; /**< SDO request */
|
||||||
uint8_t toggle; /**< toggle bit for segment commands */
|
uint8_t toggle; /**< toggle bit for segment commands */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -374,9 +374,9 @@ int ec_fsm_master_action_process_phy(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Check for pending Sdo requests and process one.
|
/** Check for pending SDO requests and process one.
|
||||||
*
|
*
|
||||||
* \return non-zero, if an Sdo request is processed.
|
* \return non-zero, if an SDO request is processed.
|
||||||
*/
|
*/
|
||||||
int ec_fsm_master_action_process_sdo(
|
int ec_fsm_master_action_process_sdo(
|
||||||
ec_fsm_master_t *fsm /**< Master state machine. */
|
ec_fsm_master_t *fsm /**< Master state machine. */
|
||||||
|
|
@ -399,7 +399,7 @@ int ec_fsm_master_action_process_sdo(
|
||||||
if (ec_sdo_request_timed_out(req)) {
|
if (ec_sdo_request_timed_out(req)) {
|
||||||
req->state = EC_INT_REQUEST_FAILURE;
|
req->state = EC_INT_REQUEST_FAILURE;
|
||||||
if (master->debug_level)
|
if (master->debug_level)
|
||||||
EC_DBG("Sdo request for slave %u timed out...\n",
|
EC_DBG("SDO request for slave %u timed out...\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +411,7 @@ int ec_fsm_master_action_process_sdo(
|
||||||
|
|
||||||
req->state = EC_INT_REQUEST_BUSY;
|
req->state = EC_INT_REQUEST_BUSY;
|
||||||
if (master->debug_level)
|
if (master->debug_level)
|
||||||
EC_DBG("Processing Sdo request for slave %u...\n",
|
EC_DBG("Processing SDO request for slave %u...\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
|
|
||||||
fsm->idle = 0;
|
fsm->idle = 0;
|
||||||
|
|
@ -438,19 +438,19 @@ int ec_fsm_master_action_process_sdo(
|
||||||
|
|
||||||
slave = request->slave;
|
slave = request->slave;
|
||||||
if (slave->current_state == EC_SLAVE_STATE_INIT) {
|
if (slave->current_state == EC_SLAVE_STATE_INIT) {
|
||||||
EC_ERR("Discarding Sdo request, slave %u is in INIT.\n",
|
EC_ERR("Discarding SDO request, slave %u is in INIT.\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
request->req.state = EC_INT_REQUEST_FAILURE;
|
request->req.state = EC_INT_REQUEST_FAILURE;
|
||||||
wake_up(&master->sdo_queue);
|
wake_up(&master->sdo_queue);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found pending Sdo request. Execute it!
|
// Found pending SDO request. Execute it!
|
||||||
if (master->debug_level)
|
if (master->debug_level)
|
||||||
EC_DBG("Processing Sdo request for slave %u...\n",
|
EC_DBG("Processing SDO request for slave %u...\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
|
|
||||||
// Start uploading Sdo
|
// Start uploading SDO
|
||||||
fsm->idle = 0;
|
fsm->idle = 0;
|
||||||
fsm->sdo_request = &request->req;
|
fsm->sdo_request = &request->req;
|
||||||
fsm->slave = slave;
|
fsm->slave = slave;
|
||||||
|
|
@ -476,11 +476,11 @@ void ec_fsm_master_action_idle(
|
||||||
ec_master_t *master = fsm->master;
|
ec_master_t *master = fsm->master;
|
||||||
ec_slave_t *slave;
|
ec_slave_t *slave;
|
||||||
|
|
||||||
// Check for pending Sdo requests
|
// Check for pending SDO requests
|
||||||
if (ec_fsm_master_action_process_sdo(fsm))
|
if (ec_fsm_master_action_process_sdo(fsm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check, if slaves have an Sdo dictionary to read out.
|
// check, if slaves have an SDO dictionary to read out.
|
||||||
for (slave = master->slaves;
|
for (slave = master->slaves;
|
||||||
slave < master->slaves + master->slave_count;
|
slave < master->slaves + master->slave_count;
|
||||||
slave++) {
|
slave++) {
|
||||||
|
|
@ -494,13 +494,13 @@ void ec_fsm_master_action_idle(
|
||||||
) continue;
|
) continue;
|
||||||
|
|
||||||
if (master->debug_level) {
|
if (master->debug_level) {
|
||||||
EC_DBG("Fetching Sdo dictionary from slave %u.\n",
|
EC_DBG("Fetching SDO dictionary from slave %u.\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
slave->sdo_dictionary_fetched = 1;
|
slave->sdo_dictionary_fetched = 1;
|
||||||
|
|
||||||
// start fetching Sdo dictionary
|
// start fetching SDO dictionary
|
||||||
fsm->idle = 0;
|
fsm->idle = 0;
|
||||||
fsm->slave = slave;
|
fsm->slave = slave;
|
||||||
fsm->state = ec_fsm_master_state_sdo_dictionary;
|
fsm->state = ec_fsm_master_state_sdo_dictionary;
|
||||||
|
|
@ -869,12 +869,12 @@ void ec_fsm_master_state_sdo_dictionary(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sdo dictionary fetching finished
|
// SDO dictionary fetching finished
|
||||||
|
|
||||||
if (master->debug_level) {
|
if (master->debug_level) {
|
||||||
unsigned int sdo_count, entry_count;
|
unsigned int sdo_count, entry_count;
|
||||||
ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count);
|
ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count);
|
||||||
EC_DBG("Fetched %u Sdos and %u entries from slave %u.\n",
|
EC_DBG("Fetched %u SDOs and %u entries from slave %u.\n",
|
||||||
sdo_count, entry_count, slave->ring_position);
|
sdo_count, entry_count, slave->ring_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -898,7 +898,7 @@ void ec_fsm_master_state_sdo_request(
|
||||||
if (ec_fsm_coe_exec(&fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(&fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(&fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(&fsm->fsm_coe)) {
|
||||||
EC_DBG("Failed to process Sdo request for slave %u.\n",
|
EC_DBG("Failed to process SDO request for slave %u.\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
request->state = EC_INT_REQUEST_FAILURE;
|
request->state = EC_INT_REQUEST_FAILURE;
|
||||||
wake_up(&master->sdo_queue);
|
wake_up(&master->sdo_queue);
|
||||||
|
|
@ -906,15 +906,15 @@ void ec_fsm_master_state_sdo_request(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sdo request finished
|
// SDO request finished
|
||||||
request->state = EC_INT_REQUEST_SUCCESS;
|
request->state = EC_INT_REQUEST_SUCCESS;
|
||||||
wake_up(&master->sdo_queue);
|
wake_up(&master->sdo_queue);
|
||||||
|
|
||||||
if (master->debug_level)
|
if (master->debug_level)
|
||||||
EC_DBG("Finished Sdo request for slave %u.\n",
|
EC_DBG("Finished SDO request for slave %u.\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
|
|
||||||
// check for another Sdo request
|
// check for another SDO request
|
||||||
if (ec_fsm_master_action_process_sdo(fsm))
|
if (ec_fsm_master_action_process_sdo(fsm))
|
||||||
return; // processing another request
|
return; // processing another request
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,12 @@ typedef struct {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Slave/Sdo request record for master's Sdo request list.
|
/** Slave/SDO request record for master's SDO request list.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct list_head list; /**< List element. */
|
struct list_head list; /**< List element. */
|
||||||
ec_slave_t *slave; /**< Slave. */
|
ec_slave_t *slave; /**< Slave. */
|
||||||
ec_sdo_request_t req; /**< Sdo request. */
|
ec_sdo_request_t req; /**< SDO request. */
|
||||||
} ec_master_sdo_request_t;
|
} ec_master_sdo_request_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -98,11 +98,11 @@ struct ec_fsm_master {
|
||||||
ec_slave_t *slave; /**< current slave */
|
ec_slave_t *slave; /**< current slave */
|
||||||
ec_sii_write_request_t *sii_request; /**< SII write request */
|
ec_sii_write_request_t *sii_request; /**< SII write request */
|
||||||
off_t sii_index; /**< index to SII write request data */
|
off_t sii_index; /**< index to SII write request data */
|
||||||
ec_sdo_request_t *sdo_request; /**< Sdo request to process. */
|
ec_sdo_request_t *sdo_request; /**< SDO request to process. */
|
||||||
ec_phy_request_t *phy_request; /**< Physical memory request to process. */
|
ec_phy_request_t *phy_request; /**< Physical memory request to process. */
|
||||||
|
|
||||||
ec_fsm_coe_t fsm_coe; /**< CoE state machine */
|
ec_fsm_coe_t fsm_coe; /**< CoE state machine */
|
||||||
ec_fsm_pdo_t fsm_pdo; /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t fsm_pdo; /**< PDO configuration state machine. */
|
||||||
ec_fsm_change_t fsm_change; /**< State change state machine */
|
ec_fsm_change_t fsm_change; /**< State change state machine */
|
||||||
ec_fsm_slave_config_t fsm_slave_config; /**< 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_slave_scan_t fsm_slave_scan; /**< slave state machine */
|
||||||
|
|
|
||||||
182
master/fsm_pdo.c
182
master/fsm_pdo.c
|
|
@ -25,7 +25,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* EtherCAT Pdo configuration state machine.
|
* EtherCAT PDO configuration state machine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -69,7 +69,7 @@ void ec_fsm_pdo_state_error(ec_fsm_pdo_t *);
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_init(
|
void ec_fsm_pdo_init(
|
||||||
ec_fsm_pdo_t *fsm, /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm, /**< PDO configuration state machine. */
|
||||||
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */
|
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +85,7 @@ void ec_fsm_pdo_init(
|
||||||
/** Destructor.
|
/** Destructor.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_clear(
|
void ec_fsm_pdo_clear(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_fsm_pdo_entry_clear(&fsm->fsm_pdo_entry);
|
ec_fsm_pdo_entry_clear(&fsm->fsm_pdo_entry);
|
||||||
|
|
@ -96,10 +96,10 @@ void ec_fsm_pdo_clear(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Start reading the Pdo configuration.
|
/** Start reading the PDO configuration.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_start_reading(
|
void ec_fsm_pdo_start_reading(
|
||||||
ec_fsm_pdo_t *fsm, /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm, /**< PDO configuration state machine. */
|
||||||
ec_slave_t *slave /**< slave to configure */
|
ec_slave_t *slave /**< slave to configure */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -109,10 +109,10 @@ void ec_fsm_pdo_start_reading(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Start writing the Pdo configuration.
|
/** Start writing the PDO configuration.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_start_configuration(
|
void ec_fsm_pdo_start_configuration(
|
||||||
ec_fsm_pdo_t *fsm, /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm, /**< PDO configuration state machine. */
|
||||||
ec_slave_t *slave /**< slave to configure */
|
ec_slave_t *slave /**< slave to configure */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +127,7 @@ void ec_fsm_pdo_start_configuration(
|
||||||
* \return false, if state machine has terminated
|
* \return false, if state machine has terminated
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_running(
|
int ec_fsm_pdo_running(
|
||||||
const ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
const ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return fsm->state != ec_fsm_pdo_state_end
|
return fsm->state != ec_fsm_pdo_state_end
|
||||||
|
|
@ -144,7 +144,7 @@ int ec_fsm_pdo_running(
|
||||||
* \return false, if state machine has terminated
|
* \return false, if state machine has terminated
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_exec(
|
int ec_fsm_pdo_exec(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->state(fsm);
|
fsm->state(fsm);
|
||||||
|
|
@ -158,7 +158,7 @@ int ec_fsm_pdo_exec(
|
||||||
* \return true, if the state machine terminated gracefully
|
* \return true, if the state machine terminated gracefully
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_success(
|
int ec_fsm_pdo_success(
|
||||||
const ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
const ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return fsm->state == ec_fsm_pdo_state_end;
|
return fsm->state == ec_fsm_pdo_state_end;
|
||||||
|
|
@ -168,20 +168,20 @@ int ec_fsm_pdo_success(
|
||||||
* Reading state funtions.
|
* Reading state funtions.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** Start reading Pdo assignment.
|
/** Start reading PDO assignment.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_state_start(
|
void ec_fsm_pdo_read_state_start(
|
||||||
ec_fsm_pdo_t *fsm /**< finite state machine */
|
ec_fsm_pdo_t *fsm /**< finite state machine */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// read Pdo assignment for first sync manager not reserved for mailbox
|
// read PDO assignment for first sync manager not reserved for mailbox
|
||||||
fsm->sync_index = 1; // next is 2
|
fsm->sync_index = 1; // next is 2
|
||||||
ec_fsm_pdo_read_action_next_sync(fsm);
|
ec_fsm_pdo_read_action_next_sync(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Read Pdo assignment of next sync manager.
|
/** Read PDO assignment of next sync manager.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_action_next_sync(
|
void ec_fsm_pdo_read_action_next_sync(
|
||||||
ec_fsm_pdo_t *fsm /**< Finite state machine */
|
ec_fsm_pdo_t *fsm /**< Finite state machine */
|
||||||
|
|
@ -196,7 +196,7 @@ void ec_fsm_pdo_read_action_next_sync(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (slave->master->debug_level)
|
if (slave->master->debug_level)
|
||||||
EC_DBG("Reading Pdo assignment of SM%u.\n", fsm->sync_index);
|
EC_DBG("Reading PDO assignment of SM%u.\n", fsm->sync_index);
|
||||||
|
|
||||||
ec_pdo_list_clear_pdos(&fsm->pdos);
|
ec_pdo_list_clear_pdos(&fsm->pdos);
|
||||||
|
|
||||||
|
|
@ -209,14 +209,14 @@ void ec_fsm_pdo_read_action_next_sync(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave->master->debug_level)
|
if (slave->master->debug_level)
|
||||||
EC_DBG("Reading of Pdo configuration finished.\n");
|
EC_DBG("Reading of PDO configuration finished.\n");
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_state_end;
|
fsm->state = ec_fsm_pdo_state_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Count assigned Pdos.
|
/** Count assigned PDOs.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_state_pdo_count(
|
void ec_fsm_pdo_read_state_pdo_count(
|
||||||
ec_fsm_pdo_t *fsm /**< finite state machine */
|
ec_fsm_pdo_t *fsm /**< finite state machine */
|
||||||
|
|
@ -225,14 +225,14 @@ void ec_fsm_pdo_read_state_pdo_count(
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_ERR("Failed to read number of assigned Pdos for SM%u.\n",
|
EC_ERR("Failed to read number of assigned PDOs for SM%u.\n",
|
||||||
fsm->sync_index);
|
fsm->sync_index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->request.data_size != sizeof(uint8_t)) {
|
if (fsm->request.data_size != sizeof(uint8_t)) {
|
||||||
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
|
EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
|
||||||
"from slave %u.\n", fsm->request.data_size,
|
"from slave %u.\n", fsm->request.data_size,
|
||||||
fsm->request.index, fsm->request.subindex,
|
fsm->request.index, fsm->request.subindex,
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
|
|
@ -242,16 +242,16 @@ void ec_fsm_pdo_read_state_pdo_count(
|
||||||
fsm->pdo_count = EC_READ_U8(fsm->request.data);
|
fsm->pdo_count = EC_READ_U8(fsm->request.data);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("%u Pdos assigned.\n", fsm->pdo_count);
|
EC_DBG("%u PDOs assigned.\n", fsm->pdo_count);
|
||||||
|
|
||||||
// read first Pdo
|
// read first PDO
|
||||||
fsm->pdo_pos = 1;
|
fsm->pdo_pos = 1;
|
||||||
ec_fsm_pdo_read_action_next_pdo(fsm);
|
ec_fsm_pdo_read_action_next_pdo(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Read next Pdo.
|
/** Read next PDO.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_action_next_pdo(
|
void ec_fsm_pdo_read_action_next_pdo(
|
||||||
ec_fsm_pdo_t *fsm /**< finite state machine */
|
ec_fsm_pdo_t *fsm /**< finite state machine */
|
||||||
|
|
@ -267,7 +267,7 @@ void ec_fsm_pdo_read_action_next_pdo(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// finished reading Pdo configuration
|
// finished reading PDO configuration
|
||||||
|
|
||||||
if (ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos)) {
|
if (ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos)) {
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
|
|
@ -282,7 +282,7 @@ void ec_fsm_pdo_read_action_next_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Fetch Pdo information.
|
/** Fetch PDO information.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_state_pdo(
|
void ec_fsm_pdo_read_state_pdo(
|
||||||
ec_fsm_pdo_t *fsm /**< finite state machine */
|
ec_fsm_pdo_t *fsm /**< finite state machine */
|
||||||
|
|
@ -291,14 +291,14 @@ void ec_fsm_pdo_read_state_pdo(
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_ERR("Failed to read index of assigned Pdo %u from SM%u.\n",
|
EC_ERR("Failed to read index of assigned PDO %u from SM%u.\n",
|
||||||
fsm->pdo_pos, fsm->sync_index);
|
fsm->pdo_pos, fsm->sync_index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->request.data_size != sizeof(uint16_t)) {
|
if (fsm->request.data_size != sizeof(uint16_t)) {
|
||||||
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
|
EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
|
||||||
"from slave %u.\n", fsm->request.data_size,
|
"from slave %u.\n", fsm->request.data_size,
|
||||||
fsm->request.index, fsm->request.subindex,
|
fsm->request.index, fsm->request.subindex,
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
|
|
@ -308,7 +308,7 @@ void ec_fsm_pdo_read_state_pdo(
|
||||||
|
|
||||||
if (!(fsm->pdo = (ec_pdo_t *)
|
if (!(fsm->pdo = (ec_pdo_t *)
|
||||||
kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo.\n");
|
EC_ERR("Failed to allocate PDO.\n");
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ void ec_fsm_pdo_read_state_pdo(
|
||||||
fsm->pdo->sync_index = fsm->sync_index;
|
fsm->pdo->sync_index = fsm->sync_index;
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Pdo 0x%04X.\n", fsm->pdo->index);
|
EC_DBG("PDO 0x%04X.\n", fsm->pdo->index);
|
||||||
|
|
||||||
list_add_tail(&fsm->pdo->list, &fsm->pdos.list);
|
list_add_tail(&fsm->pdo->list, &fsm->pdos.list);
|
||||||
|
|
||||||
|
|
@ -329,7 +329,7 @@ void ec_fsm_pdo_read_state_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Fetch Pdo information.
|
/** Fetch PDO information.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_read_state_pdo_entries(
|
void ec_fsm_pdo_read_state_pdo_entries(
|
||||||
ec_fsm_pdo_t *fsm /**< finite state machine */
|
ec_fsm_pdo_t *fsm /**< finite state machine */
|
||||||
|
|
@ -339,13 +339,13 @@ void ec_fsm_pdo_read_state_pdo_entries(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry)) {
|
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry)) {
|
||||||
EC_ERR("Failed to read mapped Pdo entries for Pdo 0x%04X.\n",
|
EC_ERR("Failed to read mapped PDO entries for PDO 0x%04X.\n",
|
||||||
fsm->pdo->index);
|
fsm->pdo->index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// next Pdo
|
// next PDO
|
||||||
fsm->pdo_pos++;
|
fsm->pdo_pos++;
|
||||||
ec_fsm_pdo_read_action_next_pdo(fsm);
|
ec_fsm_pdo_read_action_next_pdo(fsm);
|
||||||
}
|
}
|
||||||
|
|
@ -354,10 +354,10 @@ void ec_fsm_pdo_read_state_pdo_entries(
|
||||||
* Writing state functions.
|
* Writing state functions.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** Start Pdo configuration.
|
/** Start PDO configuration.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_start(
|
void ec_fsm_pdo_conf_state_start(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!fsm->slave->config) {
|
if (!fsm->slave->config) {
|
||||||
|
|
@ -371,16 +371,16 @@ void ec_fsm_pdo_conf_state_start(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Assign next Pdo.
|
/** Assign next PDO.
|
||||||
*/
|
*/
|
||||||
ec_pdo_t *ec_fsm_pdo_conf_action_next_pdo(
|
ec_pdo_t *ec_fsm_pdo_conf_action_next_pdo(
|
||||||
const ec_fsm_pdo_t *fsm, /**< Pdo configuration state machine. */
|
const ec_fsm_pdo_t *fsm, /**< PDO configuration state machine. */
|
||||||
const struct list_head *list /**< current Pdo list item */
|
const struct list_head *list /**< current PDO list item */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
list = list->next;
|
list = list->next;
|
||||||
if (list == &fsm->pdos.list)
|
if (list == &fsm->pdos.list)
|
||||||
return NULL; // no next Pdo
|
return NULL; // no next PDO
|
||||||
return list_entry(list, ec_pdo_t, list);
|
return list_entry(list, ec_pdo_t, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,7 +389,7 @@ ec_pdo_t *ec_fsm_pdo_conf_action_next_pdo(
|
||||||
/** Get the next sync manager for a pdo configuration.
|
/** Get the next sync manager for a pdo configuration.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_next_sync(
|
void ec_fsm_pdo_conf_action_next_sync(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->sync_index++;
|
fsm->sync_index++;
|
||||||
|
|
@ -408,13 +408,13 @@ void ec_fsm_pdo_conf_action_next_sync(
|
||||||
|
|
||||||
if (!(fsm->sync = ec_slave_get_sync(fsm->slave, fsm->sync_index))) {
|
if (!(fsm->sync = ec_slave_get_sync(fsm->slave, fsm->sync_index))) {
|
||||||
if (!list_empty(&fsm->pdos.list))
|
if (!list_empty(&fsm->pdos.list))
|
||||||
EC_WARN("Pdos configured for SM%u, but slave %u does not "
|
EC_WARN("PDOs configured for SM%u, but slave %u does not "
|
||||||
"provide the sync manager information!\n",
|
"provide the sync manager information!\n",
|
||||||
fsm->sync_index, fsm->slave->ring_position);
|
fsm->sync_index, fsm->slave->ring_position);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get first configured Pdo
|
// get first configured PDO
|
||||||
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdos.list))) {
|
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdos.list))) {
|
||||||
// no pdos configured
|
// no pdos configured
|
||||||
ec_fsm_pdo_conf_action_check_assignment(fsm);
|
ec_fsm_pdo_conf_action_check_assignment(fsm);
|
||||||
|
|
@ -433,7 +433,7 @@ void ec_fsm_pdo_conf_action_next_sync(
|
||||||
/** Check if the mapping has to be read, otherwise start to configure it.
|
/** Check if the mapping has to be read, otherwise start to configure it.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_pdo_mapping(
|
void ec_fsm_pdo_conf_action_pdo_mapping(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_pdo_t *assigned_pdo;
|
const ec_pdo_t *assigned_pdo;
|
||||||
|
|
@ -442,14 +442,14 @@ void ec_fsm_pdo_conf_action_pdo_mapping(
|
||||||
|
|
||||||
if ((assigned_pdo = ec_slave_find_pdo(fsm->slave, fsm->pdo->index))) {
|
if ((assigned_pdo = ec_slave_find_pdo(fsm->slave, fsm->pdo->index))) {
|
||||||
ec_pdo_copy_entries(&fsm->slave_pdo, assigned_pdo);
|
ec_pdo_copy_entries(&fsm->slave_pdo, assigned_pdo);
|
||||||
} else { // configured Pdo is not assigned and thus unknown
|
} else { // configured PDO is not assigned and thus unknown
|
||||||
ec_pdo_clear_entries(&fsm->slave_pdo);
|
ec_pdo_clear_entries(&fsm->slave_pdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_empty(&fsm->slave_pdo.entries)) {
|
if (list_empty(&fsm->slave_pdo.entries)) {
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Reading mapping of Pdo 0x%04X.\n",
|
EC_DBG("Reading mapping of PDO 0x%04X.\n",
|
||||||
fsm->pdo->index);
|
fsm->pdo->index);
|
||||||
|
|
||||||
// pdo mapping is unknown; start loading it
|
// pdo mapping is unknown; start loading it
|
||||||
|
|
@ -466,17 +466,17 @@ void ec_fsm_pdo_conf_action_pdo_mapping(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Execute the Pdo entry state machine to read the current Pdo's mapping.
|
/** Execute the PDO entry state machine to read the current PDO's mapping.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_read_mapping(
|
void ec_fsm_pdo_conf_state_read_mapping(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_pdo_entry_exec(&fsm->fsm_pdo_entry))
|
if (ec_fsm_pdo_entry_exec(&fsm->fsm_pdo_entry))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry))
|
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry))
|
||||||
EC_WARN("Failed to read mapped Pdo entries for Pdo 0x%04X.\n",
|
EC_WARN("Failed to read mapped PDO entries for PDO 0x%04X.\n",
|
||||||
fsm->pdo->index);
|
fsm->pdo->index);
|
||||||
|
|
||||||
// check if the mapping must be re-configured
|
// check if the mapping must be re-configured
|
||||||
|
|
@ -490,12 +490,12 @@ void ec_fsm_pdo_conf_state_read_mapping(
|
||||||
* \todo Display mapping differences.
|
* \todo Display mapping differences.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_check_mapping(
|
void ec_fsm_pdo_conf_action_check_mapping(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_pdo_equal_entries(fsm->pdo, &fsm->slave_pdo)) {
|
if (ec_pdo_equal_entries(fsm->pdo, &fsm->slave_pdo)) {
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Mapping of Pdo 0x%04X is already configured correctly.\n",
|
EC_DBG("Mapping of PDO 0x%04X is already configured correctly.\n",
|
||||||
fsm->pdo->index);
|
fsm->pdo->index);
|
||||||
ec_fsm_pdo_conf_action_next_pdo_mapping(fsm);
|
ec_fsm_pdo_conf_action_next_pdo_mapping(fsm);
|
||||||
return;
|
return;
|
||||||
|
|
@ -503,7 +503,7 @@ void ec_fsm_pdo_conf_action_check_mapping(
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
// TODO display diff
|
// TODO display diff
|
||||||
EC_DBG("Changing mapping of Pdo 0x%04X.\n", fsm->pdo->index);
|
EC_DBG("Changing mapping of PDO 0x%04X.\n", fsm->pdo->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ec_fsm_pdo_entry_start_configuration(&fsm->fsm_pdo_entry, fsm->slave,
|
ec_fsm_pdo_entry_start_configuration(&fsm->fsm_pdo_entry, fsm->slave,
|
||||||
|
|
@ -514,17 +514,17 @@ void ec_fsm_pdo_conf_action_check_mapping(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Let the Pdo entry state machine configure the current Pdo's mapping.
|
/** Let the PDO entry state machine configure the current PDO's mapping.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_mapping(
|
void ec_fsm_pdo_conf_state_mapping(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_pdo_entry_exec(&fsm->fsm_pdo_entry))
|
if (ec_fsm_pdo_entry_exec(&fsm->fsm_pdo_entry))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry))
|
if (!ec_fsm_pdo_entry_success(&fsm->fsm_pdo_entry))
|
||||||
EC_WARN("Failed to configure mapping of Pdo 0x%04X.\n",
|
EC_WARN("Failed to configure mapping of PDO 0x%04X.\n",
|
||||||
fsm->pdo->index);
|
fsm->pdo->index);
|
||||||
|
|
||||||
ec_fsm_pdo_conf_action_next_pdo_mapping(fsm);
|
ec_fsm_pdo_conf_action_next_pdo_mapping(fsm);
|
||||||
|
|
@ -532,13 +532,13 @@ void ec_fsm_pdo_conf_state_mapping(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Check mapping of next Pdo, otherwise configure assignment.
|
/** Check mapping of next PDO, otherwise configure assignment.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_next_pdo_mapping(
|
void ec_fsm_pdo_conf_action_next_pdo_mapping(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// get next configured Pdo
|
// get next configured PDO
|
||||||
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdo->list))) {
|
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdo->list))) {
|
||||||
// no more configured pdos
|
// no more configured pdos
|
||||||
ec_fsm_pdo_conf_action_check_assignment(fsm);
|
ec_fsm_pdo_conf_action_check_assignment(fsm);
|
||||||
|
|
@ -550,17 +550,17 @@ void ec_fsm_pdo_conf_action_next_pdo_mapping(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Check if the Pdo assignment of the current SM has to be re-configured.
|
/** Check if the PDO assignment of the current SM has to be re-configured.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_check_assignment(
|
void ec_fsm_pdo_conf_action_check_assignment(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// check if assignment has to be re-configured
|
// check if assignment has to be re-configured
|
||||||
if (ec_pdo_list_equal(&fsm->sync->pdos, &fsm->pdos)) {
|
if (ec_pdo_list_equal(&fsm->sync->pdos, &fsm->pdos)) {
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Pdo assignment for SM%u is already configured "
|
EC_DBG("PDO assignment for SM%u is already configured "
|
||||||
"correctly.\n", fsm->sync_index);
|
"correctly.\n", fsm->sync_index);
|
||||||
|
|
||||||
ec_fsm_pdo_conf_action_next_sync(fsm);
|
ec_fsm_pdo_conf_action_next_sync(fsm);
|
||||||
|
|
@ -568,20 +568,20 @@ void ec_fsm_pdo_conf_action_check_assignment(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Pdo assignment of SM%u differs:\n", fsm->sync_index);
|
EC_DBG("PDO assignment of SM%u differs:\n", fsm->sync_index);
|
||||||
EC_DBG("Currently assigned Pdos: ");
|
EC_DBG("Currently assigned PDOs: ");
|
||||||
ec_pdo_list_print(&fsm->sync->pdos);
|
ec_pdo_list_print(&fsm->sync->pdos);
|
||||||
printk("\n");
|
printk("\n");
|
||||||
EC_DBG("Pdos to assign: ");
|
EC_DBG("PDOs to assign: ");
|
||||||
ec_pdo_list_print(&fsm->pdos);
|
ec_pdo_list_print(&fsm->pdos);
|
||||||
printk("\n");
|
printk("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pdo assignment has to be changed. Does the slave support this?
|
// PDO assignment has to be changed. Does the slave support this?
|
||||||
if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
|
if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
|
||||||
|| (fsm->slave->sii.has_general
|
|| (fsm->slave->sii.has_general
|
||||||
&& !fsm->slave->sii.coe_details.enable_pdo_assign)) {
|
&& !fsm->slave->sii.coe_details.enable_pdo_assign)) {
|
||||||
EC_WARN("Slave %u does not support assigning Pdos!\n",
|
EC_WARN("Slave %u does not support assigning PDOs!\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
ec_fsm_pdo_conf_action_next_sync(fsm);
|
ec_fsm_pdo_conf_action_next_sync(fsm);
|
||||||
return;
|
return;
|
||||||
|
|
@ -592,14 +592,14 @@ void ec_fsm_pdo_conf_action_check_assignment(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set mapped Pdo count to zero
|
// set mapped PDO count to zero
|
||||||
EC_WRITE_U8(fsm->request.data, 0); // zero Pdos mapped
|
EC_WRITE_U8(fsm->request.data, 0); // zero PDOs mapped
|
||||||
fsm->request.data_size = 1;
|
fsm->request.data_size = 1;
|
||||||
ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
|
ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
|
||||||
ecrt_sdo_request_write(&fsm->request);
|
ecrt_sdo_request_write(&fsm->request);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Setting number of assigned Pdos to zero.\n");
|
EC_DBG("Setting number of assigned PDOs to zero.\n");
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_conf_state_zero_pdo_count;
|
fsm->state = ec_fsm_pdo_conf_state_zero_pdo_count;
|
||||||
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
||||||
|
|
@ -608,48 +608,48 @@ void ec_fsm_pdo_conf_action_check_assignment(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Set the number of assigned Pdos to zero.
|
/** Set the number of assigned PDOs to zero.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_zero_pdo_count(
|
void ec_fsm_pdo_conf_state_zero_pdo_count(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe))
|
if (ec_fsm_coe_exec(fsm->fsm_coe))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_WARN("Failed to clear Pdo assignment of SM%u.\n", fsm->sync_index);
|
EC_WARN("Failed to clear PDO assignment of SM%u.\n", fsm->sync_index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the sync manager's assigned Pdos have been cleared
|
// the sync manager's assigned PDOs have been cleared
|
||||||
ec_pdo_list_clear_pdos(&fsm->sync->pdos);
|
ec_pdo_list_clear_pdos(&fsm->sync->pdos);
|
||||||
|
|
||||||
// assign all Pdos belonging to the current sync manager
|
// assign all PDOs belonging to the current sync manager
|
||||||
|
|
||||||
// find first Pdo
|
// find first PDO
|
||||||
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdos.list))) {
|
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdos.list))) {
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("No Pdos to assign.\n");
|
EC_DBG("No PDOs to assign.\n");
|
||||||
|
|
||||||
// check for mapping to be altered
|
// check for mapping to be altered
|
||||||
ec_fsm_pdo_conf_action_next_sync(fsm);
|
ec_fsm_pdo_conf_action_next_sync(fsm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign first Pdo
|
// assign first PDO
|
||||||
fsm->pdo_pos = 1;
|
fsm->pdo_pos = 1;
|
||||||
ec_fsm_pdo_conf_action_assign_pdo(fsm);
|
ec_fsm_pdo_conf_action_assign_pdo(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Assign a Pdo.
|
/** Assign a PDO.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_action_assign_pdo(
|
void ec_fsm_pdo_conf_action_assign_pdo(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EC_WRITE_U16(fsm->request.data, fsm->pdo->index);
|
EC_WRITE_U16(fsm->request.data, fsm->pdo->index);
|
||||||
|
|
@ -659,7 +659,7 @@ void ec_fsm_pdo_conf_action_assign_pdo(
|
||||||
ecrt_sdo_request_write(&fsm->request);
|
ecrt_sdo_request_write(&fsm->request);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Assigning Pdo 0x%04X at position %u.\n",
|
EC_DBG("Assigning PDO 0x%04X at position %u.\n",
|
||||||
fsm->pdo->index, fsm->pdo_pos);
|
fsm->pdo->index, fsm->pdo_pos);
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_conf_state_assign_pdo;
|
fsm->state = ec_fsm_pdo_conf_state_assign_pdo;
|
||||||
|
|
@ -669,32 +669,32 @@ void ec_fsm_pdo_conf_action_assign_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add a Pdo to the sync managers Pdo assignment.
|
/** Add a PDO to the sync managers PDO assignment.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_assign_pdo(
|
void ec_fsm_pdo_conf_state_assign_pdo(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_WARN("Failed to assign Pdo 0x%04X at position %u of SM%u.\n",
|
EC_WARN("Failed to assign PDO 0x%04X at position %u of SM%u.\n",
|
||||||
fsm->pdo->index, fsm->pdo_pos, fsm->sync_index);
|
fsm->pdo->index, fsm->pdo_pos, fsm->sync_index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find next Pdo
|
// find next PDO
|
||||||
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdo->list))) {
|
if (!(fsm->pdo = ec_fsm_pdo_conf_action_next_pdo(fsm, &fsm->pdo->list))) {
|
||||||
|
|
||||||
// no more Pdos to assign, set Pdo count
|
// no more PDOs to assign, set PDO count
|
||||||
EC_WRITE_U8(fsm->request.data, fsm->pdo_pos);
|
EC_WRITE_U8(fsm->request.data, fsm->pdo_pos);
|
||||||
fsm->request.data_size = 1;
|
fsm->request.data_size = 1;
|
||||||
ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
|
ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
|
||||||
ecrt_sdo_request_write(&fsm->request);
|
ecrt_sdo_request_write(&fsm->request);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Setting number of assigned Pdos to %u.\n", fsm->pdo_pos);
|
EC_DBG("Setting number of assigned PDOs to %u.\n", fsm->pdo_pos);
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_conf_state_set_pdo_count;
|
fsm->state = ec_fsm_pdo_conf_state_set_pdo_count;
|
||||||
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
||||||
|
|
@ -702,36 +702,36 @@ void ec_fsm_pdo_conf_state_assign_pdo(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add next Pdo to assignment
|
// add next PDO to assignment
|
||||||
fsm->pdo_pos++;
|
fsm->pdo_pos++;
|
||||||
ec_fsm_pdo_conf_action_assign_pdo(fsm);
|
ec_fsm_pdo_conf_action_assign_pdo(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Set the number of assigned Pdos.
|
/** Set the number of assigned PDOs.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_conf_state_set_pdo_count(
|
void ec_fsm_pdo_conf_state_set_pdo_count(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_WARN("Failed to set number of assigned Pdos of SM%u.\n",
|
EC_WARN("Failed to set number of assigned PDOs of SM%u.\n",
|
||||||
fsm->sync_index);
|
fsm->sync_index);
|
||||||
fsm->state = ec_fsm_pdo_state_error;
|
fsm->state = ec_fsm_pdo_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pdos have been configured
|
// PDOs have been configured
|
||||||
ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos);
|
ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Successfully configured Pdo assignment of SM%u.\n",
|
EC_DBG("Successfully configured PDO assignment of SM%u.\n",
|
||||||
fsm->sync_index);
|
fsm->sync_index);
|
||||||
|
|
||||||
// check if Pdo mapping has to be altered
|
// check if PDO mapping has to be altered
|
||||||
ec_fsm_pdo_conf_action_next_sync(fsm);
|
ec_fsm_pdo_conf_action_next_sync(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -742,7 +742,7 @@ void ec_fsm_pdo_conf_state_set_pdo_count(
|
||||||
/** State: ERROR.
|
/** State: ERROR.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_state_error(
|
void ec_fsm_pdo_state_error(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -752,7 +752,7 @@ void ec_fsm_pdo_state_error(
|
||||||
/** State: END.
|
/** State: END.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_state_end(
|
void ec_fsm_pdo_state_end(
|
||||||
ec_fsm_pdo_t *fsm /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT Pdo configuration state machine structures.
|
EtherCAT PDO configuration state machine structures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -46,23 +46,23 @@
|
||||||
*/
|
*/
|
||||||
typedef struct ec_fsm_pdo ec_fsm_pdo_t;
|
typedef struct ec_fsm_pdo ec_fsm_pdo_t;
|
||||||
|
|
||||||
/** Pdo configuration state machine.
|
/** PDO configuration state machine.
|
||||||
*/
|
*/
|
||||||
struct ec_fsm_pdo
|
struct ec_fsm_pdo
|
||||||
{
|
{
|
||||||
void (*state)(ec_fsm_pdo_t *); /**< State function. */
|
void (*state)(ec_fsm_pdo_t *); /**< State function. */
|
||||||
ec_fsm_coe_t *fsm_coe; /**< CoE state machine to use. */
|
ec_fsm_coe_t *fsm_coe; /**< CoE state machine to use. */
|
||||||
ec_fsm_pdo_entry_t fsm_pdo_entry; /**< Pdo entry state machine. */
|
ec_fsm_pdo_entry_t fsm_pdo_entry; /**< PDO entry state machine. */
|
||||||
ec_pdo_list_t pdos; /**< Pdo configuration. */
|
ec_pdo_list_t pdos; /**< PDO configuration. */
|
||||||
ec_sdo_request_t request; /**< Sdo request. */
|
ec_sdo_request_t request; /**< SDO request. */
|
||||||
ec_pdo_t slave_pdo; /**< Pdo actually appearing in a slave. */
|
ec_pdo_t slave_pdo; /**< PDO actually appearing in a slave. */
|
||||||
|
|
||||||
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
||||||
uint8_t sync_index; /**< Current sync manager index. */
|
uint8_t sync_index; /**< Current sync manager index. */
|
||||||
ec_sync_t *sync; /**< Current sync manager. */
|
ec_sync_t *sync; /**< Current sync manager. */
|
||||||
ec_pdo_t *pdo; /**< Current Pdo. */
|
ec_pdo_t *pdo; /**< Current PDO. */
|
||||||
unsigned int pdo_pos; /**< Assignment position of current Pdos. */
|
unsigned int pdo_pos; /**< Assignment position of current PDOs. */
|
||||||
unsigned int pdo_count; /**< Number of assigned Pdos. */
|
unsigned int pdo_count; /**< Number of assigned PDOs. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* EtherCAT Pdo mapping state machine.
|
* EtherCAT PDO mapping state machine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -60,7 +60,7 @@ void ec_fsm_pdo_entry_state_error(ec_fsm_pdo_entry_t *);
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_init(
|
void ec_fsm_pdo_entry_init(
|
||||||
ec_fsm_pdo_entry_t *fsm, /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm, /**< PDO mapping state machine. */
|
||||||
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use. */
|
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ void ec_fsm_pdo_entry_init(
|
||||||
/** Destructor.
|
/** Destructor.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_clear(
|
void ec_fsm_pdo_entry_clear(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_request_clear(&fsm->request);
|
ec_sdo_request_clear(&fsm->request);
|
||||||
|
|
@ -81,12 +81,12 @@ void ec_fsm_pdo_entry_clear(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Start reading a Pdo's entries.
|
/** Start reading a PDO's entries.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_start_reading(
|
void ec_fsm_pdo_entry_start_reading(
|
||||||
ec_fsm_pdo_entry_t *fsm, /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm, /**< PDO mapping state machine. */
|
||||||
ec_slave_t *slave, /**< slave to configure */
|
ec_slave_t *slave, /**< slave to configure */
|
||||||
ec_pdo_t *pdo /**< Pdo to read entries for. */
|
ec_pdo_t *pdo /**< PDO to read entries for. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->slave = slave;
|
fsm->slave = slave;
|
||||||
|
|
@ -99,12 +99,12 @@ void ec_fsm_pdo_entry_start_reading(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Start Pdo mapping state machine.
|
/** Start PDO mapping state machine.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_start_configuration(
|
void ec_fsm_pdo_entry_start_configuration(
|
||||||
ec_fsm_pdo_entry_t *fsm, /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm, /**< PDO mapping state machine. */
|
||||||
ec_slave_t *slave, /**< slave to configure */
|
ec_slave_t *slave, /**< slave to configure */
|
||||||
const ec_pdo_t *pdo /**< Pdo with the desired entries. */
|
const ec_pdo_t *pdo /**< PDO with the desired entries. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->slave = slave;
|
fsm->slave = slave;
|
||||||
|
|
@ -120,7 +120,7 @@ void ec_fsm_pdo_entry_start_configuration(
|
||||||
* \return false, if state machine has terminated
|
* \return false, if state machine has terminated
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_entry_running(
|
int ec_fsm_pdo_entry_running(
|
||||||
const ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
const ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return fsm->state != ec_fsm_pdo_entry_state_end
|
return fsm->state != ec_fsm_pdo_entry_state_end
|
||||||
|
|
@ -134,7 +134,7 @@ int ec_fsm_pdo_entry_running(
|
||||||
* \return false, if state machine has terminated
|
* \return false, if state machine has terminated
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_entry_exec(
|
int ec_fsm_pdo_entry_exec(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->state(fsm);
|
fsm->state(fsm);
|
||||||
|
|
@ -148,7 +148,7 @@ int ec_fsm_pdo_entry_exec(
|
||||||
* \return true, if the state machine terminated gracefully
|
* \return true, if the state machine terminated gracefully
|
||||||
*/
|
*/
|
||||||
int ec_fsm_pdo_entry_success(
|
int ec_fsm_pdo_entry_success(
|
||||||
const ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
const ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return fsm->state == ec_fsm_pdo_entry_state_end;
|
return fsm->state == ec_fsm_pdo_entry_state_end;
|
||||||
|
|
@ -158,10 +158,10 @@ int ec_fsm_pdo_entry_success(
|
||||||
* Reading state functions.
|
* Reading state functions.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** Request reading the number of mapped Pdo entries.
|
/** Request reading the number of mapped PDO entries.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_read_state_start(
|
void ec_fsm_pdo_entry_read_state_start(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_request_address(&fsm->request, fsm->target_pdo->index, 0);
|
ec_sdo_request_address(&fsm->request, fsm->target_pdo->index, 0);
|
||||||
|
|
@ -174,7 +174,7 @@ void ec_fsm_pdo_entry_read_state_start(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Read number of mapped Pdo entries.
|
/** Read number of mapped PDO entries.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_read_state_count(
|
void ec_fsm_pdo_entry_read_state_count(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
||||||
|
|
@ -184,13 +184,13 @@ void ec_fsm_pdo_entry_read_state_count(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_ERR("Failed to read number of mapped Pdo entries.\n");
|
EC_ERR("Failed to read number of mapped PDO entries.\n");
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->request.data_size != sizeof(uint8_t)) {
|
if (fsm->request.data_size != sizeof(uint8_t)) {
|
||||||
EC_ERR("Invalid data size %u at uploading Sdo 0x%04X:%02X.\n",
|
EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
|
||||||
fsm->request.data_size, fsm->request.index,
|
fsm->request.data_size, fsm->request.index,
|
||||||
fsm->request.subindex);
|
fsm->request.subindex);
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
|
|
@ -200,16 +200,16 @@ void ec_fsm_pdo_entry_read_state_count(
|
||||||
fsm->entry_count = EC_READ_U8(fsm->request.data);
|
fsm->entry_count = EC_READ_U8(fsm->request.data);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("%u Pdo entries mapped.\n", fsm->entry_count);
|
EC_DBG("%u PDO entries mapped.\n", fsm->entry_count);
|
||||||
|
|
||||||
// read first Pdo entry
|
// read first PDO entry
|
||||||
fsm->entry_pos = 1;
|
fsm->entry_pos = 1;
|
||||||
ec_fsm_pdo_entry_read_action_next(fsm);
|
ec_fsm_pdo_entry_read_action_next(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Read next Pdo entry.
|
/** Read next PDO entry.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_read_action_next(
|
void ec_fsm_pdo_entry_read_action_next(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
||||||
|
|
@ -230,7 +230,7 @@ void ec_fsm_pdo_entry_read_action_next(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Read Pdo entry information.
|
/** Read PDO entry information.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_read_state_entry(
|
void ec_fsm_pdo_entry_read_state_entry(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
ec_fsm_pdo_entry_t *fsm /**< finite state machine */
|
||||||
|
|
@ -239,13 +239,13 @@ void ec_fsm_pdo_entry_read_state_entry(
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_ERR("Failed to read mapped Pdo entry.\n");
|
EC_ERR("Failed to read mapped PDO entry.\n");
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->request.data_size != sizeof(uint32_t)) {
|
if (fsm->request.data_size != sizeof(uint32_t)) {
|
||||||
EC_ERR("Invalid data size %u at uploading Sdo 0x%04X:%02X.\n",
|
EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
|
||||||
fsm->request.data_size, fsm->request.index,
|
fsm->request.data_size, fsm->request.index,
|
||||||
fsm->request.subindex);
|
fsm->request.subindex);
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
|
|
@ -257,7 +257,7 @@ void ec_fsm_pdo_entry_read_state_entry(
|
||||||
|
|
||||||
if (!(pdo_entry = (ec_pdo_entry_t *)
|
if (!(pdo_entry = (ec_pdo_entry_t *)
|
||||||
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo entry.\n");
|
EC_ERR("Failed to allocate PDO entry.\n");
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +277,7 @@ void ec_fsm_pdo_entry_read_state_entry(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level) {
|
if (fsm->slave->master->debug_level) {
|
||||||
EC_DBG("Pdo entry 0x%04X:%02X, %u bit, \"%s\".\n",
|
EC_DBG("PDO entry 0x%04X:%02X, %u bit, \"%s\".\n",
|
||||||
pdo_entry->index, pdo_entry->subindex,
|
pdo_entry->index, pdo_entry->subindex,
|
||||||
pdo_entry->bit_length,
|
pdo_entry->bit_length,
|
||||||
pdo_entry->name ? pdo_entry->name : "???");
|
pdo_entry->name ? pdo_entry->name : "???");
|
||||||
|
|
@ -285,7 +285,7 @@ void ec_fsm_pdo_entry_read_state_entry(
|
||||||
|
|
||||||
list_add_tail(&pdo_entry->list, &fsm->target_pdo->entries);
|
list_add_tail(&pdo_entry->list, &fsm->target_pdo->entries);
|
||||||
|
|
||||||
// next Pdo entry
|
// next PDO entry
|
||||||
fsm->entry_pos++;
|
fsm->entry_pos++;
|
||||||
ec_fsm_pdo_entry_read_action_next(fsm);
|
ec_fsm_pdo_entry_read_action_next(fsm);
|
||||||
}
|
}
|
||||||
|
|
@ -295,17 +295,17 @@ void ec_fsm_pdo_entry_read_state_entry(
|
||||||
* Configuration state functions.
|
* Configuration state functions.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** Start Pdo mapping.
|
/** Start PDO mapping.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_conf_state_start(
|
void ec_fsm_pdo_entry_conf_state_start(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Pdo mapping has to be changed. Does the slave support this?
|
// PDO mapping has to be changed. Does the slave support this?
|
||||||
if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
|
if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
|
||||||
|| (fsm->slave->sii.has_general
|
|| (fsm->slave->sii.has_general
|
||||||
&& !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
|
&& !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
|
||||||
EC_WARN("Slave %u does not support changing the Pdo mapping!\n",
|
EC_WARN("Slave %u does not support changing the PDO mapping!\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
return;
|
return;
|
||||||
|
|
@ -316,7 +316,7 @@ void ec_fsm_pdo_entry_conf_state_start(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set mapped Pdo entry count to zero
|
// set mapped PDO entry count to zero
|
||||||
EC_WRITE_U8(fsm->request.data, 0);
|
EC_WRITE_U8(fsm->request.data, 0);
|
||||||
fsm->request.data_size = 1;
|
fsm->request.data_size = 1;
|
||||||
ec_sdo_request_address(&fsm->request, fsm->source_pdo->index, 0);
|
ec_sdo_request_address(&fsm->request, fsm->source_pdo->index, 0);
|
||||||
|
|
@ -332,10 +332,10 @@ void ec_fsm_pdo_entry_conf_state_start(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Process next Pdo entry.
|
/** Process next PDO entry.
|
||||||
*/
|
*/
|
||||||
ec_pdo_entry_t *ec_fsm_pdo_entry_conf_next_entry(
|
ec_pdo_entry_t *ec_fsm_pdo_entry_conf_next_entry(
|
||||||
const ec_fsm_pdo_entry_t *fsm, /**< Pdo mapping state machine. */
|
const ec_fsm_pdo_entry_t *fsm, /**< PDO mapping state machine. */
|
||||||
const struct list_head *list /**< current entry list item */
|
const struct list_head *list /**< current entry list item */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -350,14 +350,14 @@ ec_pdo_entry_t *ec_fsm_pdo_entry_conf_next_entry(
|
||||||
/** Set the number of mapped entries to zero.
|
/** Set the number of mapped entries to zero.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_conf_state_zero_entry_count(
|
void ec_fsm_pdo_entry_conf_state_zero_entry_count(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe))
|
if (ec_fsm_coe_exec(fsm->fsm_coe))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_WARN("Failed to clear Pdo mapping.\n");
|
EC_WARN("Failed to clear PDO mapping.\n");
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -380,16 +380,16 @@ void ec_fsm_pdo_entry_conf_state_zero_entry_count(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Starts to add a Pdo entry.
|
/** Starts to add a PDO entry.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_conf_action_map(
|
void ec_fsm_pdo_entry_conf_action_map(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Mapping Pdo entry 0x%04X:%02X (%u bit) at position %u.\n",
|
EC_DBG("Mapping PDO entry 0x%04X:%02X (%u bit) at position %u.\n",
|
||||||
fsm->entry->index, fsm->entry->subindex,
|
fsm->entry->index, fsm->entry->subindex,
|
||||||
fsm->entry->bit_length, fsm->entry_pos);
|
fsm->entry->bit_length, fsm->entry_pos);
|
||||||
|
|
||||||
|
|
@ -407,16 +407,16 @@ void ec_fsm_pdo_entry_conf_action_map(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add a Pdo entry.
|
/** Add a PDO entry.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_conf_state_map_entry(
|
void ec_fsm_pdo_entry_conf_state_map_entry(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_WARN("Failed to map Pdo entry 0x%04X:%02X (%u bit) to "
|
EC_WARN("Failed to map PDO entry 0x%04X:%02X (%u bit) to "
|
||||||
"position %u.\n", fsm->entry->index, fsm->entry->subindex,
|
"position %u.\n", fsm->entry->index, fsm->entry->subindex,
|
||||||
fsm->entry->bit_length, fsm->entry_pos);
|
fsm->entry->bit_length, fsm->entry_pos);
|
||||||
fsm->state = ec_fsm_pdo_entry_state_error;
|
fsm->state = ec_fsm_pdo_entry_state_error;
|
||||||
|
|
@ -434,7 +434,7 @@ void ec_fsm_pdo_entry_conf_state_map_entry(
|
||||||
ecrt_sdo_request_write(&fsm->request);
|
ecrt_sdo_request_write(&fsm->request);
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Setting number of Pdo entries to %u.\n", fsm->entry_pos);
|
EC_DBG("Setting number of PDO entries to %u.\n", fsm->entry_pos);
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_entry_conf_state_set_entry_count;
|
fsm->state = ec_fsm_pdo_entry_conf_state_set_entry_count;
|
||||||
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
|
||||||
|
|
@ -452,7 +452,7 @@ void ec_fsm_pdo_entry_conf_state_map_entry(
|
||||||
/** Set the number of entries.
|
/** Set the number of entries.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_conf_state_set_entry_count(
|
void ec_fsm_pdo_entry_conf_state_set_entry_count(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
@ -464,7 +464,7 @@ void ec_fsm_pdo_entry_conf_state_set_entry_count(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm->slave->master->debug_level)
|
if (fsm->slave->master->debug_level)
|
||||||
EC_DBG("Successfully configured mapping for Pdo 0x%04X.\n",
|
EC_DBG("Successfully configured mapping for PDO 0x%04X.\n",
|
||||||
fsm->source_pdo->index);
|
fsm->source_pdo->index);
|
||||||
|
|
||||||
fsm->state = ec_fsm_pdo_entry_state_end; // finished
|
fsm->state = ec_fsm_pdo_entry_state_end; // finished
|
||||||
|
|
@ -477,7 +477,7 @@ void ec_fsm_pdo_entry_conf_state_set_entry_count(
|
||||||
/** State: ERROR.
|
/** State: ERROR.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_state_error(
|
void ec_fsm_pdo_entry_state_error(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -487,7 +487,7 @@ void ec_fsm_pdo_entry_state_error(
|
||||||
/** State: END.
|
/** State: END.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_pdo_entry_state_end(
|
void ec_fsm_pdo_entry_state_end(
|
||||||
ec_fsm_pdo_entry_t *fsm /**< Pdo mapping state machine. */
|
ec_fsm_pdo_entry_t *fsm /**< PDO mapping state machine. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* EtherCAT Pdo entry configuration state machine structures.
|
* EtherCAT PDO entry configuration state machine structures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -44,20 +44,20 @@
|
||||||
*/
|
*/
|
||||||
typedef struct ec_fsm_pdo_entry ec_fsm_pdo_entry_t;
|
typedef struct ec_fsm_pdo_entry ec_fsm_pdo_entry_t;
|
||||||
|
|
||||||
/** Pdo configuration state machine.
|
/** PDO configuration state machine.
|
||||||
*/
|
*/
|
||||||
struct ec_fsm_pdo_entry
|
struct ec_fsm_pdo_entry
|
||||||
{
|
{
|
||||||
void (*state)(ec_fsm_pdo_entry_t *); /**< state function */
|
void (*state)(ec_fsm_pdo_entry_t *); /**< state function */
|
||||||
ec_fsm_coe_t *fsm_coe; /**< CoE state machine to use */
|
ec_fsm_coe_t *fsm_coe; /**< CoE state machine to use */
|
||||||
ec_sdo_request_t request; /**< Sdo request. */
|
ec_sdo_request_t request; /**< SDO request. */
|
||||||
|
|
||||||
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
||||||
ec_pdo_t *target_pdo; /**< Pdo to read the mapping for. */
|
ec_pdo_t *target_pdo; /**< PDO to read the mapping for. */
|
||||||
const ec_pdo_t *source_pdo; /**< Pdo with desired mapping. */
|
const ec_pdo_t *source_pdo; /**< PDO with desired mapping. */
|
||||||
const ec_pdo_entry_t *entry; /**< Current entry. */
|
const ec_pdo_entry_t *entry; /**< Current entry. */
|
||||||
unsigned int entry_count; /**< Number of entries. */
|
unsigned int entry_count; /**< Number of entries. */
|
||||||
unsigned int entry_pos; /**< Position in Pdo mapping. */
|
unsigned int entry_pos; /**< Position in PDO mapping. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ void ec_fsm_slave_config_init(
|
||||||
ec_datagram_t *datagram, /**< datagram structure to use */
|
ec_datagram_t *datagram, /**< datagram structure to use */
|
||||||
ec_fsm_change_t *fsm_change, /**< State change state machine to use. */
|
ec_fsm_change_t *fsm_change, /**< State change state machine to use. */
|
||||||
ec_fsm_coe_t *fsm_coe, /**< CoE state machine to use. */
|
ec_fsm_coe_t *fsm_coe, /**< CoE state machine to use. */
|
||||||
ec_fsm_pdo_t *fsm_pdo /**< Pdo configuration state machine to use. */
|
ec_fsm_pdo_t *fsm_pdo /**< PDO configuration state machine to use. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_request_init(&fsm->request_copy);
|
ec_sdo_request_init(&fsm->request_copy);
|
||||||
|
|
@ -436,7 +436,7 @@ void ec_fsm_slave_config_state_preop(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Check for Sdo configurations to be applied.
|
/** Check for SDO configurations to be applied.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_slave_config_enter_sdo_conf(
|
void ec_fsm_slave_config_enter_sdo_conf(
|
||||||
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
||||||
|
|
@ -445,12 +445,12 @@ void ec_fsm_slave_config_enter_sdo_conf(
|
||||||
ec_slave_t *slave = fsm->slave;
|
ec_slave_t *slave = fsm->slave;
|
||||||
|
|
||||||
// No CoE configuration to be applied?
|
// No CoE configuration to be applied?
|
||||||
if (list_empty(&slave->config->sdo_configs)) { // skip Sdo configuration
|
if (list_empty(&slave->config->sdo_configs)) { // skip SDO configuration
|
||||||
ec_fsm_slave_config_enter_pdo_conf(fsm);
|
ec_fsm_slave_config_enter_pdo_conf(fsm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start Sdo configuration
|
// start SDO configuration
|
||||||
fsm->state = ec_fsm_slave_config_state_sdo_conf;
|
fsm->state = ec_fsm_slave_config_state_sdo_conf;
|
||||||
fsm->request = list_entry(fsm->slave->config->sdo_configs.next,
|
fsm->request = list_entry(fsm->slave->config->sdo_configs.next,
|
||||||
ec_sdo_request_t, list);
|
ec_sdo_request_t, list);
|
||||||
|
|
@ -471,7 +471,7 @@ void ec_fsm_slave_config_state_sdo_conf(
|
||||||
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
|
||||||
|
|
||||||
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
|
||||||
EC_ERR("Sdo configuration failed for slave %u.\n",
|
EC_ERR("SDO configuration failed for slave %u.\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
fsm->slave->error_flag = 1;
|
fsm->slave->error_flag = 1;
|
||||||
fsm->state = ec_fsm_slave_config_state_error;
|
fsm->state = ec_fsm_slave_config_state_error;
|
||||||
|
|
@ -483,7 +483,7 @@ void ec_fsm_slave_config_state_sdo_conf(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another Sdo to configure?
|
// Another SDO to configure?
|
||||||
if (fsm->request->list.next != &fsm->slave->config->sdo_configs) {
|
if (fsm->request->list.next != &fsm->slave->config->sdo_configs) {
|
||||||
fsm->request = list_entry(fsm->request->list.next,
|
fsm->request = list_entry(fsm->request->list.next,
|
||||||
ec_sdo_request_t, list);
|
ec_sdo_request_t, list);
|
||||||
|
|
@ -494,7 +494,7 @@ void ec_fsm_slave_config_state_sdo_conf(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All Sdos are now configured.
|
// All SDOs are now configured.
|
||||||
ec_fsm_slave_config_enter_pdo_conf(fsm);
|
ec_fsm_slave_config_enter_pdo_conf(fsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -506,7 +506,7 @@ void ec_fsm_slave_config_enter_pdo_conf(
|
||||||
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Start configuring Pdos
|
// Start configuring PDOs
|
||||||
ec_fsm_pdo_start_configuration(fsm->fsm_pdo, fsm->slave);
|
ec_fsm_pdo_start_configuration(fsm->fsm_pdo, fsm->slave);
|
||||||
fsm->state = ec_fsm_slave_config_state_pdo_conf;
|
fsm->state = ec_fsm_slave_config_state_pdo_conf;
|
||||||
fsm->state(fsm); // execute immediately
|
fsm->state(fsm); // execute immediately
|
||||||
|
|
@ -529,7 +529,7 @@ void ec_fsm_slave_config_state_pdo_conf(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) {
|
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) {
|
||||||
EC_WARN("Pdo configuration failed on slave %u.\n",
|
EC_WARN("PDO configuration failed on slave %u.\n",
|
||||||
fsm->slave->ring_position);
|
fsm->slave->ring_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -538,7 +538,7 @@ void ec_fsm_slave_config_state_pdo_conf(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Check for Pdo sync managers to be configured.
|
/** Check for PDO sync managers to be configured.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_slave_config_enter_pdo_sync(
|
void ec_fsm_slave_config_enter_pdo_sync(
|
||||||
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
||||||
|
|
@ -559,7 +559,7 @@ void ec_fsm_slave_config_enter_pdo_sync(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave->sii.sync_count <= offset) {
|
if (slave->sii.sync_count <= offset) {
|
||||||
// no Pdo sync managers to configure
|
// no PDO sync managers to configure
|
||||||
ec_fsm_slave_config_enter_fmmu(fsm);
|
ec_fsm_slave_config_enter_fmmu(fsm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -587,7 +587,7 @@ void ec_fsm_slave_config_enter_pdo_sync(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Configure Pdo sync managers.
|
/** Configure PDO sync managers.
|
||||||
*/
|
*/
|
||||||
void ec_fsm_slave_config_state_pdo_sync(
|
void ec_fsm_slave_config_state_pdo_sync(
|
||||||
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
ec_fsm_slave_config_t *fsm /**< slave state machine */
|
||||||
|
|
@ -661,7 +661,7 @@ void ec_fsm_slave_config_enter_fmmu(
|
||||||
if (!(sync = ec_slave_get_sync(slave, fmmu->sync_index))) {
|
if (!(sync = ec_slave_get_sync(slave, fmmu->sync_index))) {
|
||||||
slave->error_flag = 1;
|
slave->error_flag = 1;
|
||||||
fsm->state = ec_fsm_slave_config_state_error;
|
fsm->state = ec_fsm_slave_config_state_error;
|
||||||
EC_ERR("Failed to determine Pdo sync manager for FMMU on slave"
|
EC_ERR("Failed to determine PDO sync manager for FMMU on slave"
|
||||||
" %u!\n", slave->ring_position);
|
" %u!\n", slave->ring_position);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,13 @@ struct ec_fsm_slave_config
|
||||||
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
||||||
ec_fsm_change_t *fsm_change; /**< State change state machine. */
|
ec_fsm_change_t *fsm_change; /**< State change state machine. */
|
||||||
ec_fsm_coe_t *fsm_coe; /**< CoE state machine. */
|
ec_fsm_coe_t *fsm_coe; /**< CoE state machine. */
|
||||||
ec_fsm_pdo_t *fsm_pdo; /**< Pdo configuration state machine. */
|
ec_fsm_pdo_t *fsm_pdo; /**< PDO configuration state machine. */
|
||||||
|
|
||||||
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
ec_slave_t *slave; /**< Slave the FSM runs on. */
|
||||||
void (*state)(ec_fsm_slave_config_t *); /**< State function. */
|
void (*state)(ec_fsm_slave_config_t *); /**< State function. */
|
||||||
unsigned int retries; /**< Retries on datagram timeout. */
|
unsigned int retries; /**< Retries on datagram timeout. */
|
||||||
ec_sdo_request_t *request; /**< Sdo request for Sdo configuration. */
|
ec_sdo_request_t *request; /**< SDO request for SDO configuration. */
|
||||||
ec_sdo_request_t request_copy; /**< Copied Sdo request. */
|
ec_sdo_request_t request_copy; /**< Copied SDO request. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ void ec_fsm_slave_scan_init(
|
||||||
ec_datagram_t *datagram, /**< Datagram to use. */
|
ec_datagram_t *datagram, /**< Datagram to use. */
|
||||||
ec_fsm_slave_config_t *fsm_slave_config, /**< Slave configuration
|
ec_fsm_slave_config_t *fsm_slave_config, /**< Slave configuration
|
||||||
state machine to use. */
|
state machine to use. */
|
||||||
ec_fsm_pdo_t *fsm_pdo /**< Pdo configuration machine to use. */
|
ec_fsm_pdo_t *fsm_pdo /**< PDO configuration machine to use. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fsm->datagram = datagram;
|
fsm->datagram = datagram;
|
||||||
|
|
@ -536,12 +536,12 @@ void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *fsm /**< slave state
|
||||||
break;
|
break;
|
||||||
case 0x0032:
|
case 0x0032:
|
||||||
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
|
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
|
||||||
cat_size * 2, EC_DIR_INPUT)) // TxPdo
|
cat_size * 2, EC_DIR_INPUT)) // TxPDO
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
case 0x0033:
|
case 0x0033:
|
||||||
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
|
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
|
||||||
cat_size * 2, EC_DIR_OUTPUT)) // RxPdo
|
cat_size * 2, EC_DIR_OUTPUT)) // RxPDO
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -625,7 +625,7 @@ void ec_fsm_slave_scan_enter_pdos(
|
||||||
ec_slave_t *slave = fsm->slave;
|
ec_slave_t *slave = fsm->slave;
|
||||||
|
|
||||||
if (slave->master->debug_level)
|
if (slave->master->debug_level)
|
||||||
EC_DBG("Scanning Pdo assignment and mapping of slave %u.\n",
|
EC_DBG("Scanning PDO assignment and mapping of slave %u.\n",
|
||||||
slave->ring_position);
|
slave->ring_position);
|
||||||
fsm->state = ec_fsm_slave_scan_state_pdos;
|
fsm->state = ec_fsm_slave_scan_state_pdos;
|
||||||
ec_fsm_pdo_start_reading(fsm->fsm_pdo, slave);
|
ec_fsm_pdo_start_reading(fsm->fsm_pdo, slave);
|
||||||
|
|
@ -648,7 +648,7 @@ void ec_fsm_slave_scan_state_pdos(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading Pdo configuration finished
|
// reading PDO configuration finished
|
||||||
fsm->state = ec_fsm_slave_scan_state_end;
|
fsm->state = ec_fsm_slave_scan_state_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ struct ec_fsm_slave_scan
|
||||||
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
ec_datagram_t *datagram; /**< Datagram used in the state machine. */
|
||||||
ec_fsm_slave_config_t *fsm_slave_config; /**< Slave configuration state
|
ec_fsm_slave_config_t *fsm_slave_config; /**< Slave configuration state
|
||||||
machine to use. */
|
machine to use. */
|
||||||
ec_fsm_pdo_t *fsm_pdo; /**< Pdo configuration state machine to use. */
|
ec_fsm_pdo_t *fsm_pdo; /**< PDO configuration state machine to use. */
|
||||||
unsigned int retries; /**< Retries on datagram timeout. */
|
unsigned int retries; /**< Retries on datagram timeout. */
|
||||||
|
|
||||||
void (*state)(ec_fsm_slave_scan_t *); /**< State function. */
|
void (*state)(ec_fsm_slave_scan_t *); /**< State function. */
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
/** Number of state machine retries on datagram timeout. */
|
/** Number of state machine retries on datagram timeout. */
|
||||||
#define EC_FSM_RETRIES 3
|
#define EC_FSM_RETRIES 3
|
||||||
|
|
||||||
/** Seconds to wait before fetching Sdo dictionary
|
/** Seconds to wait before fetching SDO dictionary
|
||||||
after slave entered PREOP state. */
|
after slave entered PREOP state. */
|
||||||
#define EC_WAIT_SDO_DICT 3
|
#define EC_WAIT_SDO_DICT 3
|
||||||
|
|
||||||
|
|
@ -126,21 +126,21 @@ typedef enum {
|
||||||
/** Supported mailbox protocols.
|
/** Supported mailbox protocols.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
EC_MBOX_AOE = 0x01, /**< ADS-over-EtherCAT */
|
EC_MBOX_AOE = 0x01, /**< ADS over EtherCAT */
|
||||||
EC_MBOX_EOE = 0x02, /**< Ethernet-over-EtherCAT */
|
EC_MBOX_EOE = 0x02, /**< Ethernet over EtherCAT */
|
||||||
EC_MBOX_COE = 0x04, /**< CANopen-over-EtherCAT */
|
EC_MBOX_COE = 0x04, /**< CANopen over EtherCAT */
|
||||||
EC_MBOX_FOE = 0x08, /**< File-Access-over-EtherCAT */
|
EC_MBOX_FOE = 0x08, /**< File-Access over EtherCAT */
|
||||||
EC_MBOX_SOE = 0x10, /**< Servo-Profile-over-EtherCAT */
|
EC_MBOX_SOE = 0x10, /**< Servo-Profile over EtherCAT */
|
||||||
EC_MBOX_VOE = 0x20 /**< Vendor specific */
|
EC_MBOX_VOE = 0x20 /**< Vendor specific */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Slave information interface CANopen-over-EtherCAT details flags.
|
/** Slave information interface CANopen over EtherCAT details flags.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t enable_sdo : 1; /**< Enable Sdo access. */
|
uint8_t enable_sdo : 1; /**< Enable SDO access. */
|
||||||
uint8_t enable_sdo_info : 1; /**< SDO information service available. */
|
uint8_t enable_sdo_info : 1; /**< SDO information service available. */
|
||||||
uint8_t enable_pdo_assign : 1; /**< Pdo mapping configurable. */
|
uint8_t enable_pdo_assign : 1; /**< PDO mapping configurable. */
|
||||||
uint8_t enable_pdo_configuration : 1; /**< Pdo configuration possible. */
|
uint8_t enable_pdo_configuration : 1; /**< PDO configuration possible. */
|
||||||
uint8_t enable_upload_at_startup : 1; /**< ?. */
|
uint8_t enable_upload_at_startup : 1; /**< ?. */
|
||||||
uint8_t enable_sdo_complete_access : 1; /**< Complete access possible. */
|
uint8_t enable_sdo_complete_access : 1; /**< Complete access possible. */
|
||||||
} ec_sii_coe_details_t;
|
} ec_sii_coe_details_t;
|
||||||
|
|
|
||||||
|
|
@ -981,7 +981,7 @@ schedule:
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
/** Starts Ethernet-over-EtherCAT processing on demand.
|
/** Starts Ethernet over EtherCAT processing on demand.
|
||||||
*/
|
*/
|
||||||
void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */)
|
void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */)
|
||||||
{
|
{
|
||||||
|
|
@ -1008,7 +1008,7 @@ void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Stops the Ethernet-over-EtherCAT processing.
|
/** Stops the Ethernet over EtherCAT processing.
|
||||||
*/
|
*/
|
||||||
void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */)
|
void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */)
|
||||||
{
|
{
|
||||||
|
|
@ -1022,7 +1022,7 @@ void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Does the Ethernet-over-EtherCAT processing.
|
/** Does the Ethernet over EtherCAT processing.
|
||||||
*/
|
*/
|
||||||
void ec_master_eoe_run(unsigned long data /**< master pointer */)
|
void ec_master_eoe_run(unsigned long data /**< master pointer */)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ struct ec_master {
|
||||||
#ifdef EC_EOE
|
#ifdef EC_EOE
|
||||||
struct timer_list eoe_timer; /**< EoE timer object. */
|
struct timer_list eoe_timer; /**< EoE timer object. */
|
||||||
unsigned int eoe_running; /**< \a True, if EoE processing is active. */
|
unsigned int eoe_running; /**< \a True, if EoE processing is active. */
|
||||||
struct list_head eoe_handlers; /**< Ethernet-over-EtherCAT handlers. */
|
struct list_head eoe_handlers; /**< Ethernet over EtherCAT handlers. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spinlock_t internal_lock; /**< Spinlock used in \a IDLE phase. */
|
spinlock_t internal_lock; /**< Spinlock used in \a IDLE phase. */
|
||||||
|
|
@ -154,8 +154,8 @@ struct ec_master {
|
||||||
wait_queue_head_t sii_queue; /**< Wait queue for SII
|
wait_queue_head_t sii_queue; /**< Wait queue for SII
|
||||||
write requests from user space. */
|
write requests from user space. */
|
||||||
|
|
||||||
struct list_head slave_sdo_requests; /**< Sdo access requests. */
|
struct list_head slave_sdo_requests; /**< SDO access requests. */
|
||||||
wait_queue_head_t sdo_queue; /**< Wait queue for Sdo access requests
|
wait_queue_head_t sdo_queue; /**< Wait queue for SDO access requests
|
||||||
from user space. */
|
from user space. */
|
||||||
|
|
||||||
struct list_head phy_requests; /**< Physical memory requests. */
|
struct list_head phy_requests; /**< Physical memory requests. */
|
||||||
|
|
|
||||||
50
master/pdo.c
50
master/pdo.c
|
|
@ -38,10 +38,10 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo constructor.
|
/** PDO constructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_init(
|
void ec_pdo_init(
|
||||||
ec_pdo_t *pdo /**< EtherCAT Pdo */
|
ec_pdo_t *pdo /**< EtherCAT PDO */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pdo->sync_index = -1; // not assigned
|
pdo->sync_index = -1; // not assigned
|
||||||
|
|
@ -51,7 +51,7 @@ void ec_pdo_init(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo copy constructor.
|
/** PDO copy constructor.
|
||||||
*
|
*
|
||||||
* \retval 0 Success.
|
* \retval 0 Success.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
|
|
@ -83,9 +83,9 @@ out_return:
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo destructor.
|
/** PDO destructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_clear(ec_pdo_t *pdo /**< EtherCAT Pdo. */)
|
void ec_pdo_clear(ec_pdo_t *pdo /**< EtherCAT PDO. */)
|
||||||
{
|
{
|
||||||
if (pdo->name)
|
if (pdo->name)
|
||||||
kfree(pdo->name);
|
kfree(pdo->name);
|
||||||
|
|
@ -95,13 +95,13 @@ void ec_pdo_clear(ec_pdo_t *pdo /**< EtherCAT Pdo. */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Clear Pdo entry list.
|
/** Clear PDO entry list.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_clear_entries(ec_pdo_t *pdo /**< EtherCAT Pdo. */)
|
void ec_pdo_clear_entries(ec_pdo_t *pdo /**< EtherCAT PDO. */)
|
||||||
{
|
{
|
||||||
ec_pdo_entry_t *entry, *next;
|
ec_pdo_entry_t *entry, *next;
|
||||||
|
|
||||||
// free all Pdo entries
|
// free all PDO entries
|
||||||
list_for_each_entry_safe(entry, next, &pdo->entries, list) {
|
list_for_each_entry_safe(entry, next, &pdo->entries, list) {
|
||||||
list_del(&entry->list);
|
list_del(&entry->list);
|
||||||
ec_pdo_entry_clear(entry);
|
ec_pdo_entry_clear(entry);
|
||||||
|
|
@ -111,13 +111,13 @@ void ec_pdo_clear_entries(ec_pdo_t *pdo /**< EtherCAT Pdo. */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Set Pdo name.
|
/** Set PDO name.
|
||||||
*
|
*
|
||||||
* \retval 0 Success.
|
* \retval 0 Success.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_set_name(
|
int ec_pdo_set_name(
|
||||||
ec_pdo_t *pdo, /**< Pdo. */
|
ec_pdo_t *pdo, /**< PDO. */
|
||||||
const char *name /**< New name. */
|
const char *name /**< New name. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -131,7 +131,7 @@ int ec_pdo_set_name(
|
||||||
|
|
||||||
if (name && (len = strlen(name))) {
|
if (name && (len = strlen(name))) {
|
||||||
if (!(pdo->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
|
if (!(pdo->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo name.\n");
|
EC_ERR("Failed to allocate PDO name.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memcpy(pdo->name, name, len + 1);
|
memcpy(pdo->name, name, len + 1);
|
||||||
|
|
@ -144,7 +144,7 @@ int ec_pdo_set_name(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add a new Pdo entry to the configuration.
|
/** Add a new PDO entry to the configuration.
|
||||||
*
|
*
|
||||||
* \retval Pointer to the added entry, otherwise a ERR_PTR() code.
|
* \retval Pointer to the added entry, otherwise a ERR_PTR() code.
|
||||||
*/
|
*/
|
||||||
|
|
@ -158,7 +158,7 @@ ec_pdo_entry_t *ec_pdo_add_entry(
|
||||||
ec_pdo_entry_t *entry;
|
ec_pdo_entry_t *entry;
|
||||||
|
|
||||||
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate memory for Pdo entry.\n");
|
EC_ERR("Failed to allocate memory for PDO entry.\n");
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ ec_pdo_entry_t *ec_pdo_add_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Copy Pdo entries from another Pdo.
|
/** Copy PDO entries from another PDO.
|
||||||
*
|
*
|
||||||
* \retval 0 Success.
|
* \retval 0 Success.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
|
|
@ -187,7 +187,7 @@ int ec_pdo_copy_entries(ec_pdo_t *pdo, const ec_pdo_t *other)
|
||||||
list_for_each_entry(other_entry, &other->entries, list) {
|
list_for_each_entry(other_entry, &other->entries, list) {
|
||||||
if (!(entry = (ec_pdo_entry_t *)
|
if (!(entry = (ec_pdo_entry_t *)
|
||||||
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate memory for Pdo entry copy.\n");
|
EC_ERR("Failed to allocate memory for PDO entry copy.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,14 +205,14 @@ int ec_pdo_copy_entries(ec_pdo_t *pdo, const ec_pdo_t *other)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Compares the entries of two Pdos.
|
/** Compares the entries of two PDOs.
|
||||||
*
|
*
|
||||||
* \retval 1 The entries of the given Pdos are equal.
|
* \retval 1 The entries of the given PDOs are equal.
|
||||||
* \retval 0 The entries of the given Pdos differ.
|
* \retval 0 The entries of the given PDOs differ.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_equal_entries(
|
int ec_pdo_equal_entries(
|
||||||
const ec_pdo_t *pdo1, /**< First Pdo. */
|
const ec_pdo_t *pdo1, /**< First PDO. */
|
||||||
const ec_pdo_t *pdo2 /**< Second Pdo. */
|
const ec_pdo_t *pdo2 /**< Second PDO. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const struct list_head *head1, *head2, *item1, *item2;
|
const struct list_head *head1, *head2, *item1, *item2;
|
||||||
|
|
@ -241,12 +241,12 @@ int ec_pdo_equal_entries(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get the number of Pdo entries.
|
/** Get the number of PDO entries.
|
||||||
*
|
*
|
||||||
* \return Number of Pdo entries.
|
* \return Number of PDO entries.
|
||||||
*/
|
*/
|
||||||
unsigned int ec_pdo_entry_count(
|
unsigned int ec_pdo_entry_count(
|
||||||
const ec_pdo_t *pdo /**< Pdo. */
|
const ec_pdo_t *pdo /**< PDO. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_pdo_entry_t *entry;
|
const ec_pdo_entry_t *entry;
|
||||||
|
|
@ -261,12 +261,12 @@ unsigned int ec_pdo_entry_count(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a Pdo entry via its position in the list.
|
/** Finds a PDO entry via its position in the list.
|
||||||
*
|
*
|
||||||
* Const version.
|
* Const version.
|
||||||
*/
|
*/
|
||||||
const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const(
|
const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const(
|
||||||
const ec_pdo_t *pdo, /**< Pdo. */
|
const ec_pdo_t *pdo, /**< PDO. */
|
||||||
unsigned int pos /**< Position in the list. */
|
unsigned int pos /**< Position in the list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo description.
|
/** PDO description.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct list_head list; /**< List item. */
|
struct list_head list; /**< List item. */
|
||||||
uint16_t index; /**< Pdo index. */
|
uint16_t index; /**< PDO index. */
|
||||||
int8_t sync_index; /**< Assigned sync manager. \todo remove? */
|
int8_t sync_index; /**< Assigned sync manager. \todo remove? */
|
||||||
char *name; /**< Pdo name. */
|
char *name; /**< PDO name. */
|
||||||
struct list_head entries; /**< List of Pdo entries. */
|
struct list_head entries; /**< List of PDO entries. */
|
||||||
} ec_pdo_t;
|
} ec_pdo_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo entry constructor.
|
/** PDO entry constructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_entry_init(
|
void ec_pdo_entry_init(
|
||||||
ec_pdo_entry_t *entry /**< Pdo entry. */
|
ec_pdo_entry_t *entry /**< PDO entry. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
entry->name = NULL;
|
entry->name = NULL;
|
||||||
|
|
@ -48,14 +48,14 @@ void ec_pdo_entry_init(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo entry copy constructor.
|
/** PDO entry copy constructor.
|
||||||
*
|
*
|
||||||
* \retval 0 Success.
|
* \retval 0 Success.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_entry_init_copy(
|
int ec_pdo_entry_init_copy(
|
||||||
ec_pdo_entry_t *entry, /**< Pdo entry. */
|
ec_pdo_entry_t *entry, /**< PDO entry. */
|
||||||
const ec_pdo_entry_t *other /**< Pdo entry to copy from. */
|
const ec_pdo_entry_t *other /**< PDO entry to copy from. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
entry->index = other->index;
|
entry->index = other->index;
|
||||||
|
|
@ -68,9 +68,9 @@ int ec_pdo_entry_init_copy(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo entry destructor.
|
/** PDO entry destructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_entry_clear(ec_pdo_entry_t *entry /**< Pdo entry. */)
|
void ec_pdo_entry_clear(ec_pdo_entry_t *entry /**< PDO entry. */)
|
||||||
{
|
{
|
||||||
if (entry->name)
|
if (entry->name)
|
||||||
kfree(entry->name);
|
kfree(entry->name);
|
||||||
|
|
@ -78,13 +78,13 @@ void ec_pdo_entry_clear(ec_pdo_entry_t *entry /**< Pdo entry. */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Set Pdo entry name.
|
/** Set PDO entry name.
|
||||||
*
|
*
|
||||||
* \retval 0 Success.
|
* \retval 0 Success.
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_entry_set_name(
|
int ec_pdo_entry_set_name(
|
||||||
ec_pdo_entry_t *entry, /**< Pdo entry. */
|
ec_pdo_entry_t *entry, /**< PDO entry. */
|
||||||
const char *name /**< New name. */
|
const char *name /**< New name. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +98,7 @@ int ec_pdo_entry_set_name(
|
||||||
|
|
||||||
if (name && (len = strlen(name))) {
|
if (name && (len = strlen(name))) {
|
||||||
if (!(entry->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
|
if (!(entry->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo entry name.\n");
|
EC_ERR("Failed to allocate PDO entry name.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memcpy(entry->name, name, len + 1);
|
memcpy(entry->name, name, len + 1);
|
||||||
|
|
@ -111,14 +111,14 @@ int ec_pdo_entry_set_name(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Compares two Pdo entries.
|
/** Compares two PDO entries.
|
||||||
*
|
*
|
||||||
* \retval 1 The entries are equal.
|
* \retval 1 The entries are equal.
|
||||||
* \retval 0 The entries differ.
|
* \retval 0 The entries differ.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_entry_equal(
|
int ec_pdo_entry_equal(
|
||||||
const ec_pdo_entry_t *entry1, /**< First Pdo entry. */
|
const ec_pdo_entry_t *entry1, /**< First PDO entry. */
|
||||||
const ec_pdo_entry_t *entry2 /**< Second Pdo entry. */
|
const ec_pdo_entry_t *entry2 /**< Second PDO entry. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return entry1->index == entry2->index
|
return entry1->index == entry2->index
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo entry description.
|
/** PDO entry description.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct list_head list; /**< list item */
|
struct list_head list; /**< list item */
|
||||||
uint16_t index; /**< Pdo entry index */
|
uint16_t index; /**< PDO entry index */
|
||||||
uint8_t subindex; /**< Pdo entry subindex */
|
uint8_t subindex; /**< PDO entry subindex */
|
||||||
char *name; /**< entry name */
|
char *name; /**< entry name */
|
||||||
uint8_t bit_length; /**< entry length in bit */
|
uint8_t bit_length; /**< entry length in bit */
|
||||||
} ec_pdo_entry_t;
|
} ec_pdo_entry_t;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT Pdo list methods.
|
EtherCAT PDO list methods.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -42,10 +42,10 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo list constructor.
|
/** PDO list constructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_list_init(
|
void ec_pdo_list_init(
|
||||||
ec_pdo_list_t *pl /**< Pdo list. */
|
ec_pdo_list_t *pl /**< PDO list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&pl->list);
|
INIT_LIST_HEAD(&pl->list);
|
||||||
|
|
@ -53,18 +53,18 @@ void ec_pdo_list_init(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Pdo list destructor.
|
/** PDO list destructor.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_list_clear(ec_pdo_list_t *pl /**< Pdo list. */)
|
void ec_pdo_list_clear(ec_pdo_list_t *pl /**< PDO list. */)
|
||||||
{
|
{
|
||||||
ec_pdo_list_clear_pdos(pl);
|
ec_pdo_list_clear_pdos(pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Clears the list of mapped Pdos.
|
/** Clears the list of mapped PDOs.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl /**< Pdo list. */)
|
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl /**< PDO list. */)
|
||||||
{
|
{
|
||||||
ec_pdo_t *pdo, *next;
|
ec_pdo_t *pdo, *next;
|
||||||
|
|
||||||
|
|
@ -77,12 +77,12 @@ void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl /**< Pdo list. */)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Calculates the total size of the mapped Pdo entries.
|
/** Calculates the total size of the mapped PDO entries.
|
||||||
*
|
*
|
||||||
* \retval Data size in byte.
|
* \retval Data size in byte.
|
||||||
*/
|
*/
|
||||||
uint16_t ec_pdo_list_total_size(
|
uint16_t ec_pdo_list_total_size(
|
||||||
const ec_pdo_list_t *pl /**< Pdo list. */
|
const ec_pdo_list_t *pl /**< PDO list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned int bit_size;
|
unsigned int bit_size;
|
||||||
|
|
@ -107,19 +107,19 @@ uint16_t ec_pdo_list_total_size(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add a new Pdo to the list.
|
/** Add a new PDO to the list.
|
||||||
*
|
*
|
||||||
* \return Pointer to new Pdo, otherwise an ERR_PTR() code.
|
* \return Pointer to new PDO, otherwise an ERR_PTR() code.
|
||||||
*/
|
*/
|
||||||
ec_pdo_t *ec_pdo_list_add_pdo(
|
ec_pdo_t *ec_pdo_list_add_pdo(
|
||||||
ec_pdo_list_t *pl, /**< Pdo list. */
|
ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
uint16_t index /**< Pdo index. */
|
uint16_t index /**< PDO index. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_pdo_t *pdo;
|
ec_pdo_t *pdo;
|
||||||
|
|
||||||
if (!(pdo = (ec_pdo_t *) kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
if (!(pdo = (ec_pdo_t *) kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate memory for Pdo.\n");
|
EC_ERR("Failed to allocate memory for PDO.\n");
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,27 +131,27 @@ ec_pdo_t *ec_pdo_list_add_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Add the copy of an existing Pdo to the list.
|
/** Add the copy of an existing PDO to the list.
|
||||||
*
|
*
|
||||||
* \return 0 on success, else < 0
|
* \return 0 on success, else < 0
|
||||||
*/
|
*/
|
||||||
int ec_pdo_list_add_pdo_copy(
|
int ec_pdo_list_add_pdo_copy(
|
||||||
ec_pdo_list_t *pl, /**< Pdo list. */
|
ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
const ec_pdo_t *pdo /**< Pdo to add. */
|
const ec_pdo_t *pdo /**< PDO to add. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_pdo_t *mapped_pdo;
|
ec_pdo_t *mapped_pdo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// Pdo already mapped?
|
// PDO already mapped?
|
||||||
list_for_each_entry(mapped_pdo, &pl->list, list) {
|
list_for_each_entry(mapped_pdo, &pl->list, list) {
|
||||||
if (mapped_pdo->index != pdo->index) continue;
|
if (mapped_pdo->index != pdo->index) continue;
|
||||||
EC_ERR("Pdo 0x%04X is already mapped!\n", pdo->index);
|
EC_ERR("PDO 0x%04X is already mapped!\n", pdo->index);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo memory.\n");
|
EC_ERR("Failed to allocate PDO memory.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,13 +167,13 @@ int ec_pdo_list_add_pdo_copy(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Makes a deep copy of another Pdo list.
|
/** Makes a deep copy of another PDO list.
|
||||||
*
|
*
|
||||||
* \return 0 on success, else < 0
|
* \return 0 on success, else < 0
|
||||||
*/
|
*/
|
||||||
int ec_pdo_list_copy(
|
int ec_pdo_list_copy(
|
||||||
ec_pdo_list_t *pl, /**< Pdo list. */
|
ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
const ec_pdo_list_t *other /**< Pdo list to copy from. */
|
const ec_pdo_list_t *other /**< PDO list to copy from. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_pdo_t *other_pdo;
|
ec_pdo_t *other_pdo;
|
||||||
|
|
@ -181,7 +181,7 @@ int ec_pdo_list_copy(
|
||||||
|
|
||||||
ec_pdo_list_clear_pdos(pl);
|
ec_pdo_list_clear_pdos(pl);
|
||||||
|
|
||||||
// Pdo already mapped?
|
// PDO already mapped?
|
||||||
list_for_each_entry(other_pdo, &other->list, list) {
|
list_for_each_entry(other_pdo, &other->list, list) {
|
||||||
ret = ec_pdo_list_add_pdo_copy(pl, other_pdo);
|
ret = ec_pdo_list_add_pdo_copy(pl, other_pdo);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
@ -193,13 +193,13 @@ int ec_pdo_list_copy(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Compares two Pdo lists.
|
/** Compares two PDO lists.
|
||||||
*
|
*
|
||||||
* Only the list is compared, not the Pdo entries (i. e. the Pdo
|
* Only the list is compared, not the PDO entries (i. e. the PDO
|
||||||
* mapping).
|
* mapping).
|
||||||
*
|
*
|
||||||
* \retval 1 The given Pdo lists are equal.
|
* \retval 1 The given PDO lists are equal.
|
||||||
* \retval 0 The given Pdo lists differ.
|
* \retval 0 The given PDO lists differ.
|
||||||
*/
|
*/
|
||||||
int ec_pdo_list_equal(
|
int ec_pdo_list_equal(
|
||||||
const ec_pdo_list_t *pl1, /**< First list. */
|
const ec_pdo_list_t *pl1, /**< First list. */
|
||||||
|
|
@ -233,11 +233,11 @@ int ec_pdo_list_equal(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a Pdo with the given index.
|
/** Finds a PDO with the given index.
|
||||||
*/
|
*/
|
||||||
ec_pdo_t *ec_pdo_list_find_pdo(
|
ec_pdo_t *ec_pdo_list_find_pdo(
|
||||||
const ec_pdo_list_t *pl, /**< Pdo list. */
|
const ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
uint16_t index /**< Pdo index. */
|
uint16_t index /**< PDO index. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_pdo_t *pdo;
|
ec_pdo_t *pdo;
|
||||||
|
|
@ -253,11 +253,11 @@ ec_pdo_t *ec_pdo_list_find_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a Pdo with the given index and returns a const pointer.
|
/** Finds a PDO with the given index and returns a const pointer.
|
||||||
*/
|
*/
|
||||||
const ec_pdo_t *ec_pdo_list_find_pdo_const(
|
const ec_pdo_t *ec_pdo_list_find_pdo_const(
|
||||||
const ec_pdo_list_t *pl, /**< Pdo list. */
|
const ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
uint16_t index /**< Pdo index. */
|
uint16_t index /**< PDO index. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_pdo_t *pdo;
|
const ec_pdo_t *pdo;
|
||||||
|
|
@ -273,12 +273,12 @@ const ec_pdo_t *ec_pdo_list_find_pdo_const(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a Pdo via its position in the list.
|
/** Finds a PDO via its position in the list.
|
||||||
*
|
*
|
||||||
* Const version.
|
* Const version.
|
||||||
*/
|
*/
|
||||||
const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
|
const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
|
||||||
const ec_pdo_list_t *pl, /**< Pdo list. */
|
const ec_pdo_list_t *pl, /**< PDO list. */
|
||||||
unsigned int pos /**< Position in the list. */
|
unsigned int pos /**< Position in the list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -295,12 +295,12 @@ const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get the number of Pdos in the list.
|
/** Get the number of PDOs in the list.
|
||||||
*
|
*
|
||||||
* \return Number of Pdos.
|
* \return Number of PDOs.
|
||||||
*/
|
*/
|
||||||
unsigned int ec_pdo_list_count(
|
unsigned int ec_pdo_list_count(
|
||||||
const ec_pdo_list_t *pl /**< Pdo list. */
|
const ec_pdo_list_t *pl /**< PDO list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_pdo_t *pdo;
|
const ec_pdo_t *pdo;
|
||||||
|
|
@ -315,10 +315,10 @@ unsigned int ec_pdo_list_count(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Outputs the Pdos in the list.
|
/** Outputs the PDOs in the list.
|
||||||
*/
|
*/
|
||||||
void ec_pdo_list_print(
|
void ec_pdo_list_print(
|
||||||
const ec_pdo_list_t *pl /**< Pdo list. */
|
const ec_pdo_list_t *pl /**< PDO list. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_pdo_t *pdo;
|
const ec_pdo_t *pdo;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT Pdo list structure.
|
EtherCAT PDO list structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -41,10 +41,10 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** EtherCAT Pdo list.
|
/** EtherCAT PDO list.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct list_head list; /**< List of Pdos. */
|
struct list_head list; /**< List of PDOs. */
|
||||||
} ec_pdo_list_t;
|
} ec_pdo_list_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
28
master/sdo.c
28
master/sdo.c
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
CANopen Sdo functions.
|
CANopen SDO functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -42,9 +42,9 @@
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_init(
|
void ec_sdo_init(
|
||||||
ec_sdo_t *sdo, /**< Sdo. */
|
ec_sdo_t *sdo, /**< SDO. */
|
||||||
ec_slave_t *slave, /**< Parent slave. */
|
ec_slave_t *slave, /**< Parent slave. */
|
||||||
uint16_t index /**< Sdo index. */
|
uint16_t index /**< SDO index. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
sdo->slave = slave;
|
sdo->slave = slave;
|
||||||
|
|
@ -57,12 +57,12 @@ void ec_sdo_init(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Sdo destructor.
|
/** SDO destructor.
|
||||||
*
|
*
|
||||||
* Clears and frees an Sdo object.
|
* Clears and frees an SDO object.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_clear(
|
void ec_sdo_clear(
|
||||||
ec_sdo_t *sdo /**< Sdo. */
|
ec_sdo_t *sdo /**< SDO. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_entry_t *entry, *next;
|
ec_sdo_entry_t *entry, *next;
|
||||||
|
|
@ -80,13 +80,13 @@ void ec_sdo_clear(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get an Sdo entry from an Sdo via its subindex.
|
/** Get an SDO entry from an SDO via its subindex.
|
||||||
*
|
*
|
||||||
* \retval >0 Pointer to the requested Sdo entry.
|
* \retval >0 Pointer to the requested SDO entry.
|
||||||
* \retval NULL Sdo entry not found.
|
* \retval NULL SDO entry not found.
|
||||||
*/
|
*/
|
||||||
ec_sdo_entry_t *ec_sdo_get_entry(
|
ec_sdo_entry_t *ec_sdo_get_entry(
|
||||||
ec_sdo_t *sdo, /**< Sdo. */
|
ec_sdo_t *sdo, /**< SDO. */
|
||||||
uint8_t subindex /**< Entry subindex. */
|
uint8_t subindex /**< Entry subindex. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -103,15 +103,15 @@ ec_sdo_entry_t *ec_sdo_get_entry(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get an Sdo entry from an Sdo via its subindex.
|
/** Get an SDO entry from an SDO via its subindex.
|
||||||
*
|
*
|
||||||
* const version.
|
* const version.
|
||||||
*
|
*
|
||||||
* \retval >0 Pointer to the requested Sdo entry.
|
* \retval >0 Pointer to the requested SDO entry.
|
||||||
* \retval NULL Sdo entry not found.
|
* \retval NULL SDO entry not found.
|
||||||
*/
|
*/
|
||||||
const ec_sdo_entry_t *ec_sdo_get_entry_const(
|
const ec_sdo_entry_t *ec_sdo_get_entry_const(
|
||||||
const ec_sdo_t *sdo, /**< Sdo. */
|
const ec_sdo_t *sdo, /**< SDO. */
|
||||||
uint8_t subindex /**< Entry subindex. */
|
uint8_t subindex /**< Entry subindex. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT CANopen Sdo structure.
|
EtherCAT CANopen SDO structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -41,14 +41,14 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** CANopen Sdo.
|
/** CANopen SDO.
|
||||||
*/
|
*/
|
||||||
struct ec_sdo {
|
struct ec_sdo {
|
||||||
struct list_head list; /**< List item. */
|
struct list_head list; /**< List item. */
|
||||||
ec_slave_t *slave; /**< Parent slave. */
|
ec_slave_t *slave; /**< Parent slave. */
|
||||||
uint16_t index; /**< Sdo index. */
|
uint16_t index; /**< SDO index. */
|
||||||
uint8_t object_code; /**< Object code. */
|
uint8_t object_code; /**< Object code. */
|
||||||
char *name; /**< Sdo name. */
|
char *name; /**< SDO name. */
|
||||||
uint8_t max_subindex; /**< Maximum subindex. */
|
uint8_t max_subindex; /**< Maximum subindex. */
|
||||||
struct list_head entries; /**< List of entries. */
|
struct list_head entries; /**< List of entries. */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
CANopen-over-EtherCAT Sdo entry functions.
|
CANopen over EtherCAT SDO entry functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -40,8 +40,8 @@
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_entry_init(
|
void ec_sdo_entry_init(
|
||||||
ec_sdo_entry_t *entry, /**< Sdo entry. */
|
ec_sdo_entry_t *entry, /**< SDO entry. */
|
||||||
ec_sdo_t *sdo, /**< Parent Sdo. */
|
ec_sdo_t *sdo, /**< Parent SDO. */
|
||||||
uint8_t subindex /**< Subindex. */
|
uint8_t subindex /**< Subindex. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ void ec_sdo_entry_init(
|
||||||
/** Destructor.
|
/** Destructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_entry_clear(
|
void ec_sdo_entry_clear(
|
||||||
ec_sdo_entry_t *entry /**< Sdo entry. */
|
ec_sdo_entry_t *entry /**< SDO entry. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT CANopen Sdo entry structure.
|
EtherCAT CANopen SDO entry structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -46,11 +46,11 @@ typedef struct ec_sdo ec_sdo_t; /**< \see ec_sdo. */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** CANopen Sdo entry.
|
/** CANopen SDO entry.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct list_head list; /**< List item. */
|
struct list_head list; /**< List item. */
|
||||||
ec_sdo_t *sdo; /**< Parent Sdo. */
|
ec_sdo_t *sdo; /**< Parent SDO. */
|
||||||
uint8_t subindex; /**< Subindex. */
|
uint8_t subindex; /**< Subindex. */
|
||||||
uint16_t data_type; /**< Data type. */
|
uint16_t data_type; /**< Data type. */
|
||||||
uint16_t bit_length; /**< Data size in bit. */
|
uint16_t bit_length; /**< Data size in bit. */
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* Canopen-over-EtherCAT Sdo request functions.
|
* Canopen over EtherCAT SDO request functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Default timeout in ms to wait for Sdo transfer responses.
|
/** Default timeout in ms to wait for SDO transfer responses.
|
||||||
*/
|
*/
|
||||||
#define EC_SDO_REQUEST_RESPONSE_TIMEOUT 3000
|
#define EC_SDO_REQUEST_RESPONSE_TIMEOUT 3000
|
||||||
|
|
||||||
|
|
@ -47,10 +47,10 @@ void ec_sdo_request_clear_data(ec_sdo_request_t *);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Sdo request constructor.
|
/** SDO request constructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_request_init(
|
void ec_sdo_request_init(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
req->data = NULL;
|
req->data = NULL;
|
||||||
|
|
@ -65,10 +65,10 @@ void ec_sdo_request_init(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Sdo request destructor.
|
/** SDO request destructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_request_clear(
|
void ec_sdo_request_clear(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_request_clear_data(req);
|
ec_sdo_request_clear_data(req);
|
||||||
|
|
@ -76,7 +76,7 @@ void ec_sdo_request_clear(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Copy another Sdo request.
|
/** Copy another SDO request.
|
||||||
*
|
*
|
||||||
* \attention Only the index subindex and data are copied.
|
* \attention Only the index subindex and data are copied.
|
||||||
*/
|
*/
|
||||||
|
|
@ -92,10 +92,10 @@ int ec_sdo_request_copy(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Sdo request destructor.
|
/** SDO request destructor.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_request_clear_data(
|
void ec_sdo_request_clear_data(
|
||||||
ec_sdo_request_t *req /**< Sdo request. */
|
ec_sdo_request_t *req /**< SDO request. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (req->data) {
|
if (req->data) {
|
||||||
|
|
@ -109,12 +109,12 @@ void ec_sdo_request_clear_data(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Set the Sdo address.
|
/** Set the SDO address.
|
||||||
*/
|
*/
|
||||||
void ec_sdo_request_address(
|
void ec_sdo_request_address(
|
||||||
ec_sdo_request_t *req, /**< Sdo request. */
|
ec_sdo_request_t *req, /**< SDO request. */
|
||||||
uint16_t index, /**< Sdo index. */
|
uint16_t index, /**< SDO index. */
|
||||||
uint8_t subindex /**< Sdo subindex. */
|
uint8_t subindex /**< SDO subindex. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
req->index = index;
|
req->index = index;
|
||||||
|
|
@ -130,7 +130,7 @@ void ec_sdo_request_address(
|
||||||
* \return 0 on success, otherwise -ENOMEM.
|
* \return 0 on success, otherwise -ENOMEM.
|
||||||
*/
|
*/
|
||||||
int ec_sdo_request_alloc(
|
int ec_sdo_request_alloc(
|
||||||
ec_sdo_request_t *req, /**< Sdo request. */
|
ec_sdo_request_t *req, /**< SDO request. */
|
||||||
size_t size /**< Data size to allocate. */
|
size_t size /**< Data size to allocate. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -140,7 +140,7 @@ int ec_sdo_request_alloc(
|
||||||
ec_sdo_request_clear_data(req);
|
ec_sdo_request_clear_data(req);
|
||||||
|
|
||||||
if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
|
if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate %u bytes of Sdo memory.\n", size);
|
EC_ERR("Failed to allocate %u bytes of SDO memory.\n", size);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ int ec_sdo_request_alloc(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Copies Sdo data from an external source.
|
/** Copies SDO data from an external source.
|
||||||
*
|
*
|
||||||
* If the \a mem_size is to small, new memory is allocated.
|
* If the \a mem_size is to small, new memory is allocated.
|
||||||
*
|
*
|
||||||
|
|
@ -159,7 +159,7 @@ int ec_sdo_request_alloc(
|
||||||
* \retval <0 Error code.
|
* \retval <0 Error code.
|
||||||
*/
|
*/
|
||||||
int ec_sdo_request_copy_data(
|
int ec_sdo_request_copy_data(
|
||||||
ec_sdo_request_t *req, /**< Sdo request. */
|
ec_sdo_request_t *req, /**< SDO request. */
|
||||||
const uint8_t *source, /**< Source data. */
|
const uint8_t *source, /**< Source data. */
|
||||||
size_t size /**< Number of bytes in \a source. */
|
size_t size /**< Number of bytes in \a source. */
|
||||||
)
|
)
|
||||||
|
|
@ -179,7 +179,7 @@ int ec_sdo_request_copy_data(
|
||||||
*
|
*
|
||||||
* \return non-zero if the timeout was exceeded, else zero.
|
* \return non-zero if the timeout was exceeded, else zero.
|
||||||
*/
|
*/
|
||||||
int ec_sdo_request_timed_out(const ec_sdo_request_t *req /**< Sdo request. */)
|
int ec_sdo_request_timed_out(const ec_sdo_request_t *req /**< SDO request. */)
|
||||||
{
|
{
|
||||||
return req->issue_timeout
|
return req->issue_timeout
|
||||||
&& jiffies - req->jiffies_start > HZ * req->issue_timeout / 1000;
|
&& jiffies - req->jiffies_start > HZ * req->issue_timeout / 1000;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
EtherCAT CANopen Sdo request structure.
|
EtherCAT CANopen SDO request structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -40,15 +40,15 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** CANopen Sdo request.
|
/** CANopen SDO request.
|
||||||
*/
|
*/
|
||||||
struct ec_sdo_request {
|
struct ec_sdo_request {
|
||||||
struct list_head list; /**< List item. */
|
struct list_head list; /**< List item. */
|
||||||
uint16_t index; /**< Sdo index. */
|
uint16_t index; /**< SDO index. */
|
||||||
uint8_t subindex; /**< Sdo subindex. */
|
uint8_t subindex; /**< SDO subindex. */
|
||||||
uint8_t *data; /**< Pointer to Sdo data. */
|
uint8_t *data; /**< Pointer to SDO data. */
|
||||||
size_t mem_size; /**< Size of Sdo data memory. */
|
size_t mem_size; /**< Size of SDO data memory. */
|
||||||
size_t data_size; /**< Size of Sdo data. */
|
size_t data_size; /**< Size of SDO data. */
|
||||||
uint32_t issue_timeout; /**< Maximum time in ms, the processing of the
|
uint32_t issue_timeout; /**< Maximum time in ms, the processing of the
|
||||||
request may take. */
|
request may take. */
|
||||||
uint32_t response_timeout; /**< Maximum time in ms, the transfer is
|
uint32_t response_timeout; /**< Maximum time in ms, the transfer is
|
||||||
|
|
@ -56,11 +56,11 @@ struct ec_sdo_request {
|
||||||
ec_direction_t dir; /**< Direction. EC_DIR_OUTPUT means downloading to
|
ec_direction_t dir; /**< Direction. EC_DIR_OUTPUT means downloading to
|
||||||
the slave, EC_DIR_INPUT means uploading from the
|
the slave, EC_DIR_INPUT means uploading from the
|
||||||
slave. */
|
slave. */
|
||||||
ec_internal_request_state_t state; /**< Sdo request state. */
|
ec_internal_request_state_t state; /**< SDO request state. */
|
||||||
unsigned long jiffies_start; /**< Jiffies, when the request was issued. */
|
unsigned long jiffies_start; /**< Jiffies, when the request was issued. */
|
||||||
unsigned long jiffies_sent; /**< Jiffies, when the upload/download
|
unsigned long jiffies_sent; /**< Jiffies, when the upload/download
|
||||||
request was sent. */
|
request was sent. */
|
||||||
uint32_t abort_code; /**< Sdo request abort code. Zero on success. */
|
uint32_t abort_code; /**< SDO request abort code. Zero on success. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ void ec_slave_clear(ec_slave_t *slave /**< EtherCAT slave */)
|
||||||
if (slave->config)
|
if (slave->config)
|
||||||
ec_slave_config_detach(slave->config);
|
ec_slave_config_detach(slave->config);
|
||||||
|
|
||||||
// free all Sdos
|
// free all SDOs
|
||||||
list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) {
|
list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) {
|
||||||
list_del(&sdo->list);
|
list_del(&sdo->list);
|
||||||
ec_sdo_clear(sdo);
|
ec_sdo_clear(sdo);
|
||||||
|
|
@ -157,7 +157,7 @@ void ec_slave_clear(ec_slave_t *slave /**< EtherCAT slave */)
|
||||||
// free all sync managers
|
// free all sync managers
|
||||||
ec_slave_clear_sync_managers(slave);
|
ec_slave_clear_sync_managers(slave);
|
||||||
|
|
||||||
// free all SII Pdos
|
// free all SII PDOs
|
||||||
list_for_each_entry_safe(pdo, next_pdo, &slave->sii.pdos, list) {
|
list_for_each_entry_safe(pdo, next_pdo, &slave->sii.pdos, list) {
|
||||||
list_del(&pdo->list);
|
list_del(&pdo->list);
|
||||||
ec_pdo_clear(pdo);
|
ec_pdo_clear(pdo);
|
||||||
|
|
@ -398,7 +398,7 @@ int ec_slave_fetch_sii_syncs(
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches data from a [RT]XPdo category.
|
Fetches data from a [RT]xPDO category.
|
||||||
\return 0 in case of success, else < 0
|
\return 0 in case of success, else < 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -406,7 +406,7 @@ int ec_slave_fetch_sii_pdos(
|
||||||
ec_slave_t *slave, /**< EtherCAT slave */
|
ec_slave_t *slave, /**< EtherCAT slave */
|
||||||
const uint8_t *data, /**< category data */
|
const uint8_t *data, /**< category data */
|
||||||
size_t data_size, /**< number of bytes */
|
size_t data_size, /**< number of bytes */
|
||||||
ec_direction_t dir /**< Pdo direction. */
|
ec_direction_t dir /**< PDO direction. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -416,7 +416,7 @@ int ec_slave_fetch_sii_pdos(
|
||||||
|
|
||||||
while (data_size >= 8) {
|
while (data_size >= 8) {
|
||||||
if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo memory.\n");
|
EC_ERR("Failed to allocate PDO memory.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,7 +438,7 @@ int ec_slave_fetch_sii_pdos(
|
||||||
|
|
||||||
for (i = 0; i < entry_count; i++) {
|
for (i = 0; i < entry_count; i++) {
|
||||||
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Pdo entry memory.\n");
|
EC_ERR("Failed to allocate PDO entry memory.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,12 +459,12 @@ int ec_slave_fetch_sii_pdos(
|
||||||
data += 8;
|
data += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if sync manager index is positive, the Pdo is mapped by default
|
// if sync manager index is positive, the PDO is mapped by default
|
||||||
if (pdo->sync_index >= 0) {
|
if (pdo->sync_index >= 0) {
|
||||||
ec_sync_t *sync;
|
ec_sync_t *sync;
|
||||||
|
|
||||||
if (!(sync = ec_slave_get_sync(slave, pdo->sync_index))) {
|
if (!(sync = ec_slave_get_sync(slave, pdo->sync_index))) {
|
||||||
EC_ERR("Invalid SM index %i for Pdo 0x%04X in slave %u.",
|
EC_ERR("Invalid SM index %i for PDO 0x%04X in slave %u.",
|
||||||
pdo->sync_index, pdo->index, slave->ring_position);
|
pdo->sync_index, pdo->index, slave->ring_position);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
@ -524,11 +524,11 @@ ec_sync_t *ec_slave_get_sync(
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Counts the total number of Sdos and entries in the dictionary.
|
Counts the total number of SDOs and entries in the dictionary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */
|
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */
|
||||||
unsigned int *sdo_count, /**< number of Sdos */
|
unsigned int *sdo_count, /**< number of SDOs */
|
||||||
unsigned int *entry_count /**< total number of
|
unsigned int *entry_count /**< total number of
|
||||||
entries */
|
entries */
|
||||||
)
|
)
|
||||||
|
|
@ -551,13 +551,13 @@ void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an Sdo from the dictionary.
|
* Get an SDO from the dictionary.
|
||||||
* \returns The desired Sdo, or NULL.
|
* \returns The desired SDO, or NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ec_sdo_t *ec_slave_get_sdo(
|
ec_sdo_t *ec_slave_get_sdo(
|
||||||
ec_slave_t *slave, /**< EtherCAT slave */
|
ec_slave_t *slave, /**< EtherCAT slave */
|
||||||
uint16_t index /**< Sdo index */
|
uint16_t index /**< SDO index */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_sdo_t *sdo;
|
ec_sdo_t *sdo;
|
||||||
|
|
@ -574,16 +574,16 @@ ec_sdo_t *ec_slave_get_sdo(
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an Sdo from the dictionary.
|
* Get an SDO from the dictionary.
|
||||||
*
|
*
|
||||||
* const version.
|
* const version.
|
||||||
*
|
*
|
||||||
* \returns The desired Sdo, or NULL.
|
* \returns The desired SDO, or NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ec_sdo_t *ec_slave_get_sdo_const(
|
const ec_sdo_t *ec_slave_get_sdo_const(
|
||||||
const ec_slave_t *slave, /**< EtherCAT slave */
|
const ec_slave_t *slave, /**< EtherCAT slave */
|
||||||
uint16_t index /**< Sdo index */
|
uint16_t index /**< SDO index */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_sdo_t *sdo;
|
const ec_sdo_t *sdo;
|
||||||
|
|
@ -599,13 +599,13 @@ const ec_sdo_t *ec_slave_get_sdo_const(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get an Sdo from the dictionary, given its position in the list.
|
/** Get an SDO from the dictionary, given its position in the list.
|
||||||
* \returns The desired Sdo, or NULL.
|
* \returns The desired SDO, or NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ec_sdo_t *ec_slave_get_sdo_by_pos_const(
|
const ec_sdo_t *ec_slave_get_sdo_by_pos_const(
|
||||||
const ec_slave_t *slave, /**< EtherCAT slave. */
|
const ec_slave_t *slave, /**< EtherCAT slave. */
|
||||||
uint16_t sdo_position /**< Sdo list position. */
|
uint16_t sdo_position /**< SDO list position. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const ec_sdo_t *sdo;
|
const ec_sdo_t *sdo;
|
||||||
|
|
@ -621,8 +621,8 @@ const ec_sdo_t *ec_slave_get_sdo_by_pos_const(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get the number of Sdos in the dictionary.
|
/** Get the number of SDOs in the dictionary.
|
||||||
* \returns Sdo count.
|
* \returns SDO count.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint16_t ec_slave_sdo_count(
|
uint16_t ec_slave_sdo_count(
|
||||||
|
|
@ -641,12 +641,12 @@ uint16_t ec_slave_sdo_count(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds a mapped Pdo.
|
/** Finds a mapped PDO.
|
||||||
* \returns The desired Pdo object, or NULL.
|
* \returns The desired PDO object, or NULL.
|
||||||
*/
|
*/
|
||||||
const ec_pdo_t *ec_slave_find_pdo(
|
const ec_pdo_t *ec_slave_find_pdo(
|
||||||
const ec_slave_t *slave, /**< Slave. */
|
const ec_slave_t *slave, /**< Slave. */
|
||||||
uint16_t index /**< Pdo index to find. */
|
uint16_t index /**< PDO index to find. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
@ -667,7 +667,7 @@ const ec_pdo_t *ec_slave_find_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Find name for a Pdo and its entries.
|
/** Find name for a PDO and its entries.
|
||||||
*/
|
*/
|
||||||
void ec_slave_find_names_for_pdo(
|
void ec_slave_find_names_for_pdo(
|
||||||
ec_slave_t *slave,
|
ec_slave_t *slave,
|
||||||
|
|
@ -698,7 +698,7 @@ void ec_slave_find_names_for_pdo(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Attach Pdo names.
|
/** Attach PDO names.
|
||||||
*/
|
*/
|
||||||
void ec_slave_attach_pdo_names(
|
void ec_slave_attach_pdo_names(
|
||||||
ec_slave_t *slave
|
ec_slave_t *slave
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ struct ec_slave
|
||||||
// Slave information interface
|
// Slave information interface
|
||||||
ec_sii_t sii; /**< Extracted SII data. */
|
ec_sii_t sii; /**< Extracted SII data. */
|
||||||
|
|
||||||
struct list_head sdo_dictionary; /**< Sdo dictionary list */
|
struct list_head sdo_dictionary; /**< SDO dictionary list */
|
||||||
uint8_t sdo_dictionary_fetched; /**< Dictionary has been fetched. */
|
uint8_t sdo_dictionary_fetched; /**< Dictionary has been fetched. */
|
||||||
unsigned long jiffies_preop; /**< Time, the slave went to PREOP. */
|
unsigned long jiffies_preop; /**< Time, the slave went to PREOP. */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -94,14 +94,14 @@ void ec_slave_config_clear(
|
||||||
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
|
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
|
||||||
ec_sync_config_clear(&sc->sync_configs[i]);
|
ec_sync_config_clear(&sc->sync_configs[i]);
|
||||||
|
|
||||||
// free all Sdo configurations
|
// free all SDO configurations
|
||||||
list_for_each_entry_safe(req, next_req, &sc->sdo_configs, list) {
|
list_for_each_entry_safe(req, next_req, &sc->sdo_configs, list) {
|
||||||
list_del(&req->list);
|
list_del(&req->list);
|
||||||
ec_sdo_request_clear(req);
|
ec_sdo_request_clear(req);
|
||||||
kfree(req);
|
kfree(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// free all Sdo requests
|
// free all SDO requests
|
||||||
list_for_each_entry_safe(req, next_req, &sc->sdo_requests, list) {
|
list_for_each_entry_safe(req, next_req, &sc->sdo_requests, list) {
|
||||||
list_del(&req->list);
|
list_del(&req->list);
|
||||||
ec_sdo_request_clear(req);
|
ec_sdo_request_clear(req);
|
||||||
|
|
@ -134,7 +134,7 @@ int ec_slave_config_prepare_fmmu(
|
||||||
ec_slave_config_t *sc, /**< Slave configuration. */
|
ec_slave_config_t *sc, /**< Slave configuration. */
|
||||||
ec_domain_t *domain, /**< Domain. */
|
ec_domain_t *domain, /**< Domain. */
|
||||||
uint8_t sync_index, /**< Sync manager index. */
|
uint8_t sync_index, /**< Sync manager index. */
|
||||||
ec_direction_t dir /**< Pdo direction. */
|
ec_direction_t dir /**< PDO direction. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
@ -234,7 +234,7 @@ void ec_slave_config_detach(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Loads the default Pdo assignment from the slave object.
|
/** Loads the default PDO assignment from the slave object.
|
||||||
*/
|
*/
|
||||||
void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
|
void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +259,7 @@ void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Loads the default mapping for a Pdo from the slave object.
|
/** Loads the default mapping for a PDO from the slave object.
|
||||||
*/
|
*/
|
||||||
void ec_slave_config_load_default_mapping(
|
void ec_slave_config_load_default_mapping(
|
||||||
const ec_slave_config_t *sc,
|
const ec_slave_config_t *sc,
|
||||||
|
|
@ -274,10 +274,10 @@ void ec_slave_config_load_default_mapping(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sc->master->debug_level)
|
if (sc->master->debug_level)
|
||||||
EC_DBG("Loading default mapping for Pdo 0x%04X in config %u:%u.\n",
|
EC_DBG("Loading default mapping for PDO 0x%04X in config %u:%u.\n",
|
||||||
pdo->index, sc->alias, sc->position);
|
pdo->index, sc->alias, sc->position);
|
||||||
|
|
||||||
// find Pdo in any sync manager (it could be reassigned later)
|
// find PDO in any sync manager (it could be reassigned later)
|
||||||
for (i = 0; i < sc->slave->sii.sync_count; i++) {
|
for (i = 0; i < sc->slave->sii.sync_count; i++) {
|
||||||
sync = &sc->slave->sii.syncs[i];
|
sync = &sc->slave->sii.syncs[i];
|
||||||
|
|
||||||
|
|
@ -287,13 +287,13 @@ void ec_slave_config_load_default_mapping(
|
||||||
|
|
||||||
if (default_pdo->name) {
|
if (default_pdo->name) {
|
||||||
if (sc->master->debug_level)
|
if (sc->master->debug_level)
|
||||||
EC_DBG("Found Pdo name \"%s\".\n", default_pdo->name);
|
EC_DBG("Found PDO name \"%s\".\n", default_pdo->name);
|
||||||
|
|
||||||
// take Pdo name from assigned one
|
// take PDO name from assigned one
|
||||||
ec_pdo_set_name(pdo, default_pdo->name);
|
ec_pdo_set_name(pdo, default_pdo->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy entries (= default Pdo mapping)
|
// copy entries (= default PDO mapping)
|
||||||
if (ec_pdo_copy_entries(pdo, default_pdo))
|
if (ec_pdo_copy_entries(pdo, default_pdo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -315,9 +315,9 @@ void ec_slave_config_load_default_mapping(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Get the number of Sdo configurations.
|
/** Get the number of SDO configurations.
|
||||||
*
|
*
|
||||||
* \return Number of Sdo configurations.
|
* \return Number of SDO configurations.
|
||||||
*/
|
*/
|
||||||
unsigned int ec_slave_config_sdo_count(
|
unsigned int ec_slave_config_sdo_count(
|
||||||
const ec_slave_config_t *sc /**< Slave configuration. */
|
const ec_slave_config_t *sc /**< Slave configuration. */
|
||||||
|
|
@ -335,7 +335,7 @@ unsigned int ec_slave_config_sdo_count(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Finds an Sdo configuration via its position in the list.
|
/** Finds an SDO configuration via its position in the list.
|
||||||
*
|
*
|
||||||
* Const version.
|
* Const version.
|
||||||
*/
|
*/
|
||||||
|
|
@ -484,7 +484,7 @@ int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
|
||||||
if (IS_ERR(entry))
|
if (IS_ERR(entry))
|
||||||
retval = PTR_ERR(entry);
|
retval = PTR_ERR(entry);
|
||||||
} else {
|
} else {
|
||||||
EC_ERR("Pdo 0x%04X is not assigned in config %u:%u.\n",
|
EC_ERR("PDO 0x%04X is not assigned in config %u:%u.\n",
|
||||||
pdo_index, sc->alias, sc->position);
|
pdo_index, sc->alias, sc->position);
|
||||||
retval = -ENOENT;
|
retval = -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
@ -514,7 +514,7 @@ void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
|
||||||
ec_pdo_clear_entries(pdo);
|
ec_pdo_clear_entries(pdo);
|
||||||
up(&sc->master->master_sem);
|
up(&sc->master->master_sem);
|
||||||
} else {
|
} else {
|
||||||
EC_WARN("Pdo 0x%04X is not assigned in config %u:%u.\n",
|
EC_WARN("PDO 0x%04X is not assigned in config %u:%u.\n",
|
||||||
pdo_index, sc->alias, sc->position);
|
pdo_index, sc->alias, sc->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -620,7 +620,7 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
if (bit_position) {
|
if (bit_position) {
|
||||||
*bit_position = bit_pos;
|
*bit_position = bit_pos;
|
||||||
} else if (bit_pos) {
|
} else if (bit_pos) {
|
||||||
EC_ERR("Pdo entry 0x%04X:%02X does not byte-align "
|
EC_ERR("PDO entry 0x%04X:%02X does not byte-align "
|
||||||
"in config %u:%u.\n", index, subindex,
|
"in config %u:%u.\n", index, subindex,
|
||||||
sc->alias, sc->position);
|
sc->alias, sc->position);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
@ -637,7 +637,7 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EC_ERR("Pdo entry 0x%04X:%02X is not mapped in slave config %u:%u.\n",
|
EC_ERR("PDO entry 0x%04X:%02X is not mapped in slave config %u:%u.\n",
|
||||||
index, subindex, sc->alias, sc->position);
|
index, subindex, sc->alias, sc->position);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
@ -664,7 +664,7 @@ int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
|
||||||
|
|
||||||
if (!(req = (ec_sdo_request_t *)
|
if (!(req = (ec_sdo_request_t *)
|
||||||
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate memory for Sdo configuration!\n");
|
EC_ERR("Failed to allocate memory for SDO configuration!\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -747,7 +747,7 @@ ec_sdo_request_t *ecrt_slave_config_create_sdo_request_err(
|
||||||
|
|
||||||
if (!(req = (ec_sdo_request_t *)
|
if (!(req = (ec_sdo_request_t *)
|
||||||
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Sdo request memory!\n");
|
EC_ERR("Failed to allocate SDO request memory!\n");
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -796,7 +796,7 @@ ec_voe_handler_t *ecrt_slave_config_create_voe_handler_err(
|
||||||
|
|
||||||
if (!(voe = (ec_voe_handler_t *)
|
if (!(voe = (ec_voe_handler_t *)
|
||||||
kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) {
|
kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) {
|
||||||
EC_ERR("Failed to allocate Sdo request memory!\n");
|
EC_ERR("Failed to allocate VoE request memory!\n");
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ struct ec_slave_config {
|
||||||
ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */
|
ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */
|
||||||
uint8_t used_fmmus; /**< Number of FMMUs used. */
|
uint8_t used_fmmus; /**< Number of FMMUs used. */
|
||||||
|
|
||||||
struct list_head sdo_configs; /**< List of Sdo configurations. */
|
struct list_head sdo_configs; /**< List of SDO configurations. */
|
||||||
struct list_head sdo_requests; /**< List of Sdo requests. */
|
struct list_head sdo_requests; /**< List of SDO requests. */
|
||||||
struct list_head voe_handlers; /**< List of VoE handlers. */
|
struct list_head voe_handlers; /**< List of VoE handlers. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,13 @@ void ec_sync_page(
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Adds a Pdo to the list of known mapped Pdos.
|
/** Adds a PDO to the list of known mapped PDOs.
|
||||||
*
|
*
|
||||||
* \return 0 on success, else < 0
|
* \return 0 on success, else < 0
|
||||||
*/
|
*/
|
||||||
int ec_sync_add_pdo(
|
int ec_sync_add_pdo(
|
||||||
ec_sync_t *sync, /**< EtherCAT sync manager. */
|
ec_sync_t *sync, /**< EtherCAT sync manager. */
|
||||||
const ec_pdo_t *pdo /**< Pdo to map. */
|
const ec_pdo_t *pdo /**< PDO to map. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ec_pdo_list_add_pdo_copy(&sync->pdos, pdo);
|
return ec_pdo_list_add_pdo_copy(&sync->pdos, pdo);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ typedef struct {
|
||||||
uint16_t default_length; /**< Data length in bytes. */
|
uint16_t default_length; /**< Data length in bytes. */
|
||||||
uint8_t control_register; /**< Control register value. */
|
uint8_t control_register; /**< Control register value. */
|
||||||
uint8_t enable; /**< Enable bit. */
|
uint8_t enable; /**< Enable bit. */
|
||||||
ec_pdo_list_t pdos; /**< Current Pdo assignment. */
|
ec_pdo_list_t pdos; /**< Current PDO assignment. */
|
||||||
} ec_sync_t;
|
} ec_sync_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ec_direction_t dir; /**< Sync manager direction. */
|
ec_direction_t dir; /**< Sync manager direction. */
|
||||||
ec_pdo_list_t pdos; /**< Current Pdo assignment. */
|
ec_pdo_list_t pdos; /**< Current PDO assignment. */
|
||||||
} ec_sync_config_t;
|
} ec_sync_config_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* Vendor-specific-over-EtherCAT protocol handler functions.
|
* Vendor specific over EtherCAT protocol handler functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file
|
\file
|
||||||
Vendor-specific-over-EtherCAT protocol handler.
|
Vendor specific over EtherCAT protocol handler.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Vendor-specific-over-EtherCAT handler.
|
/** Vendor specific over EtherCAT handler.
|
||||||
*/
|
*/
|
||||||
struct ec_voe_handler {
|
struct ec_voe_handler {
|
||||||
struct list_head list; /**< List item. */
|
struct list_head list; /**< List item. */
|
||||||
|
|
@ -49,7 +49,7 @@ struct ec_voe_handler {
|
||||||
ec_datagram_t datagram; /**< State machine datagram. */
|
ec_datagram_t datagram; /**< State machine datagram. */
|
||||||
uint32_t vendor_id; /**< Vendor ID for the header. */
|
uint32_t vendor_id; /**< Vendor ID for the header. */
|
||||||
uint16_t vendor_type; /**< Vendor type for the header. */
|
uint16_t vendor_type; /**< Vendor type for the header. */
|
||||||
size_t data_size; /**< Size of Sdo data. */
|
size_t data_size; /**< Size of VoE data. */
|
||||||
ec_direction_t dir; /**< Direction. EC_DIR_OUTPUT means writing to
|
ec_direction_t dir; /**< Direction. EC_DIR_OUTPUT means writing to
|
||||||
the slave, EC_DIR_INPUT means reading from the
|
the slave, EC_DIR_INPUT means reading from the
|
||||||
slave. */
|
slave. */
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ string CommandConfig::helpString() const
|
||||||
<< "| hexadecimal)." << endl
|
<< "| hexadecimal)." << endl
|
||||||
<< "\\- Alias address and relative position (both decimal)." << endl
|
<< "\\- Alias address and relative position (both decimal)." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "With the --verbose option given, the configured Pdos and" << endl
|
<< "With the --verbose option given, the configured PDOs and" << endl
|
||||||
<< "Sdos are output in addition." << endl
|
<< "SDOs are output in addition." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Configuration selection:" << endl
|
<< "Configuration selection:" << endl
|
||||||
<< " Slave configurations can be selected with" << endl
|
<< " Slave configurations can be selected with" << endl
|
||||||
|
|
@ -138,13 +138,13 @@ void CommandConfig::showDetailedConfigs(
|
||||||
for (k = 0; k < configIter->syncs[j].pdo_count; k++) {
|
for (k = 0; k < configIter->syncs[j].pdo_count; k++) {
|
||||||
m.getConfigPdo(&pdo, configIter->config_index, j, k);
|
m.getConfigPdo(&pdo, configIter->config_index, j, k);
|
||||||
|
|
||||||
cout << " Pdo 0x" << hex << setw(4) << pdo.index << endl;
|
cout << " PDO 0x" << hex << setw(4) << pdo.index << endl;
|
||||||
|
|
||||||
for (l = 0; l < pdo.entry_count; l++) {
|
for (l = 0; l < pdo.entry_count; l++) {
|
||||||
m.getConfigPdoEntry(&entry,
|
m.getConfigPdoEntry(&entry,
|
||||||
configIter->config_index, j, k, l);
|
configIter->config_index, j, k, l);
|
||||||
|
|
||||||
cout << " Pdo entry 0x" << hex << setfill('0')
|
cout << " PDO entry 0x" << hex << setfill('0')
|
||||||
<< setw(4) << entry.index << ":"
|
<< setw(4) << entry.index << ":"
|
||||||
<< setw(2) << (unsigned int) entry.subindex
|
<< setw(2) << (unsigned int) entry.subindex
|
||||||
<< ", " << dec << setfill(' ')
|
<< ", " << dec << setfill(' ')
|
||||||
|
|
@ -155,7 +155,7 @@ void CommandConfig::showDetailedConfigs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Sdo configuration:" << endl;
|
cout << "SDO configuration:" << endl;
|
||||||
if (configIter->sdo_count) {
|
if (configIter->sdo_count) {
|
||||||
for (j = 0; j < configIter->sdo_count; j++) {
|
for (j = 0; j < configIter->sdo_count; j++) {
|
||||||
m.getConfigSdo(&sdo, configIter->config_index, j);
|
m.getConfigSdo(&sdo, configIter->config_index, j);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ string CommandDomains::helpString() const
|
||||||
<< "(LRD/LWR/LRW) is displayed followed by the domain's" << endl
|
<< "(LRD/LWR/LRW) is displayed followed by the domain's" << endl
|
||||||
<< "process data size in byte. The last values are the current" << endl
|
<< "process data size in byte. The last values are the current" << endl
|
||||||
<< "datagram working counter sum and the expected working" << endl
|
<< "datagram working counter sum and the expected working" << endl
|
||||||
<< "counter sum. If the values are equal, all Pdos were" << endl
|
<< "counter sum. If the values are equal, all PDOs were" << endl
|
||||||
<< "exchanged during the last cycle." << endl
|
<< "exchanged during the last cycle." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "If the --verbose option is given, the participating slave" << endl
|
<< "If the --verbose option is given, the participating slave" << endl
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandDownload::CommandDownload():
|
CommandDownload::CommandDownload():
|
||||||
SdoCommand("download", "Write an Sdo entry to a slave.")
|
SdoCommand("download", "Write an SDO entry to a slave.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,28 +29,28 @@ string CommandDownload::helpString() const
|
||||||
<< endl
|
<< endl
|
||||||
<< "This command requires a single slave to be selected." << endl
|
<< "This command requires a single slave to be selected." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "The data type of the Sdo entry is taken from the Sdo" << endl
|
<< "The data type of the SDO entry is taken from the SDO" << endl
|
||||||
<< "dictionary by default. It can be overridden with the" << endl
|
<< "dictionary by default. It can be overridden with the" << endl
|
||||||
<< "--type option. If the slave does not support the Sdo" << endl
|
<< "--type option. If the slave does not support the SDO" << endl
|
||||||
<< "information service or the Sdo is not in the dictionary," << endl
|
<< "information service or the SDO is not in the dictionary," << endl
|
||||||
<< "the --type option is mandatory." << endl
|
<< "the --type option is mandatory." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "These are the valid Sdo entry data types:" << endl
|
<< "These are the valid SDO entry data types:" << endl
|
||||||
<< " int8, int16, int32, uint8, uint16, uint32, string." << endl
|
<< " int8, int16, int32, uint8, uint16, uint32, string." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Arguments:" << endl
|
<< "Arguments:" << endl
|
||||||
<< " INDEX is the Sdo index and must be an unsigned" << endl
|
<< " INDEX is the SDO index and must be an unsigned" << endl
|
||||||
<< " 16 bit number." << endl
|
<< " 16 bit number." << endl
|
||||||
<< " SUBINDEX is the Sdo entry subindex and must be an" << endl
|
<< " SUBINDEX is the SDO entry subindex and must be an" << endl
|
||||||
<< " unsigned 8 bit number." << endl
|
<< " unsigned 8 bit number." << endl
|
||||||
<< " VALUE is the value to download and must correspond" << endl
|
<< " VALUE is the value to download and must correspond" << endl
|
||||||
<< " to the Sdo entry datatype (see above)." << endl
|
<< " to the SDO entry datatype (see above)." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Command-specific options:" << endl
|
<< "Command-specific options:" << endl
|
||||||
<< " --alias -a <alias>" << endl
|
<< " --alias -a <alias>" << endl
|
||||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||||
<< " the 'slaves' command." << endl
|
<< " the 'slaves' command." << endl
|
||||||
<< " --type -t <type> Sdo entry data type (see above)." << endl
|
<< " --type -t <type> SDO entry data type (see above)." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< numericInfo();
|
<< numericInfo();
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
||||||
>> resetiosflags(ios::basefield) // guess base from prefix
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
>> data.sdo_index;
|
>> data.sdo_index;
|
||||||
if (strIndex.fail()) {
|
if (strIndex.fail()) {
|
||||||
err << "Invalid Sdo index '" << args[0] << "'!";
|
err << "Invalid SDO index '" << args[0] << "'!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
||||||
>> resetiosflags(ios::basefield) // guess base from prefix
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
>> number;
|
>> number;
|
||||||
if (strSubIndex.fail() || number > 0xff) {
|
if (strSubIndex.fail() || number > 0xff) {
|
||||||
err << "Invalid Sdo subindex '" << args[1] << "'!";
|
err << "Invalid SDO subindex '" << args[1] << "'!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
data.sdo_entry_subindex = number;
|
data.sdo_entry_subindex = number;
|
||||||
|
|
@ -110,12 +110,12 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
||||||
m.getSdoEntry(&entry, data.slave_position,
|
m.getSdoEntry(&entry, data.slave_position,
|
||||||
data.sdo_index, data.sdo_entry_subindex);
|
data.sdo_index, data.sdo_entry_subindex);
|
||||||
} catch (MasterDeviceException &e) {
|
} catch (MasterDeviceException &e) {
|
||||||
err << "Failed to determine Sdo entry data type. "
|
err << "Failed to determine SDO entry data type. "
|
||||||
<< "Please specify --type.";
|
<< "Please specify --type.";
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
}
|
}
|
||||||
if (!(dataType = findDataType(entry.data_type))) {
|
if (!(dataType = findDataType(entry.data_type))) {
|
||||||
err << "Pdo entry has unknown data type 0x"
|
err << "PDO entry has unknown data type 0x"
|
||||||
<< hex << setfill('0') << setw(4) << entry.data_type << "!"
|
<< hex << setfill('0') << setw(4) << entry.data_type << "!"
|
||||||
<< " Please specify --type.";
|
<< " Please specify --type.";
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
|
|
@ -207,7 +207,7 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
||||||
m.sdoDownload(&data);
|
m.sdoDownload(&data);
|
||||||
} catch (MasterDeviceSdoAbortException &e) {
|
} catch (MasterDeviceSdoAbortException &e) {
|
||||||
delete [] data.data;
|
delete [] data.data;
|
||||||
err << "Sdo transfer aborted with code 0x"
|
err << "SDO transfer aborted with code 0x"
|
||||||
<< setfill('0') << hex << setw(8) << e.abortCode
|
<< setfill('0') << hex << setw(8) << e.abortCode
|
||||||
<< ": " << abortText(e.abortCode);
|
<< ": " << abortText(e.abortCode);
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandPdos::CommandPdos():
|
CommandPdos::CommandPdos():
|
||||||
Command("pdos", "List Sync managers, Pdo assignment and mapping.")
|
Command("pdos", "List Sync managers, PDO assignment and mapping.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,19 +37,19 @@ string CommandPdos::helpString() const
|
||||||
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, "
|
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, "
|
||||||
<< "Enable 1" << endl
|
<< "Enable 1" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "2) Assigned Pdos - Pdo direction, hexadecimal index and" << endl
|
<< "2) Assigned PDOs - PDO direction, hexadecimal index and" << endl
|
||||||
<< " the Pdo name, if avaliable. Note that a 'Tx' and 'Rx'" << endl
|
<< " the PDO name, if avaliable. Note that a 'Tx' and 'Rx'" << endl
|
||||||
<< " are seen from the slave's point of view. Example:" << endl
|
<< " are seen from the slave's point of view. Example:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " TxPdo 0x1a00 \"Channel1\"" << endl
|
<< " TxPDO 0x1a00 \"Channel1\"" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "3) Mapped Pdo entries - Pdo entry index and subindex (both" << endl
|
<< "3) Mapped PDO entries - PDO entry index and subindex (both" << endl
|
||||||
<< " hexadecimal), the length in bit and the description, if" << endl
|
<< " hexadecimal), the length in bit and the description, if" << endl
|
||||||
<< " available. Example:" << endl
|
<< " available. Example:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " Pdo entry 0x3101:01, 8 bit, \"Status\"" << endl
|
<< " PDO entry 0x3101:01, 8 bit, \"Status\"" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Note, that the displayed Pdo assignment and Pdo mapping" << endl
|
<< "Note, that the displayed PDO assignment and PDO mapping" << endl
|
||||||
<< "information can either originate from the SII or from the" << endl
|
<< "information can either originate from the SII or from the" << endl
|
||||||
<< "CoE communication area." << endl
|
<< "CoE communication area." << endl
|
||||||
<< endl
|
<< endl
|
||||||
|
|
@ -115,7 +115,7 @@ void CommandPdos::listSlavePdos(
|
||||||
m.getPdo(&pdo, slave.position, i, j);
|
m.getPdo(&pdo, slave.position, i, j);
|
||||||
|
|
||||||
cout << " " << (sync.control_register & 0x04 ? "R" : "T")
|
cout << " " << (sync.control_register & 0x04 ? "R" : "T")
|
||||||
<< "xPdo 0x"
|
<< "xPDO 0x"
|
||||||
<< hex << setfill('0')
|
<< hex << setfill('0')
|
||||||
<< setw(4) << pdo.index
|
<< setw(4) << pdo.index
|
||||||
<< " \"" << pdo.name << "\"" << endl;
|
<< " \"" << pdo.name << "\"" << endl;
|
||||||
|
|
@ -126,7 +126,7 @@ void CommandPdos::listSlavePdos(
|
||||||
for (k = 0; k < pdo.entry_count; k++) {
|
for (k = 0; k < pdo.entry_count; k++) {
|
||||||
m.getPdoEntry(&entry, slave.position, i, j, k);
|
m.getPdoEntry(&entry, slave.position, i, j, k);
|
||||||
|
|
||||||
cout << " Pdo entry 0x"
|
cout << " PDO entry 0x"
|
||||||
<< hex << setfill('0')
|
<< hex << setfill('0')
|
||||||
<< setw(4) << entry.index
|
<< setw(4) << entry.index
|
||||||
<< ":" << setw(2) << (unsigned int) entry.subindex
|
<< ":" << setw(2) << (unsigned int) entry.subindex
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandSdos::CommandSdos():
|
CommandSdos::CommandSdos():
|
||||||
SdoCommand("sdos", "List Sdo dictionaries.")
|
SdoCommand("sdos", "List SDO dictionaries.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,27 +27,27 @@ string CommandSdos::helpString() const
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Sdo dictionary information is displayed in two layers," << endl
|
<< "SDO dictionary information is displayed in two layers," << endl
|
||||||
<< "which are indented accordingly:" << endl
|
<< "which are indented accordingly:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "1) Sdos - Hexadecimal Sdo index and the name. Example:" << endl
|
<< "1) SDOs - Hexadecimal SDO index and the name. Example:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " Sdo 0x1018, \"Identity object\"" << endl
|
<< " SDO 0x1018, \"Identity object\"" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "2) Sdo entries - Sdo index and Sdo entry subindex (both" << endl
|
<< "2) SDO entries - SDO index and SDO entry subindex (both" << endl
|
||||||
<< " hexadecimal) followed by the data type, the length in" << endl
|
<< " hexadecimal) followed by the data type, the length in" << endl
|
||||||
<< " bit, and the description. Example:" << endl
|
<< " bit, and the description. Example:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " 0x1018:01, uint32, 32 bit, \"Vendor id\"" << endl
|
<< " 0x1018:01, uint32, 32 bit, \"Vendor id\"" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "If the --quiet option is given, only the Sdos are output."
|
<< "If the --quiet option is given, only the SDOs are output."
|
||||||
<< endl << endl
|
<< endl << endl
|
||||||
<< "Command-specific options:" << endl
|
<< "Command-specific options:" << endl
|
||||||
<< " --alias -a <alias>" << endl
|
<< " --alias -a <alias>" << endl
|
||||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||||
<< " the 'slaves' command." << endl
|
<< " the 'slaves' command." << endl
|
||||||
<< " --quiet -q Only output Sdos (without the" << endl
|
<< " --quiet -q Only output SDOs (without the" << endl
|
||||||
<< " Sdo entries)." << endl
|
<< " SDO entries)." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< numericInfo();
|
<< numericInfo();
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ void CommandSdos::listSlaveSdos(
|
||||||
for (i = 0; i < slave.sdo_count; i++) {
|
for (i = 0; i < slave.sdo_count; i++) {
|
||||||
m.getSdo(&sdo, slave.position, i);
|
m.getSdo(&sdo, slave.position, i);
|
||||||
|
|
||||||
cout << "Sdo 0x"
|
cout << "SDO 0x"
|
||||||
<< hex << setfill('0')
|
<< hex << setfill('0')
|
||||||
<< setw(4) << sdo.sdo_index
|
<< setw(4) << sdo.sdo_index
|
||||||
<< ", \"" << sdo.name << "\"" << endl;
|
<< ", \"" << sdo.name << "\"" << endl;
|
||||||
|
|
|
||||||
|
|
@ -261,20 +261,20 @@ void CommandSlaves::showSlaves(
|
||||||
|
|
||||||
if (si->mailbox_protocols & EC_MBOX_COE) {
|
if (si->mailbox_protocols & EC_MBOX_COE) {
|
||||||
cout << " CoE details:" << endl
|
cout << " CoE details:" << endl
|
||||||
<< " Enable Sdo: "
|
<< " Enable SDO: "
|
||||||
<< (si->coe_details.enable_sdo ? "yes" : "no") << endl
|
<< (si->coe_details.enable_sdo ? "yes" : "no") << endl
|
||||||
<< " Enable Sdo Info: "
|
<< " Enable SDO Info: "
|
||||||
<< (si->coe_details.enable_sdo_info ? "yes" : "no") << endl
|
<< (si->coe_details.enable_sdo_info ? "yes" : "no") << endl
|
||||||
<< " Enable Pdo Assign: "
|
<< " Enable PDO Assign: "
|
||||||
<< (si->coe_details.enable_pdo_assign
|
<< (si->coe_details.enable_pdo_assign
|
||||||
? "yes" : "no") << endl
|
? "yes" : "no") << endl
|
||||||
<< " Enable Pdo Configuration: "
|
<< " Enable PDO Configuration: "
|
||||||
<< (si->coe_details.enable_pdo_configuration
|
<< (si->coe_details.enable_pdo_configuration
|
||||||
? "yes" : "no") << endl
|
? "yes" : "no") << endl
|
||||||
<< " Enable Upload at startup: "
|
<< " Enable Upload at startup: "
|
||||||
<< (si->coe_details.enable_upload_at_startup
|
<< (si->coe_details.enable_upload_at_startup
|
||||||
? "yes" : "no") << endl
|
? "yes" : "no") << endl
|
||||||
<< " Enable Sdo complete access: "
|
<< " Enable SDO complete access: "
|
||||||
<< (si->coe_details.enable_sdo_complete_access
|
<< (si->coe_details.enable_sdo_complete_access
|
||||||
? "yes" : "no") << endl;
|
? "yes" : "no") << endl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
CommandUpload::CommandUpload():
|
CommandUpload::CommandUpload():
|
||||||
SdoCommand("upload", "Read an Sdo entry from a slave.")
|
SdoCommand("upload", "Read an SDO entry from a slave.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,26 +29,26 @@ string CommandUpload::helpString() const
|
||||||
<< endl
|
<< endl
|
||||||
<< "This command requires a single slave to be selected." << endl
|
<< "This command requires a single slave to be selected." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "The data type of the Sdo entry is taken from the Sdo" << endl
|
<< "The data type of the SDO entry is taken from the SDO" << endl
|
||||||
<< "dictionary by default. It can be overridden with the" << endl
|
<< "dictionary by default. It can be overridden with the" << endl
|
||||||
<< "--type option. If the slave does not support the Sdo" << endl
|
<< "--type option. If the slave does not support the SDO" << endl
|
||||||
<< "information service or the Sdo is not in the dictionary," << endl
|
<< "information service or the SDO is not in the dictionary," << endl
|
||||||
<< "the --type option is mandatory." << endl
|
<< "the --type option is mandatory." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "These are the valid Sdo entry data types:" << endl
|
<< "These are the valid SDO entry data types:" << endl
|
||||||
<< " int8, int16, int32, uint8, uint16, uint32, string." << endl
|
<< " int8, int16, int32, uint8, uint16, uint32, string." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Arguments:" << endl
|
<< "Arguments:" << endl
|
||||||
<< " INDEX is the Sdo index and must be an unsigned" << endl
|
<< " INDEX is the SDO index and must be an unsigned" << endl
|
||||||
<< " 16 bit number." << endl
|
<< " 16 bit number." << endl
|
||||||
<< " SUBINDEX is the Sdo entry subindex and must be an" << endl
|
<< " SUBINDEX is the SDO entry subindex and must be an" << endl
|
||||||
<< " unsigned 8 bit number." << endl
|
<< " unsigned 8 bit number." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Command-specific options:" << endl
|
<< "Command-specific options:" << endl
|
||||||
<< " --alias -a <alias>" << endl
|
<< " --alias -a <alias>" << endl
|
||||||
<< " --position -p <pos> Slave selection. See the help of" << endl
|
<< " --position -p <pos> Slave selection. See the help of" << endl
|
||||||
<< " the 'slaves' command." << endl
|
<< " the 'slaves' command." << endl
|
||||||
<< " --type -t <type> Sdo entry data type (see above)." << endl
|
<< " --type -t <type> SDO entry data type (see above)." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< numericInfo();
|
<< numericInfo();
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
||||||
>> resetiosflags(ios::basefield) // guess base from prefix
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
>> data.sdo_index;
|
>> data.sdo_index;
|
||||||
if (strIndex.fail()) {
|
if (strIndex.fail()) {
|
||||||
err << "Invalid Sdo index '" << args[0] << "'!";
|
err << "Invalid SDO index '" << args[0] << "'!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
||||||
>> resetiosflags(ios::basefield) // guess base from prefix
|
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||||
>> uval;
|
>> uval;
|
||||||
if (strSubIndex.fail() || uval > 0xff) {
|
if (strSubIndex.fail() || uval > 0xff) {
|
||||||
err << "Invalid Sdo subindex '" << args[1] << "'!";
|
err << "Invalid SDO subindex '" << args[1] << "'!";
|
||||||
throwInvalidUsageException(err);
|
throwInvalidUsageException(err);
|
||||||
}
|
}
|
||||||
data.sdo_entry_subindex = uval;
|
data.sdo_entry_subindex = uval;
|
||||||
|
|
@ -109,12 +109,12 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
||||||
m.getSdoEntry(&entry, data.slave_position,
|
m.getSdoEntry(&entry, data.slave_position,
|
||||||
data.sdo_index, data.sdo_entry_subindex);
|
data.sdo_index, data.sdo_entry_subindex);
|
||||||
} catch (MasterDeviceException &e) {
|
} catch (MasterDeviceException &e) {
|
||||||
err << "Failed to determine Sdo entry data type. "
|
err << "Failed to determine SDO entry data type. "
|
||||||
<< "Please specify --type.";
|
<< "Please specify --type.";
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
}
|
}
|
||||||
if (!(dataType = findDataType(entry.data_type))) {
|
if (!(dataType = findDataType(entry.data_type))) {
|
||||||
err << "Pdo entry has unknown data type 0x"
|
err << "PDO entry has unknown data type 0x"
|
||||||
<< hex << setfill('0') << setw(4) << entry.data_type << "!"
|
<< hex << setfill('0') << setw(4) << entry.data_type << "!"
|
||||||
<< " Please specify --type.";
|
<< " Please specify --type.";
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
|
|
@ -133,7 +133,7 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
||||||
m.sdoUpload(&data);
|
m.sdoUpload(&data);
|
||||||
} catch (MasterDeviceSdoAbortException &e) {
|
} catch (MasterDeviceSdoAbortException &e) {
|
||||||
delete [] data.target;
|
delete [] data.target;
|
||||||
err << "Sdo transfer aborted with code 0x"
|
err << "SDO transfer aborted with code 0x"
|
||||||
<< setfill('0') << hex << setw(8) << e.abortCode
|
<< setfill('0') << hex << setw(8) << e.abortCode
|
||||||
<< ": " << abortText(e.abortCode);
|
<< ": " << abortText(e.abortCode);
|
||||||
throwCommandException(err);
|
throwCommandException(err);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ string CommandXml::helpString() const
|
||||||
<< endl
|
<< endl
|
||||||
<< getBriefDescription() << endl
|
<< getBriefDescription() << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Note that the Pdo information can either originate" << endl
|
<< "Note that the PDO information can either originate" << endl
|
||||||
<< "from the SII or from the CoE communication area. For" << endl
|
<< "from the SII or from the CoE communication area. For" << endl
|
||||||
<< "slaves, that support configuring Pdo assignment and" << endl
|
<< "slaves, that support configuring PDO assignment and" << endl
|
||||||
<< "mapping, the output depends on the last configuration." << endl
|
<< "mapping, the output depends on the last configuration." << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< "Command-specific options:" << endl
|
<< "Command-specific options:" << endl
|
||||||
|
|
@ -111,7 +111,7 @@ void CommandXml::generateSlaveXml(
|
||||||
for (j = 0; j < sync.pdo_count; j++) {
|
for (j = 0; j < sync.pdo_count; j++) {
|
||||||
m.getPdo(&pdo, slave.position, i, j);
|
m.getPdo(&pdo, slave.position, i, j);
|
||||||
pdoType = (sync.control_register & 0x04 ? "R" : "T");
|
pdoType = (sync.control_register & 0x04 ? "R" : "T");
|
||||||
pdoType += "xPdo";
|
pdoType += "xPdo"; // last 2 letters lowercase in XML!
|
||||||
|
|
||||||
cout
|
cout
|
||||||
<< " <" << pdoType
|
<< " <" << pdoType
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ void MasterDevice::getConfigPdo(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_CONFIG_PDO, data) < 0) {
|
if (ioctl(fd, EC_IOCTL_CONFIG_PDO, data) < 0) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get slave config Pdo: " << strerror(errno);
|
err << "Failed to get slave config PDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ void MasterDevice::getConfigPdoEntry(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_CONFIG_PDO_ENTRY, data) < 0) {
|
if (ioctl(fd, EC_IOCTL_CONFIG_PDO_ENTRY, data) < 0) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get slave config Pdo entry: " << strerror(errno);
|
err << "Failed to get slave config PDO entry: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,7 +147,7 @@ void MasterDevice::getConfigSdo(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_CONFIG_SDO, data) < 0) {
|
if (ioctl(fd, EC_IOCTL_CONFIG_SDO, data) < 0) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get slave config Sdo: " << strerror(errno);
|
err << "Failed to get slave config SDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +253,7 @@ void MasterDevice::getPdo(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO, pdo)) {
|
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO, pdo)) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get Pdo: " << strerror(errno);
|
err << "Failed to get PDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +275,7 @@ void MasterDevice::getPdoEntry(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO_ENTRY, entry)) {
|
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO_ENTRY, entry)) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get Pdo entry: " << strerror(errno);
|
err << "Failed to get PDO entry: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,7 @@ void MasterDevice::getSdo(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_SLAVE_SDO, sdo)) {
|
if (ioctl(fd, EC_IOCTL_SLAVE_SDO, sdo)) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get Sdo: " << strerror(errno);
|
err << "Failed to get SDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -313,7 +313,7 @@ void MasterDevice::getSdoEntry(
|
||||||
|
|
||||||
if (ioctl(fd, EC_IOCTL_SLAVE_SDO_ENTRY, entry)) {
|
if (ioctl(fd, EC_IOCTL_SLAVE_SDO_ENTRY, entry)) {
|
||||||
stringstream err;
|
stringstream err;
|
||||||
err << "Failed to get Sdo entry: " << strerror(errno);
|
err << "Failed to get SDO entry: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -390,7 +390,7 @@ void MasterDevice::sdoDownload(ec_ioctl_slave_sdo_download_t *data)
|
||||||
if (errno == EIO && data->abort_code) {
|
if (errno == EIO && data->abort_code) {
|
||||||
throw MasterDeviceSdoAbortException(data->abort_code);
|
throw MasterDeviceSdoAbortException(data->abort_code);
|
||||||
} else {
|
} else {
|
||||||
err << "Failed to download Sdo: " << strerror(errno);
|
err << "Failed to download SDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -405,7 +405,7 @@ void MasterDevice::sdoUpload(ec_ioctl_slave_sdo_upload_t *data)
|
||||||
if (errno == EIO && data->abort_code) {
|
if (errno == EIO && data->abort_code) {
|
||||||
throw MasterDeviceSdoAbortException(data->abort_code);
|
throw MasterDeviceSdoAbortException(data->abort_code);
|
||||||
} else {
|
} else {
|
||||||
err << "Failed to upload Sdo: " << strerror(errno);
|
err << "Failed to upload SDO: " << strerror(errno);
|
||||||
throw MasterDeviceException(err);
|
throw MasterDeviceException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class MasterDeviceSdoAbortException:
|
||||||
protected:
|
protected:
|
||||||
/** Constructor with stringstream parameter. */
|
/** Constructor with stringstream parameter. */
|
||||||
MasterDeviceSdoAbortException(uint32_t code):
|
MasterDeviceSdoAbortException(uint32_t code):
|
||||||
MasterDeviceException("Sdo transfer aborted.") {
|
MasterDeviceException("SDO transfer aborted.") {
|
||||||
abortCode = code;
|
abortCode = code;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -70,24 +70,24 @@ const SdoCommand::DataType SdoCommand::dataTypes[] = {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Sdo abort messages.
|
/** SDO abort messages.
|
||||||
*
|
*
|
||||||
* The "Abort Sdo transfer request" supplies an abort code, which can be
|
* The "Abort SDO transfer request" supplies an abort code, which can be
|
||||||
* translated to clear text. This table does the mapping of the codes and
|
* translated to clear text. This table does the mapping of the codes and
|
||||||
* messages.
|
* messages.
|
||||||
*/
|
*/
|
||||||
const SdoCommand::AbortMessage SdoCommand::abortMessages[] = {
|
const SdoCommand::AbortMessage SdoCommand::abortMessages[] = {
|
||||||
{0x05030000, "Toggle bit not changed"},
|
{0x05030000, "Toggle bit not changed"},
|
||||||
{0x05040000, "Sdo protocol timeout"},
|
{0x05040000, "SDO protocol timeout"},
|
||||||
{0x05040001, "Client/Server command specifier not valid or unknown"},
|
{0x05040001, "Client/Server command specifier not valid or unknown"},
|
||||||
{0x05040005, "Out of memory"},
|
{0x05040005, "Out of memory"},
|
||||||
{0x06010000, "Unsupported access to an object"},
|
{0x06010000, "Unsupported access to an object"},
|
||||||
{0x06010001, "Attempt to read a write-only object"},
|
{0x06010001, "Attempt to read a write-only object"},
|
||||||
{0x06010002, "Attempt to write a read-only object"},
|
{0x06010002, "Attempt to write a read-only object"},
|
||||||
{0x06020000, "This object does not exist in the object directory"},
|
{0x06020000, "This object does not exist in the object directory"},
|
||||||
{0x06040041, "The object cannot be mapped into the Pdo"},
|
{0x06040041, "The object cannot be mapped into the PDO"},
|
||||||
{0x06040042, "The number and length of the objects to be mapped would"
|
{0x06040042, "The number and length of the objects to be mapped would"
|
||||||
" exceed the Pdo length"},
|
" exceed the PDO length"},
|
||||||
{0x06040043, "General parameter incompatibility reason"},
|
{0x06040043, "General parameter incompatibility reason"},
|
||||||
{0x06040047, "Gerneral internal incompatibility in device"},
|
{0x06040047, "Gerneral internal incompatibility in device"},
|
||||||
{0x06060000, "Access failure due to a hardware error"},
|
{0x06060000, "Access failure due to a hardware error"},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue