@@ -95,18 +95,20 @@ namespace splitter {
95
95
// 02: 1=tracking sats, 0=no sats
96
96
// 01: 1=antenna OK, 0=antenna fault
97
97
98
+ int pps_offset = (std::int8_t )data[1 ];
99
+
98
100
if (!(data[0 ] & 0x10 )) {
99
101
// 12MHz mode
100
- write_status_file (" red" , " Not in GPS timestamp mode" );
102
+ write_status_file (" red" , " Not in GPS timestamp mode" , pps_offset );
101
103
return ;
102
104
}
103
105
104
106
if (!(data[2 ] & 0x80 )) {
105
107
// Old style message. Assume it's good if abs(degradation) < 45ms
106
- if (data[ 1 ] <= 3 || data[ 1 ] >= ( 256 - 3 ) ) {
107
- write_status_file (" green" , " Receiver synchronized to GPS time" );
108
+ if (pps_offset <= 3 || pps_offset >= - 3 ) {
109
+ write_status_file (" green" , " Receiver synchronized to GPS time" , pps_offset );
108
110
} else {
109
- write_status_file (" amber" , " Receiver more than 45ns from GPS time" );
111
+ write_status_file (" amber" , " Receiver more than 45ns from GPS time" , pps_offset );
110
112
}
111
113
return ;
112
114
}
@@ -116,9 +118,9 @@ namespace splitter {
116
118
if (!(data[2 ] & 0x20 )) {
117
119
// FPGA is using GPS time
118
120
if (data[2 ] & 0x10 ) {
119
- write_status_file (" green" , " Receiver synchronized to GPS time" );
121
+ write_status_file (" green" , " Receiver synchronized to GPS time" , pps_offset );
120
122
} else {
121
- write_status_file (" amber" , " Receiver more than 45ns from GPS time" );
123
+ write_status_file (" amber" , " Receiver more than 45ns from GPS time" , pps_offset );
122
124
}
123
125
return ;
124
126
}
@@ -151,10 +153,10 @@ namespace splitter {
151
153
status_buffer << *i;
152
154
}
153
155
154
- write_status_file (" red" , status_buffer.str ());
156
+ write_status_file (" red" , status_buffer.str (), pps_offset );
155
157
}
156
158
157
- void StatusWriter::write_status_file (const std::string &gps_color, const std::string &gps_message) {
159
+ void StatusWriter::write_status_file (const std::string &gps_color, const std::string &gps_message, int pps_offset ) {
158
160
// This is simple enough we don't bother with a JSON library.
159
161
// NB: we assume that the status messages do not need escaping.
160
162
@@ -169,14 +171,26 @@ namespace splitter {
169
171
std::string radio_color = (input->is_connected () ? " green" : " red" );
170
172
std::string radio_message = (input->is_connected () ? " Connected to receiver" : " Not connected to receiver" );
171
173
172
- outf << " \" radio\" : {" << std::endl << " \" status\" : \" " << (input->is_connected () ? " green" : " red" ) << " \" ," << std::endl << " \" message\" : \" " << (input->is_connected () ? " Connected to receiver" : " Not connected to receiver" ) << " \" " << std::endl << " }," << std::endl;
174
+ outf << " \" radio\" : {" << std::endl;
175
+ outf << " \" status\" : \" " << (input->is_connected () ? " green" : " red" ) << " \" ," << std::endl;
176
+ outf << " \" message\" : \" " << (input->is_connected () ? " Connected to receiver" : " Not connected to receiver" ) << " \" " << std::endl;
177
+ outf << " }," << std::endl;
173
178
}
174
179
175
180
if (!gps_color.empty ()) {
176
- outf << " \" gps\" : {" << std::endl << " \" status\" : \" " << gps_color << " \" ," << std::endl << " \" message\" : \" " << gps_message << " \" " << std::endl << " }," << std::endl;
181
+ outf << " \" gps\" : {" << std::endl;
182
+ outf << " \" status\" : \" " << gps_color << " \" ," << std::endl;
183
+ if (pps_offset != -9999 ) {
184
+ outf << " \" pps_offset\" : " << pps_offset << " ," << std::endl;
185
+ }
186
+ outf << " \" message\" : \" " << gps_message << " \" " << std::endl;
187
+ outf << " }," << std::endl;
177
188
}
178
189
179
- outf << " \" time\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(now - unix_epoch).count () << " ," << std::endl << " \" expiry\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(expiry - unix_epoch).count () << " ," << std::endl << " \" interval\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(timeout_interval).count () << std::endl << " }" << std::endl;
190
+ outf << " \" time\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(now - unix_epoch).count () << " ," << std::endl;
191
+ outf << " \" expiry\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(expiry - unix_epoch).count () << " ," << std::endl;
192
+ outf << " \" interval\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(timeout_interval).count () << std::endl;
193
+ outf << " }" << std::endl;
180
194
outf.close ();
181
195
182
196
if (outf) {
0 commit comments