Skip to content

Commit

Permalink
set device name (#306)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #306

Applying patches provided by Calnex team (Fraser).
This diff will set the device name visible in UI.
Works with both - old and new FW versons

Reviewed By: deathowl

Differential Revision: D50500249

fbshipit-source-id: 578d24c8ef7649e39ed0848e26908fa1cdfc1bc5
  • Loading branch information
leoleovich authored and facebook-github-bot committed Oct 20, 2023
1 parent 4986917 commit baa1eec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions calnex/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ func (c *config) measureConfig(s *ini.Section, mc map[api.Channel]MeasureConfig)
}
}

func (c *config) baseConfig(measure *ini.Section, gnss *ini.Section, antennaDelayNS int) {
func (c *config) baseConfig(measure *ini.Section, gnss *ini.Section, target string, antennaDelayNS int) {
// device hostname
c.set(measure, "device_name", target)

// gnss antenna compensation
c.set(gnss, "antenna_delay", fmt.Sprintf("%d ns", antennaDelayNS))

Expand Down Expand Up @@ -196,7 +199,7 @@ func Config(target string, insecureTLS bool, cc *CalnexConfig, apply bool) error
g := f.Section("gnss")

// set base config
c.baseConfig(m, g, cc.AntennaDelayNS)
c.baseConfig(m, g, target, cc.AntennaDelayNS)

// set measure config
c.measureConfig(m, cc.Measure)
Expand Down
5 changes: 4 additions & 1 deletion calnex/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ reference=Internal
meas_time=1 days 1 hours
tie_mode=TIE + 1 PPS Alignment
ch8\used=Yes
device_name=leoleovich.com
ch6\synce_enabled=Off
ch7\synce_enabled=Off
ch6\ptp_synce\ptp\dscp=0
Expand All @@ -106,7 +107,7 @@ ch6\virtual_channels_enabled=On
s := f.Section("measure")
g := f.Section("gnss")

c.baseConfig(s, g, 42)
c.baseConfig(s, g, "leoleovich.com", 42)
require.True(t, c.changed)

buf, err := api.ToBuffer(f)
Expand Down Expand Up @@ -418,6 +419,7 @@ func TestConfig(t *testing.T) {
expectedConfig := `[gnss]
antenna_delay=42 ns
[measure]
device_name=%s
continuous=On
reference=Internal
meas_time=1 days 1 hours
Expand Down Expand Up @@ -588,6 +590,7 @@ ch30\ptp_synce\ptp\domain=0
parsed, _ := url.Parse(ts.URL)
calnexAPI := api.NewAPI(parsed.Host, true)
calnexAPI.Client = ts.Client()
expectedConfig = fmt.Sprintf(expectedConfig, parsed.Host)

cc := &CalnexConfig{
AntennaDelayNS: 42,
Expand Down

0 comments on commit baa1eec

Please sign in to comment.