[−][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(controls, &telem);
Comms Service Config File Format
[service-name.comms]
handler_port_min = 13002
handler_port_max = 13010
downlink_ports = [13011]
ground-port = 9001
timeout = 1500
ground-ip = "192.168.8.1"
satellite-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. |
Enums
CommsServiceError |
This enum defines all errors that can occur within the |
Constants
DEFAULT_HANDLER_END |
Default message handler ending port |
DEFAULT_HANDLER_START |
Default message handler starting port |
DEFAULT_TIMEOUT |
Default message handler timeout |
Statics
DEFAULT_GROUND_IP |
Default ground gateway IP address |
DEFAULT_SATELLITE_IP |
Default satellite IP address |
Type Definitions
CommsResult |
Result returned by the |
ReadFn |
Type definition for a "read" function pointer. |
WriteFn |
Type definition for a "write" function pointer. |