Expand description
A general purpose library for interacting with phd2.
PHD2 is telescope guiding software that simplifies the process of tracking a guide star, letting you concentrate on other aspects of deep-sky imaging or spectroscopy. For more information on phd2 see the project’s website here.
The purpose of this crate is to provide a convinent way to interact with phd2 using the using the EventMonitoring protocol. Details on the protocol can be found here.
Simple usage.
The simpliest way to use this crate is to convert a TcpStream to a Phd2Connection to send commands and receive events.
Example
use phd2::{serialization::Event, Phd2Connection};
#[tokio::main]
async fn main() {
let mut phd2: Phd2Connection<_>= tokio::net::TcpStream::connect("localhost:4400")
.await
.expect("Connecting to phd2")
.into();
let mut pixel_scale = phd2.get_pixel_scale().await.expect("Getting pixel scale.");
let mut sub = phd2.subscribe().await;
while let Ok(event) = sub.recv().await {
if let Event::GuideStep(guide) = &event.event {
let delta = pixel_scale * (guide.dx.powi(2) + guide.dy.powi(2)).sqrt();
println!("guide event: {} arcsec.", delta);
}
if let Event::ConfigurationChange(_) = &event.event {
pixel_scale = phd2.get_pixel_scale().await.expect("Getting pixel scale.");
}
}
}