Skip to main content

Crate nexstar_rust

Crate nexstar_rust 

Source
Expand description

§nexstar_rust

docs.rs crates.io

Rust helpers for the Celestron NexStar handset serial protocol: build command frames and parse #-terminated responses.

This crate is a Rust port of the Dart/Flutter NexStar protocol library spin7ion/nexstar_flutter (command builders and response parsing). Behavior follows that project, with a few protocol fixes noted in the source where the original had clear mistakes.

API reference (this crate on Docs.rs): nexstar_rust on docs.rs

Source: github.com/spin7ion/nexstar_rust

Contact: spin7ion@gmail.com · spin@7ion.ru

This crate handles encoding and decoding only. It does not open a serial port; wire those bytes up with your platform’s UART/USB stack (for example serialport on desktop).

§Quick start

Add the crate to your project:

[dependencies]
nexstar_rust = "0.1"

Build bytes and parse a reply:

use nexstar_rust::{build_get_version_command, NexstarParsedResponse};

let v = build_get_version_command();
let reply_from_mount = [4u8, 21, b'#'];
match v.parse_response(&reply_from_mount) {
    NexstarParsedResponse::Version(r) if r.success() => {
        assert_eq!(r.version(), "4.21");
    }
    _ => panic!("expected version"),
}

§Examples

ExampleWhat it shows
build_commandsCommon command strings / byte vectors
parse_responsesTurning sample replies into structs
cargo run --example build_commands
cargo run --example parse_responses

§API overview

§License

Licensed under either of Apache-2.0 or MIT at your option.

§Publishing (maintainers)

See the Cargo Book: Publishing on crates.io. Run cargo publish --dry-run, then cargo login and cargo publish. Repository and homepage are set in Cargo.toml.

Re-exports§

pub use command::NexstarCommand;
pub use command::PassThroughCommand;
pub use parser::parse_response;
pub use response::EchoResponse;
pub use response::GetDateResponse;
pub use response::GetGpsLatitudeResponse;
pub use response::GetGpsLongitudeResponse;
pub use response::GetGpsTimeResponse;
pub use response::GetGpsYearResponse;
pub use response::GetLocationResponse;
pub use response::GetModelResponse;
pub use response::GetPositionResponse;
pub use response::GetRtcTimeResponse;
pub use response::GetTimeResponse;
pub use response::GetTrackingModeResponse;
pub use response::GetVersionResponse;
pub use response::IsAlignmentCompleteResponse;
pub use response::IsGotoInProgressResponse;
pub use response::IsGpsLinkedResponse;
pub use response::NexstarParsedResponse;
pub use response::PassThroughPayload;
pub use response::PassThroughResponse;
pub use response::VoidResponse;
pub use utils::convert_degrees_to_nexstar;
pub use utils::convert_degrees_to_precise_nexstar;
pub use utils::deg_to_dms;
pub use utils::dms_to_deg;
pub use utils::int_to_string_rad;
pub use utils::string_to_double_rad;
pub use utils::tracking_rate_to_bytes;
pub use constants::*;
pub use factory::*;

Modules§

command
Command envelope: opcode + payload.
constants
Protocol enums and constants.
factory
High-level command builders.
parser
Dispatch parsing by command type.
response
Parsed responses from the mount.
utils
Angle and binary helpers.