@@ -19,7 +19,7 @@ import (
1919
2020type E810Opts struct {
2121 EnableDefaultConfig bool `json:"enableDefaultConfig"`
22- UblxCmds [] E810UblxCmds `json:"ublxCmds"`
22+ UblxCmds UblxCmdList `json:"ublxCmds"`
2323 DevicePins map [string ]map [string ]string `json:"pins"`
2424 DpllSettings map [string ]uint64 `json:"settings"`
2525 PhaseOffsetPins map [string ]map [string ]string `json:"phaseOffsetPins"`
5757echo "Disabled all SMA and U.FL Connections"
5858`
5959
60- var unitTest bool
61- var clockChain = & ClockChain {}
60+ var (
61+ unitTest bool
62+ clockChain = & ClockChain {}
63+ )
6264
6365// For mocking DPLL pin info
6466var DpllPins = []* dpll_netlink.PinInfo {}
6567
66- func getDefaultUblxCmds () []E810UblxCmds {
67- // Ublx command to output NAV-CLOCK every second
68- cfgMsgNavClock := E810UblxCmds {
69- ReportOutput : false ,
70- Args : []string {"-p" , "CFG-MSG,1,34,1" },
71- }
72- // Ublx command to output NAV-STATUS every second
73- cfgMsgNavStatus := E810UblxCmds {
74- ReportOutput : false ,
75- Args : []string {"-p" , "CFG-MSG,1,3,1" },
76- }
77-
78- // Ublx command to disable SA messages
79- cfgMsgDisableSA := E810UblxCmds {
80- ReportOutput : false ,
81- Args : []string {"-p" , "CFG-MSG,0xf0,0x02,0" },
82- }
83- // Ublx command to disable SV messages
84- cfgMsgDisableSV := E810UblxCmds {
85- ReportOutput : false ,
86- Args : []string {"-p" , "CFG-MSG,0xf0,0x03,0" },
87- }
88- // Ublx command to disable VTG messages
89- cfgMsgDisableVTG := E810UblxCmds {
90- ReportOutput : false ,
91- Args : []string {"-z" , "CFG-MSGOUT-NMEA_ID_VTG_I2C,0" },
92- }
93- // Ublx command to disable GST messages
94- cfgMsgDisableGST := E810UblxCmds {
95- ReportOutput : false ,
96- Args : []string {"-z" , "CFG-MSGOUT-NMEA_ID_GST_I2C,0" },
97- }
98- // Ublx command to disable ZDA messages
99- cfgMsgDisableZDA := E810UblxCmds {
100- ReportOutput : false ,
101- Args : []string {"-z" , "CFG-MSGOUT-NMEA_ID_ZDA_I2C,0" },
102- }
103- // Ublx command to disable GBS messages
104- cfgMsgDisableGBS := E810UblxCmds {
105- ReportOutput : false ,
106- Args : []string {"-z" , "CFG-MSGOUT-NMEA_ID_GBS_I2C,0" },
107- }
108- // Ublx command to save configuration to storage
109- cfgSave := E810UblxCmds {
110- ReportOutput : false ,
111- Args : []string {"-p" , "SAVE" },
112- }
113- return []E810UblxCmds {cfgMsgNavClock , cfgMsgNavStatus , cfgMsgDisableSA , cfgMsgDisableSV ,
114- cfgMsgDisableVTG , cfgMsgDisableGST , cfgMsgDisableZDA , cfgMsgDisableGBS , cfgSave }
115- }
116-
11768func OnPTPConfigChangeE810 (data * interface {}, nodeProfile * ptpv1.PtpProfile ) error {
11869 glog .Info ("calling onPTPConfigChange for e810 plugin" )
11970 var e810Opts E810Opts
@@ -159,7 +110,7 @@ func OnPTPConfigChangeE810(data *interface{}, nodeProfile *ptpv1.PtpProfile) err
159110 for _ , phc := range phcs {
160111 pinPath = fmt .Sprintf ("/sys/class/net/%s/device/ptp/%s/pins/%s" , device , phc .Name (), pin )
161112 glog .Infof ("echo %s > %s" , value , pinPath )
162- err = os .WriteFile (pinPath , []byte (value ), 0666 )
113+ err = os .WriteFile (pinPath , []byte (value ), 0o666 )
163114 if err != nil {
164115 glog .Error ("e810 failed to write " + value + " to " + pinPath + ": " + err .Error ())
165116 }
@@ -211,11 +162,11 @@ func OnPTPConfigChangeE810(data *interface{}, nodeProfile *ptpv1.PtpProfile) err
211162}
212163
213164func AfterRunPTPCommandE810 (data * interface {}, nodeProfile * ptpv1.PtpProfile , command string ) error {
165+ pluginData := (* data ).(* E810PluginData )
214166 glog .Info ("calling AfterRunPTPCommandE810 for e810 plugin" )
215167 var e810Opts E810Opts
216168 var err error
217169 var optsByteArray []byte
218- var stdout []byte
219170
220171 e810Opts .EnableDefaultConfig = false
221172
@@ -229,22 +180,10 @@ func AfterRunPTPCommandE810(data *interface{}, nodeProfile *ptpv1.PtpProfile, co
229180 switch command {
230181 case "gpspipe" :
231182 glog .Infof ("AfterRunPTPCommandE810 doing ublx config for command: %s" , command )
232- for _ , ublxOpt := range append (e810Opts .UblxCmds , getDefaultUblxCmds ()... ) {
233- ublxArgs := ublxOpt .Args
234- glog .Infof ("Running /usr/bin/ubxtool with args %s" , strings .Join (ublxArgs , ", " ))
235- stdout , _ = exec .Command ("/usr/local/bin/ubxtool" , ublxArgs ... ).CombinedOutput ()
236- //stdout, err = exec.Command("/usr/local/bin/ubxtool", "-p", "STATUS").CombinedOutput()
237- if data != nil && ublxOpt .ReportOutput {
238- _data := * data
239- glog .Infof ("Saving status to hwconfig: %s" , string (stdout ))
240- var pluginData = _data .(* E810PluginData )
241- _pluginData := * pluginData
242- statusString := fmt .Sprintf ("ublx data: %s" , string (stdout ))
243- * _pluginData .hwplugins = append (* _pluginData .hwplugins , statusString )
244- } else {
245- glog .Infof ("Not saving status to hwconfig: %s" , string (stdout ))
246- }
247- }
183+ // Execute user-supplied UblxCmds first:
184+ * pluginData .hwplugins = append (* pluginData .hwplugins , e810Opts .UblxCmds .runAll ()... )
185+ // Finish with the default commands:
186+ * pluginData .hwplugins = append (* pluginData .hwplugins , defaultUblxCmds ().runAll ()... )
248187 case "tbc-ho-exit" :
249188 _ , err = clockChain .EnterNormalTBC ()
250189 if err != nil {
@@ -277,7 +216,7 @@ func PopulateHwConfigE810(data *interface{}, hwconfigs *[]ptpv1.HwConfig) error
277216 //*hwconfigs = append(*hwconfigs, hwConfig)
278217 if data != nil {
279218 _data := * data
280- var pluginData = _data .(* E810PluginData )
219+ pluginData : = _data .(* E810PluginData )
281220 _pluginData := * pluginData
282221 if _pluginData .hwplugins != nil {
283222 for _ , _hwconfig := range * _pluginData .hwplugins {
@@ -299,7 +238,8 @@ func E810(name string) (*plugin.Plugin, *interface{}) {
299238 glog .Infof ("registering e810 plugin" )
300239 hwplugins := []string {}
301240 pluginData := E810PluginData {hwplugins : & hwplugins }
302- _plugin := plugin.Plugin {Name : "e810" ,
241+ _plugin := plugin.Plugin {
242+ Name : "e810" ,
303243 OnPTPConfigChange : OnPTPConfigChangeE810 ,
304244 AfterRunPTPCommand : AfterRunPTPCommandE810 ,
305245 PopulateHwConfig : PopulateHwConfigE810 ,
0 commit comments