Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
b1f4ddf2
Commit
b1f4ddf2
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Implemented ecrt_slave_config_state(); minor changes in
ec_master_state_t and ec_slave_config_state_t; adapted example.
parent
99717b00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
TODO
+0
-2
0 additions, 2 deletions
TODO
examples/mini/mini.c
+43
-13
43 additions, 13 deletions
examples/mini/mini.c
include/ecrt.h
+18
-17
18 additions, 17 deletions
include/ecrt.h
master/master.c
+1
-1
1 addition, 1 deletion
master/master.c
master/slave_config.c
+17
-0
17 additions, 0 deletions
master/slave_config.c
with
79 additions
and
33 deletions
TODO
+
0
−
2
View file @
b1f4ddf2
...
...
@@ -8,8 +8,6 @@ $Id$
Version 1.4.0:
* Supply new ec_master_state_t.
* Implement ecrt_slave_config_state().
* Remove get_cycles() calls and references to cpu_khz to increase
portability.
* Make ecrt_master_slave_config() return no error when slave is not present
...
...
This diff is collapsed.
Click to expand it.
examples/mini/mini.c
+
43
−
13
View file @
b1f4ddf2
...
...
@@ -60,6 +60,9 @@ spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
static
ec_domain_t
*
domain1
=
NULL
;
static
ec_domain_state_t
domain1_state
=
{};
static
ec_slave_config_t
*
sc_ana_in
=
NULL
;
static
ec_slave_config_state_t
sc_ana_in_state
=
{};
static
struct
timer_list
timer
;
static
unsigned
int
counter
=
0
;
...
...
@@ -128,14 +131,14 @@ void check_domain1_state(void)
{
ec_domain_state_t
ds
;
spin_lock
(
&
master_lock
);
ecrt_domain_state
(
domain1
,
&
ds
);
if
(
ds
.
working_counter
!=
domain1_state
.
working_counter
)
printk
(
KERN_INFO
PFX
"domain1 working_counter changed to %u.
\n
"
,
ds
.
working_counter
);
spin_unlock
(
&
master_lock
);
if
(
ds
.
working_counter
!=
domain1_state
.
working_counter
)
printk
(
KERN_INFO
PFX
"Domain1: WC %u.
\n
"
,
ds
.
working_counter
);
if
(
ds
.
wc_state
!=
domain1_state
.
wc_state
)
printk
(
KERN_INFO
PFX
"domain1 wc_state changed to %u.
\n
"
,
ds
.
wc_state
);
printk
(
KERN_INFO
PFX
"Domain1: State %u.
\n
"
,
ds
.
wc_state
);
domain1_state
=
ds
;
}
...
...
@@ -150,16 +153,39 @@ void check_master_state(void)
ecrt_master_state
(
master
,
&
ms
);
spin_unlock
(
&
master_lock
);
if
(
ms
.
slaves_responding
!=
master_state
.
slaves_responding
)
{
printk
(
KERN_INFO
PFX
"slaves_responding changed to %u.
\n
"
,
ms
.
slaves_responding
);
}
if
(
ms
.
slaves_responding
!=
master_state
.
slaves_responding
)
printk
(
KERN_INFO
PFX
"%u slave(s).
\n
"
,
ms
.
slaves_responding
);
if
(
ms
.
al_states
!=
master_state
.
al_states
)
printk
(
KERN_INFO
PFX
"AL states: 0x%02X.
\n
"
,
ms
.
al_states
);
if
(
ms
.
link_up
!=
master_state
.
link_up
)
printk
(
KERN_INFO
PFX
"Link is %s.
\n
"
,
ms
.
link_up
?
"up"
:
"down"
);
master_state
=
ms
;
}
/*****************************************************************************/
void
check_slave_config_states
(
void
)
{
ec_slave_config_state_t
s
;
spin_lock
(
&
master_lock
);
ecrt_slave_config_state
(
sc_ana_in
,
&
s
);
spin_unlock
(
&
master_lock
);
if
(
s
.
al_state
!=
sc_ana_in_state
.
al_state
)
printk
(
KERN_INFO
PFX
"AnaIn: State 0x%02X.
\n
"
,
s
.
al_state
);
if
(
s
.
online
!=
sc_ana_in_state
.
online
)
printk
(
KERN_INFO
PFX
"AnaIn: %s.
\n
"
,
s
.
online
?
"online"
:
"offline"
);
if
(
s
.
operational
!=
sc_ana_in_state
.
operational
)
printk
(
KERN_INFO
PFX
"AnaIn: %soperational.
\n
"
,
s
.
operational
?
""
:
"Not "
);
sc_ana_in_state
=
s
;
}
/*****************************************************************************/
#ifdef SDO_ACCESS
void
read_sdo
(
void
)
{
...
...
@@ -207,6 +233,9 @@ void cyclic_task(unsigned long data)
// check for master state (optional)
check_master_state
();
// check for islave configuration state(s) (optional)
check_slave_config_states
();
#ifdef SDO_ACCESS
// read process data Sdo
...
...
@@ -269,14 +298,15 @@ int __init init_mini_module(void)
goto
out_release_master
;
}
#ifdef CONFIGURE_PDOS
printk
(
KERN_INFO
PFX
"Configuring Pdos...
\n
"
);
if
(
!
(
sc
=
ecrt_master_slave_config
(
master
,
0
,
1
,
Beckhoff_EL3162
)))
{
if
(
!
(
sc_ana_in
=
ecrt_master_slave_config
(
master
,
0
,
1
,
Beckhoff_EL3162
)))
{
printk
(
KERN_ERR
PFX
"Failed to get slave configuration.
\n
"
);
goto
out_release_master
;
}
if
(
ecrt_slave_config_pdos
(
sc
,
EC_END
,
el3162_pdos
))
{
#ifdef CONFIGURE_PDOS
printk
(
KERN_INFO
PFX
"Configuring Pdos...
\n
"
);
if
(
ecrt_slave_config_pdos
(
sc_ana_in
,
EC_END
,
el3162_pdos
))
{
printk
(
KERN_ERR
PFX
"Failed to configure Pdos.
\n
"
);
goto
out_release_master
;
}
...
...
This diff is collapsed.
Click to expand it.
include/ecrt.h
+
18
−
17
View file @
b1f4ddf2
...
...
@@ -157,15 +157,16 @@ typedef struct ec_sdo_request ec_sdo_request_t; /**< \see ec_sdo_request. */
*/
typedef
struct
{
unsigned
int
slaves_responding
;
/**< Number of slaves in the bus. */
uint8_t
slave_states
;
/**< Application-layer states of all slaves.
The states are coded in the lower 4 bits. If a bit
is set, it means that at least one slave in the
bus is in the corresponding state:
- Bit 0: \a INIT
- Bit 1: \a PREOP
- Bit 2: \a SAFEOP
- Bit 3: \a OP */
uint8_t
link_up
;
/**< \a true, if the network link is up. */
unsigned
int
al_states
:
4
;
/**< Application-layer states of all slaves.
The states are coded in the lower 4 bits.
If a bit is set, it means that at least one
slave in the bus is in the corresponding
state:
- Bit 0: \a INIT
- Bit 1: \a PREOP
- Bit 2: \a SAFEOP
- Bit 3: \a OP */
unsigned
int
link_up
:
1
;
/**< \a true, if the network link is up. */
}
ec_master_state_t
;
/*****************************************************************************/
...
...
@@ -177,17 +178,17 @@ typedef struct {
* \see ecrt_slave_config_state().
*/
typedef
struct
{
uint8_t
slave_state
;
/**< The application-layer state of the slave.
- 1: \a INIT
- 2: \a PREOP
- 4: \a SAFEOP
- 8: \a OP
Note that each state is coded in a different
bit! */
unsigned
int
online
:
1
;
/**< The slave is online. */
unsigned
int
operational
:
1
;
/**< The slave was brought into \a OP state
using the specified configuration. */
unsigned
int
al_state
:
4
;
/**< The application-layer state of the slave.
- 1: \a INIT
- 2: \a PREOP
- 4: \a SAFEOP
- 8: \a OP
Note that each state is coded in a different
bit! */
}
ec_slave_config_state_t
;
/*****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
master/master.c
+
1
−
1
View file @
b1f4ddf2
...
...
@@ -1372,7 +1372,7 @@ void ecrt_master_callbacks(ec_master_t *master, int (*request_cb)(void *),
void
ecrt_master_state
(
const
ec_master_t
*
master
,
ec_master_state_t
*
state
)
{
state
->
slaves_responding
=
master
->
fsm
.
slaves_responding
;
state
->
slave
_states
=
master
->
fsm
.
slave_states
;
state
->
al
_states
=
master
->
fsm
.
slave_states
;
state
->
link_up
=
master
->
main_device
.
link_state
;
}
...
...
This diff is collapsed.
Click to expand it.
master/slave_config.c
+
17
−
0
View file @
b1f4ddf2
...
...
@@ -618,6 +618,22 @@ ec_sdo_request_t *ecrt_slave_config_create_sdo_request(ec_slave_config_t *sc,
/*****************************************************************************/
void
ecrt_slave_config_state
(
const
ec_slave_config_t
*
sc
,
ec_slave_config_state_t
*
state
)
{
state
->
online
=
sc
->
slave
?
1
:
0
;
if
(
state
->
online
)
{
state
->
operational
=
sc
->
slave
->
current_state
==
EC_SLAVE_STATE_OP
;
state
->
al_state
=
sc
->
slave
->
current_state
;
}
else
{
state
->
operational
=
0
;
state
->
al_state
=
EC_SLAVE_STATE_UNKNOWN
;
}
}
/*****************************************************************************/
/** \cond */
EXPORT_SYMBOL
(
ecrt_slave_config_pdo_assign_add
);
...
...
@@ -631,6 +647,7 @@ EXPORT_SYMBOL(ecrt_slave_config_sdo8);
EXPORT_SYMBOL
(
ecrt_slave_config_sdo16
);
EXPORT_SYMBOL
(
ecrt_slave_config_sdo32
);
EXPORT_SYMBOL
(
ecrt_slave_config_create_sdo_request
);
EXPORT_SYMBOL
(
ecrt_slave_config_state
);
/** \endcond */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment