[−][src]Crate comms_service
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
CommsConfig | A struct that holds useful configuration options to use in a |
CommsControlBlock | Struct that holds configuration data to allow users to set up a Communication Service. |
CommsService | Struct that enables users to start the Communication Service. |
CommsTelemetry | Generic telemetry collected by the communication service. |
SpacePacket | Structure used to implement SpacePacket version of LinkPacket |
Enums
CommsServiceError | This enum defines all errors that can occur within the |
PayloadType | Enum representing the different payload types handled by the communications service |
Constants
DEFAULT_MAX_HANDLERS | Default maximum number of message handlers |
DEFAULT_TIMEOUT | Default message handler timeout |
Traits
LinkPacket | Generic LinkPacket trait which defines the internal packet requirements of the communications service. |
Type Definitions
CommsResult | Result returned by the |
ReadFn | Type definition for a "read" function pointer. |
WriteFn | Type definition for a "write" function pointer. |