Crate comms_service
source · [−]Expand description
This library allows users to define and start communication services within their hardware services.
Example Usage
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(()) }
// 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);
Comms Service Config File Format
[service-name.comms]
max_num_handlers = 50
downlink_ports = [13011]
timeout = 1500"
ip = "192.168.8.2"
Structs
A struct that holds useful configuration options to use in a comms-service
implementation.
Created by parsing a configuration file in the toml
file format.
Struct that holds configuration data to allow users to set up a Communication Service.
Struct that enables users to start the Communication Service.
Generic telemetry collected by the communication service.
Structure used to implement SpacePacket version of LinkPacket
Enums
This enum defines all errors that can occur within the comms-service
.
Enum representing the different payload types handled by the communications service
Constants
Default maximum number of message handlers
Default message handler timeout
Traits
Generic LinkPacket trait which defines the internal packet requirements of the communications service.
Type Definitions
Result returned by the comms-service
.
Type definition for a “read” function pointer.
Type definition for a “write” function pointer.