Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
02b8a028
Commit
02b8a028
authored
Mar 06, 2023
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sim: revive it
parent
b8864944
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
main-loop.c
arch-sim/main-loop.c
+13
-1
sim-startup.c
arch-sim/sim-startup.c
+10
-0
sim-time.c
time-sim/sim-time.c
+8
-2
No files found.
arch-sim/main-loop.c
View file @
02b8a028
...
...
@@ -36,6 +36,17 @@ static int run_all_state_machines(struct pp_globals *ppg)
delay_ms
=
delay_ms_j
;
}
/* BMCA must run at least once per announce interval 9.2.6.8 */
if
(
pp_gtimeout
(
ppg
,
PP_TO_BMC
))
{
bmc_calculate_ebest
(
ppg
);
/* Calculate erbest, ebest,... */
pp_gtimeout_reset
(
ppg
,
PP_TO_BMC
);
delay_ms
=
0
;
}
else
{
/* check if the BMC timeout is the next to run */
int
delay_bmca
=
pp_gnext_delay_1
(
ppg
,
PP_TO_BMC
);
if
(
delay_bmca
<
delay_ms
)
delay_ms
=
delay_bmca
;
}
return
delay_ms
;
}
...
...
@@ -52,7 +63,8 @@ void sim_main_loop(struct pp_globals *ppg)
ppi
=
INST
(
ppg
,
j
);
ppi
->
is_new_state
=
1
;
/* just tell that the links are up */
ppi
->
link_up
=
TRUE
;
ppi
->
state
=
PPS_INITIALIZING
;
ppi
->
link_up
=
TRUE
;
}
delay_ns
=
run_all_state_machines
(
ppg
)
*
1000LL
*
1000LL
;
...
...
arch-sim/sim-startup.c
View file @
02b8a028
...
...
@@ -57,6 +57,9 @@ int sim_set_global_DS(struct pp_instance *ppi)
static
int
sim_ppi_init
(
struct
pp_instance
*
ppi
,
int
which_ppi
)
{
struct
sim_ppi_arch_data
*
data
;
memcpy
(
&
ppi
->
cfg
,
&
__pp_default_instance_cfg
,
sizeof
(
__pp_default_instance_cfg
));
ppi
->
proto
=
PP_DEFAULT_PROTO
;
ppi
->
__tx_buffer
=
malloc
(
PP_MAX_FRAME_LENGTH
);
ppi
->
__rx_buffer
=
malloc
(
PP_MAX_FRAME_LENGTH
);
...
...
@@ -107,6 +110,9 @@ int main(int argc, char **argv)
ppi
=
INST
(
ppg
,
i
);
ppi
->
glbs
=
ppg
;
// must be done before using sim_set_global_DS
ppi
->
vlans_array_len
=
CONFIG_VLAN_ARRAY_SIZE
;
ppi
->
servo
=
calloc
(
1
,
sizeof
(
struct
pp_servo
));
if
(
ppi
->
servo
==
NULL
)
return
-
1
;
if
(
sim_ppi_init
(
ppi
,
i
))
return
-
1
;
}
...
...
@@ -122,6 +128,7 @@ int main(int argc, char **argv)
* to set the initial offset for the slave
*/
sim_set_global_DS
(
pp_sim_get_master
(
ppg
));
pp_config_string
(
ppg
,
strdup
(
"port SIM_MASTER; iface MASTER;"
"proto udp;"
"sim_iter_max 10000;"
...
...
@@ -151,6 +158,9 @@ int main(int argc, char **argv)
ppi
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
ppi
->
n_ops
=
&
DEFAULT_NET_OPS
;
ppi
->
portDS
->
logAnnounceInterval
=
PP_DEFAULT_ANNOUNCE_INTERVAL
;
if
(
pp_sim_is_master
(
ppi
))
pp_init_globals
(
ppg
,
&
sim_master_rt_opts
);
else
...
...
time-sim/sim-time.c
View file @
02b8a028
...
...
@@ -61,10 +61,10 @@ static int sim_time_get_utc_offset(struct pp_instance *ppi, int *offset, int *le
*
leap59
=
0
;
*
leap61
=
0
;
*
offset
=
0
;
return
-
1
;
return
-
1
;
}
static
int
sim_time_set_utc_offset
(
struct
pp_instance
*
ppi
,
int
offset
,
int
leap59
,
int
leap61
)
static
int
sim_time_set_utc_offset
(
struct
pp_instance
*
ppi
,
int
offset
,
int
leap59
,
int
leap61
)
{
/* no UTC offset */
return
-
1
;
...
...
@@ -144,6 +144,11 @@ static unsigned long sim_calc_timeout(struct pp_instance *ppi, int millisec)
return
millisec
+
SIM_PPI_ARCH
(
ppi
)
->
time
.
current_ns
/
1000LL
/
1000LL
;
}
static
int
sim_enable_timing_output
(
struct
pp_globals
*
ppg
,
int
enable
)
{
return
0
;
}
const
struct
pp_time_operations
sim_time_ops
=
{
.
get_utc_time
=
sim_time_get_utc_time
,
.
get_utc_offset
=
sim_time_get_utc_offset
,
...
...
@@ -156,4 +161,5 @@ const struct pp_time_operations sim_time_ops = {
.
adjust_freq
=
sim_adjust_freq
,
.
init_servo
=
sim_init_servo
,
.
calc_timeout
=
sim_calc_timeout
,
.
enable_timing_output
=
sim_enable_timing_output
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment