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 33eec38 commit 77fe1a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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
3 changes: 3 additions & 0 deletions docs/precompiled/man/statime.toml.5
Original file line number Diff line number Diff line change
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 @@ -190,6 +192,10 @@ fn default_sdo_id() -> u16 {
0x000
}

fn default_slave_only() -> bool {
false
}

fn default_announce_interval() -> i8 {
1
}
Expand Down Expand Up @@ -281,6 +287,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 77fe1a2

Please sign in to comment.