1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
// // Copyright (C) 2018 Kubos Corporation // // Licensed under the Apache License, Version 2.0 (the "License") // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #![deny(missing_docs)] #![deny(warnings)] //! Kubos Service for interacting with a [NovAtel OEM6 High Precision GNSS Receiver](https://www.novatel.com/products/gnss-receivers/oem-receiver-boards/oem6-receivers/) //! //! # Configuration //! //! The service can be configured in the `/home/system/etc/config.toml` with the following fields: //! //! - `bus` - Specifies the UART bus the OEM6 is connected to //! - `ip` - Specifies the service's IP address //! - `port` - Specifies the port on which the service will be listening for UDP packets //! //! For example: //! //! ```toml //! [novatel-oem6-service] //! bus = "/dev/ttyS4" //! //! [novatel-oem6-service.addr] //! ip = "127.0.0.1" //! port = 8082 //! ``` //! //! # Starting the Service //! //! The service should be started automatically by its init script, but may also be started manually: //! //! ```toml //! $ novatel-oem6-service //! Kubos OEM6 service started //! Listening on: 10.63.1.20:8082 //! ``` //! //! # Queries //! //! ## Ping //! //! Test query to verify service is running without attempting //! to communicate with the underlying subsystem //! //! ```json //! { //! ping: "pong" //! } //! ``` //! //! ## ACK //! //! Get the last run mutation //! //! ```json //! { //! ack: AckCommand //! } //! ``` //! //! ## Errors //! //! Get all errors encountered since the last time this field was queried //! //! ```json //! { //! errors: [String] //! } //! ``` //! //! ## Power Status //! //! Get the current power state of the system //! //! Note: `uptime` is included as an available field in order to conform to //! the Kubos Service Outline, but cannot be implemented for this device, //! so the value will be 1 if the device is on and 0 if the device is off //! //! ```json //! { //! power { //! state: PowerState, //! uptime: Int //! } //! } //! ``` //! //! ## Configuration //! //! Get the current configuration of the system //! //! Stretch goal: implement the LOGLIST command //! //! ```json //! { //! config: "Not Implemented" //! } //! ``` //! //! ## Test Results //! //! Get the test results of the last run test //! //! ```json //! { //! testResults{ //! success, //! telemetryNominal{...}, //! telemetryDebug{...} //! } //! } //! ``` //! //! ## System Status //! //! Get the current system status and errors //! //! ```json //! { //! systemStatus { //! errors: Vec<String>, //! status: Vec<String> //! } //! } //! ``` //! //! ## Lock Status //! //! Get current status of position information gathering //! //! ```json //! { //! lockStatus { //! positionStatus: SolutionStatus, //! positionType: PosVelType, //! time { //! ms: Int, //! week: Int //! }, //! timeStatus: RefTimeStatus, //! velocityStatus: SolutionStatus, //! velocityType: PosVelType //! } //! } //! ``` //! //! ## Lock Information //! //! Get the last known good position information //! //! ```json //! { //! lockInfo { //! position: Vec<Float>, //! time { //! ms: Int, //! week: Int //! }, //! velocity: Vec<Float> //! } //! } //! ``` //! //! ## Telemetry //! //! Get current telemetry information for the system //! //! ```json //! { //! telemetry{ //! debug { //! components: [{ //! bootVersion: String, //! compType: Int, //! compileDate: String, //! compileTime: String, //! hwVersion: String, //! model: String, //! serialNum: String, //! swVersion: String, //! }], //! numComponents: Int //! }, //! nominal{ //! lockInfo {...}, //! lockStatus {...}, //! systemStatus: Vec<String> //! } //! } //! } //! ``` //! //! # Mutations //! //! ## Errors //! //! Get all errors encountered while processing this GraphQL request //! //! Note: This will only return errors thrown by fields which have //! already been processed, so it is recommended that this field be specified last. //! //! ```json //! mutation { //! errors: [String] //! } //! ``` //! //! ## No-Op //! //! Execute a trivial command against the system //! //! ```json //! mutation { //! noop { //! errors: String, //! success: Boolean //! } //! } //! ``` //! //! ## Set Power State //! //! Control the power state of the system //! //! Note: Power control of the GPS device will be done by the GPSRM service //! //! ```json //! mutation { //! controlPower: "Not Implemented" //! } //! ``` //! //! ## Configuration //! //! Configure the system //! //! - config: Vector of configuration requests (ConfigStruct) //! - option: Configuration operation which should be performed //! - hold: For `LOG_*` requests, specifies whether this request should be excluded //! from removal by future 'UNLOG_ALL' requests. //! For `UNLOG_ALL` requests, specifies whether the 'hold' value in previous //! `LOG_*` requests should be ignored. //! - interval: Interval at which log messages should be generated. //! Note: Only applies to `LOG_POSITION_DATA` requests. Ignored otherwise //! - offset: Offset of interval at which log messages should be generated. //! Note: Only applies to `LOG_POSITION_DATA` requests. Ignored otherwise //! //! ```json //! mutation { //! configureHardware(config: [{option: ConfigOption, hold: Boolean, interval: Float, offset: Float},...]) { //! config: String //! errors: String, //! success: Boolean, //! } //! } //! ``` //! //! ## System Self-Test //! //! Run a system self-test //! //! - test: Type of self-test to perform //! //! ```json //! mutation { //! testHardware(test: TestType) { //! ... on IntegrationTestResults { //! errors: String, //! success: Boolean, //! telemetryNominal{...}, //! telemetryDebug{...} //! } //! ... on HardwareTestResults { //! errors: "Not Implemented", //! success: true, //! data: Empty //! } //! } //! } //! ``` //! //! ## Passthrough //! //! Pass a custom command through to the system //! //! - command: String containing the hex values to be sent (ex. "C3") //! It will be converted to a byte array before transfer. //! //! ```json //! mutation { //! issueRawCommand(command: String) { //! errors: String, //! success: Boolean, //! response: String //! } //! } //! ``` //! #![recursion_limit = "256"] extern crate failure; #[macro_use] extern crate juniper; #[macro_use] extern crate kubos_service; #[macro_use] extern crate log; extern crate novatel_oem6_api; #[cfg(test)] #[macro_use] extern crate serde_json; extern crate syslog; mod model; mod objects; mod schema; #[cfg(test)] mod tests; use kubos_service::{Config, Service}; use model::{LockData, Subsystem}; use novatel_oem6_api::OEMResult; pub use objects::*; use schema::{MutationRoot, QueryRoot}; use std::sync::Arc; use syslog::Facility; fn main() -> OEMResult<()> { syslog::init( Facility::LOG_DAEMON, log::LevelFilter::Debug, Some("novatel-oem6-service"), ).unwrap(); let config = Config::new("novatel-oem6-service"); let bus = config .get("bus") .expect("No 'bus' value found in 'novatel-oem6-service' section of config"); let bus = bus.as_str().unwrap(); let subsystem = Subsystem::new(bus, Arc::new(LockData::new()))?; Service::new(config, subsystem, QueryRoot, MutationRoot).start(); Ok(()) }