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
3019ecc7
Commit
3019ecc7
authored
18 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Introduced idle flag in master state machine.
parent
4b625e9f
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
NEWS
+2
-0
2 additions, 0 deletions
NEWS
TODO
+0
-1
0 additions, 1 deletion
TODO
master/fsm_master.c
+28
-5
28 additions, 5 deletions
master/fsm_master.c
master/fsm_master.h
+3
-1
3 additions, 1 deletion
master/fsm_master.h
master/master.c
+14
-4
14 additions, 4 deletions
master/master.c
with
47 additions
and
11 deletions
NEWS
+
2
−
0
View file @
3019ecc7
...
...
@@ -37,6 +37,8 @@ Changes in version 1.3.0:
* Implemented setting of secondary slave address (alias) via sysfs.
* Implemented SDO reading in operation mode via sysfs.
* Removed annoying eeprom_write_enable file. EEPROM writing always enabled.
* Master state machine scheduled with timeout if idle, otherwise is executed
as fast as possible (with schedule()).
* Removed EtherCAT line comments from 8139too drivers.
-------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
TODO
+
0
−
1
View file @
3019ecc7
...
...
@@ -26,7 +26,6 @@ $Id$
- Evaluate EEPROM contents after writing.
- SDO dictionary fetching in operation mode.
- SDO write access in sysfs.
- Speed up IDLE state machine through fast mode with schedule().
- Configure slave ports to automatically open on link detection.
- Calculate cycle time of operation state machine.
...
...
This diff is collapsed.
Click to expand it.
master/fsm_master.c
+
28
−
5
View file @
3019ecc7
...
...
@@ -74,6 +74,7 @@ void ec_fsm_master_init(ec_fsm_master_t *fsm, /**< master state machine */
fsm
->
master
=
master
;
fsm
->
datagram
=
datagram
;
fsm
->
state
=
ec_fsm_master_state_start
;
fsm
->
idle
=
0
;
fsm
->
slaves_responding
=
0
;
fsm
->
topology_change_pending
=
0
;
fsm
->
slave_states
=
EC_SLAVE_STATE_UNKNOWN
;
...
...
@@ -126,15 +127,30 @@ int ec_fsm_master_exec(ec_fsm_master_t *fsm /**< master state machine */)
/*****************************************************************************/
/**
\return false, if state machine has terminated
*/
*
\return false, if state machine has terminated
*/
int
ec_fsm_master_running
(
ec_fsm_master_t
*
fsm
/**< master state machine */
)
int
ec_fsm_master_running
(
const
ec_fsm_master_t
*
fsm
/**< master state machine */
)
{
return
fsm
->
state
!=
ec_fsm_master_state_end
&&
fsm
->
state
!=
ec_fsm_master_state_error
;
}
/*****************************************************************************/
/**
* \return true, if the state machine is in an idle phase
*/
int
ec_fsm_master_idle
(
const
ec_fsm_master_t
*
fsm
/**< master state machine */
)
{
return
fsm
->
idle
;
}
/******************************************************************************
* master state machine
*****************************************************************************/
...
...
@@ -146,6 +162,7 @@ int ec_fsm_master_running(ec_fsm_master_t *fsm /**< master state machine */)
void
ec_fsm_master_state_start
(
ec_fsm_master_t
*
fsm
)
{
fsm
->
idle
=
1
;
ec_datagram_brd
(
fsm
->
datagram
,
0x0130
,
2
);
fsm
->
state
=
ec_fsm_master_state_broadcast
;
}
...
...
@@ -167,8 +184,7 @@ void ec_fsm_master_state_broadcast(ec_fsm_master_t *fsm /**< master state machin
if
(
datagram
->
state
==
EC_DATAGRAM_TIMED_OUT
)
return
;
// always retry
if
(
datagram
->
state
!=
EC_DATAGRAM_RECEIVED
)
{
// EC_DATAGRAM_ERROR
// link is down
if
(
datagram
->
state
!=
EC_DATAGRAM_RECEIVED
)
{
// link is down
fsm
->
slaves_responding
=
0
;
list_for_each_entry
(
slave
,
&
master
->
slaves
,
list
)
{
ec_slave_set_online_state
(
slave
,
EC_SLAVE_OFFLINE
);
...
...
@@ -210,6 +226,7 @@ void ec_fsm_master_state_broadcast(ec_fsm_master_t *fsm /**< master state machin
master
->
mode
==
EC_MASTER_MODE_IDLE
)
{
fsm
->
topology_change_pending
=
0
;
fsm
->
tainted
=
0
;
fsm
->
idle
=
0
;
ec_master_eoe_stop
(
master
);
ec_master_destroy_slaves
(
master
);
...
...
@@ -359,6 +376,7 @@ int ec_fsm_master_action_process_sdo(
slave
->
ring_position
);
// start uploading SDO
fsm
->
idle
=
0
;
fsm
->
slave
=
slave
;
fsm
->
sdo_request
=
request
;
fsm
->
state
=
ec_fsm_master_state_sdo_request
;
...
...
@@ -406,6 +424,7 @@ void ec_fsm_master_action_process_states(ec_fsm_master_t *fsm
}
}
fsm
->
idle
=
0
;
fsm
->
slave
=
slave
;
fsm
->
state
=
ec_fsm_master_state_configure_slave
;
ec_fsm_slave_start_conf
(
&
fsm
->
fsm_slave
,
slave
);
...
...
@@ -439,6 +458,7 @@ void ec_fsm_master_action_process_states(ec_fsm_master_t *fsm
slave
->
sdo_dictionary_fetched
=
1
;
// start fetching SDO dictionary
fsm
->
idle
=
0
;
fsm
->
slave
=
slave
;
fsm
->
state
=
ec_fsm_master_state_sdodict
;
ec_fsm_coe_dictionary
(
&
fsm
->
fsm_coe
,
slave
);
...
...
@@ -469,6 +489,7 @@ void ec_fsm_master_action_next_slave_state(ec_fsm_master_t *fsm
// is there another slave to query?
if
(
slave
->
list
.
next
!=
&
master
->
slaves
)
{
// process next slave
fsm
->
idle
=
1
;
fsm
->
slave
=
list_entry
(
slave
->
list
.
next
,
ec_slave_t
,
list
);
ec_datagram_nprd
(
fsm
->
datagram
,
fsm
->
slave
->
station_address
,
0x0130
,
2
);
...
...
@@ -487,6 +508,7 @@ void ec_fsm_master_action_next_slave_state(ec_fsm_master_t *fsm
// At least one slave is offline. validate!
EC_INFO
(
"Validating bus.
\n
"
);
fsm
->
idle
=
0
;
fsm
->
slave
=
list_entry
(
master
->
slaves
.
next
,
ec_slave_t
,
list
);
fsm
->
state
=
ec_fsm_master_state_validate_vendor
;
ec_fsm_sii_read
(
&
fsm
->
fsm_sii
,
slave
,
0x0008
,
EC_FSM_SII_POSITION
);
...
...
@@ -533,6 +555,7 @@ void ec_fsm_master_state_read_states(ec_fsm_master_t *fsm /**< master state mach
// check, if new slave state has to be acknowledged
if
(
slave
->
current_state
&
EC_SLAVE_STATE_ACK_ERR
&&
!
slave
->
error_flag
)
{
fsm
->
idle
=
0
;
fsm
->
state
=
ec_fsm_master_state_acknowledge
;
ec_fsm_change_ack
(
&
fsm
->
fsm_change
,
slave
);
ec_fsm_change_exec
(
&
fsm
->
fsm_change
);
...
...
This diff is collapsed.
Click to expand it.
master/fsm_master.h
+
3
−
1
View file @
3019ecc7
...
...
@@ -81,6 +81,7 @@ struct ec_fsm_master
unsigned
int
retries
;
/**< retries on datagram timeout. */
void
(
*
state
)(
ec_fsm_master_t
*
);
/**< master state function */
int
idle
;
/**< state machine is in idle phase */
unsigned
int
slaves_responding
;
/**< number of responding slaves */
unsigned
int
topology_change_pending
;
/**< bus topology changed */
ec_slave_state_t
slave_states
;
/**< states of responding slaves */
...
...
@@ -104,7 +105,8 @@ void ec_fsm_master_init(ec_fsm_master_t *, ec_master_t *, ec_datagram_t *);
void
ec_fsm_master_clear
(
ec_fsm_master_t
*
);
int
ec_fsm_master_exec
(
ec_fsm_master_t
*
);
int
ec_fsm_master_running
(
ec_fsm_master_t
*
);
int
ec_fsm_master_running
(
const
ec_fsm_master_t
*
);
int
ec_fsm_master_idle
(
const
ec_fsm_master_t
*
);
/*****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
master/master.c
+
14
−
4
View file @
3019ecc7
...
...
@@ -836,8 +836,13 @@ static int ec_master_idle_thread(ec_master_t *master)
master
->
idle_cycle_time_pos
++
;
master
->
idle_cycle_time_pos
%=
HZ
;
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
1
);
if
(
ec_fsm_master_idle
(
&
master
->
fsm
))
{
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
1
);
}
else
{
schedule
();
}
}
master
->
thread_id
=
0
;
...
...
@@ -883,8 +888,13 @@ static int ec_master_operation_thread(ec_master_t *master)
master
->
idle_cycle_time_pos
%=
HZ
;
schedule:
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
1
);
if
(
ec_fsm_master_idle
(
&
master
->
fsm
))
{
set_current_state
(
TASK_INTERRUPTIBLE
);
schedule_timeout
(
1
);
}
else
{
schedule
();
}
}
master
->
thread_id
=
0
;
...
...
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