Skip to content

Commit

Permalink
Add the slave-only instance configuration option to statime-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rnijveld committed Feb 6, 2025
1 parent cf40195 commit 4e12eb4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/man/statime.toml.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ will be indicated by each configuration setting shown.
`sdo-id` = *u12* (**0**)
: The "source domain identity" of this PTP instance. Together with the `domain` it identifies a domain.

`slave-only` = *bool* (**false**)
: Forbids this instance to ever become a master on any port.

`priority1` = *priority* (**128**)
: A tie breaker for the best master clock algorithm in the range `0..256`. `0` being the highest priority and `255` the lowest.

Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled/man/statime.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.5
.\" Automatically generated by Pandoc 3.4
.\"
.TH "STATIME" "8" "" "statime 0.2.2" "statime"
.SH NAME
Expand Down
5 changes: 4 additions & 1 deletion docs/precompiled/man/statime.toml.5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.5
.\" Automatically generated by Pandoc 3.4
.\"
.TH "STATIME.TOML" "5" "" "statime 0.2.2" "statime"
.SH NAME
Expand Down Expand Up @@ -33,6 +33,9 @@ domain.
The \[lq]source domain identity\[rq] of this PTP instance.
Together with the \f[CR]domain\f[R] it identifies a domain.
.TP
\f[CR]slave\-only\f[R] = \f[I]bool\f[R] (\f[B]false\f[R])
Forbids this instance to ever become a master on any port.
.TP
\f[CR]priority1\f[R] = \f[I]priority\f[R] (\f[B]128\f[R])
A tie breaker for the best master clock algorithm in the range
\f[CR]0..256\f[R].
Expand Down
7 changes: 7 additions & 0 deletions statime-linux/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct Config {
pub sdo_id: u16,
#[serde(default = "default_domain")]
pub domain: u8,
#[serde(default = "default_slave_only")]
pub slave_only: bool,
#[serde(default, deserialize_with = "deserialize_clock_identity")]
pub identity: Option<ClockIdentity>,
#[serde(default = "default_priority1")]
Expand Down Expand Up @@ -205,6 +207,10 @@ fn default_sdo_id() -> u16 {
0x000
}

fn default_slave_only() -> bool {
false
}

fn default_announce_interval() -> i8 {
1
}
Expand Down Expand Up @@ -302,6 +308,7 @@ interface = "enp0s31f6"
loglevel: LogLevel::Info,
sdo_id: 0x000,
domain: 0,
slave_only: false,
identity: None,
priority1: 128,
priority2: 128,
Expand Down
2 changes: 1 addition & 1 deletion statime-linux/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ async fn actual_main() {
priority_1: config.priority1,
priority_2: config.priority2,
domain_number: config.domain,
slave_only: false,
slave_only: config.slave_only,
sdo_id: SdoId::try_from(config.sdo_id).expect("sdo-id should be between 0 and 4095"),
path_trace: config.path_trace,
};
Expand Down

0 comments on commit 4e12eb4

Please sign in to comment.