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
//
// 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.
//
// Contributed by: William Greer ([email protected]) and Sam Justice ([email protected])
//

#![deny(missing_docs)]
#![deny(warnings)]

//!
//! This library allows users to define and start communication services within their hardware services.
//!
//! # Example Usage
//!
//! ```rust,no_run
//! use comms_service::*;
//! use std::net::{Ipv4Addr, UdpSocket};
//! use std::sync::{Arc, Mutex};
//!
//! // Example setup.
//! fn read(socket: &Arc<UdpSocket>) -> CommsResult<Vec<u8>> { Ok(vec![]) }
//! fn write(socket: &Arc<UdpSocket>, data: &[u8]) -> CommsResult<()> { Ok(()) }
//!
//! # fn func() -> CommsResult<()> {
//! // Defining connections.
//! let read_conn = Arc::new(UdpSocket::bind(("192.168.8.1", 13000)).unwrap());
//! let write_conn = Arc::new(UdpSocket::bind(("192.168.8.1", 13001)).unwrap());
//!
//! // Fetching communications settings from the common config.toml file.
//! let service_config = kubos_system::Config::new("service-name");
//! let comms_config = CommsConfig::new(service_config)?;
//!
//! // Putting everything into the control block.
//! let controls = CommsControlBlock::new(
//!     Some(Arc::new(read)),
//!     vec![Arc::new(write)],
//!     read_conn,
//!     write_conn,
//!     comms_config
//! )?;
//!
//! // Get telemetry from communication service.
//! let telem = Arc::new(Mutex::new(CommsTelemetry::default()));
//!
//! // Start communication service.
//! CommsService::start::<Arc<UdpSocket>, SpacePacket>(controls, &telem);
//! # Ok(())
//! # }
//! ```
//!
//! ## Comms Service Config File Format
//!
//! ```toml
//! [service-name.comms]
//! max_num_handlers = 50
//! downlink_ports = [13011]
//! timeout = 1500"
//! ip = "192.168.8.2"
//! ```

#[macro_use]
extern crate juniper;

#[macro_use]
extern crate log;

extern crate byteorder;
extern crate failure;

mod config;
mod errors;
mod packet;
mod service;
mod spacepacket;
mod telemetry;

#[cfg(test)]
mod tests;

/// Communication Service library.
pub use crate::service::*;

/// Communication Service errors.
pub use crate::errors::*;

/// Communication Service telemetry.
pub use crate::telemetry::CommsTelemetry;

/// Communication Service configuration parsing.
pub use crate::config::*;

pub use packet::LinkPacket;
pub use packet::PayloadType;
pub use spacepacket::SpacePacket;