update readme, add bash-scripts for mount management

This commit is contained in:
Edward Emelianov
2026-10-19 00:07:20 +03:00
parent 26a14dbe3b
commit 59d5078184
8 changed files with 382 additions and 32 deletions

7
.gitignore vendored
View File

@@ -1,10 +1,3 @@
# executables
*
!*.*
!*/
!Makefile
![Rr][Ee][Aa][Dd][Mm][Ee]
# build dirs # build dirs
mk/ mk/
build/ build/

View File

@@ -193,16 +193,17 @@ motion default to 0.
The daemon distinguishes the following frames: The daemon distinguishes the following frames:
| Frame | Notation | Units | Notes | | Frame | Notation | Units | Notes |
|-----------------------------|------------|----------|----------------------------------------------------------| |--------------------------------|------------|----------|----------------------------------------------------------|
| Catalog (ICRS / J2000) | `J2000` | RA: hours, Dec: degrees | Coordinates entered by the user via `tagra/tagdec`. | | Catalog (ICRS / J2000) | `J2000` | RA: hours, Dec: degrees | Coordinates entered by the user via `tagra/tagdec`. |
| Epoch of date (mean equinox)| `Jnow` | RA: hours, Dec: degrees | Used internally for pointing. | | Epoch of date (mean equinox) | `Jnow` | RA: hours, Dec: degrees | Used internally for pointing. |
| CIRS (geocentric apparent) | — | radians | Result of `eraAtci13`. | | Input epoch | `Jx` | RA: hours, Dec: degrees | Default is `J2000`, but user can select another epoch |
| Observed (with refraction) | — | radians | Result of `eraAtco13`. | | CIRS (geocentric apparent) | — | radians | Result of `eraAtci13`. |
| Horizontal | `Az/Zd` | degrees | Azimuth, clockwise from North. ZD = 90° − altitude. | | Observed (without refraction) | — | radians | Taken from mount |
| Horizontal | `Az/Zd` | degrees | Azimuth, clockwise from North. ZD = 90° − altitude. |
- **Target epoch** is stored as an MJD. By default it is J2000 (`ERFA_DJM00` = 51544.5). It can be - **Target epoch** is stored as a decimal year. By default it is J2000 (`2000.0`). It can be set with
set to any epoch via the `tagmjd` command. the `tagepoch` command in the range 1950…2050.
- The command `gotord` converts the input coordinates from the target epoch to *Jnow* using - The command `gotord` converts the input coordinates from the target epoch to *Jnow* using
`JXtoJnow()` before sending to the mount. `JXtoJnow()` before sending to the mount.
- The command `gotorh` interprets the input as an **hour angle** and converts to RA using the - The command `gotorh` interprets the input as an **hour angle** and converts to RA using the
@@ -238,6 +239,14 @@ Values may be given either as a decimal number (`12.345`, `-26.5`) or as `DD:MM:
(sexagesimal). Angles are interpreted as degrees unless the field name (RA, HA, LST) explicitly (sexagesimal). Angles are interpreted as degrees unless the field name (RA, HA, LST) explicitly
implies hours. implies hours.
Angle getters reply in decimal degrees/hours by default. A client can switch its own replies to
sexagesimal strings with `format = 1`; `format = 0` restores decimal output. The setting is
per connection.
Any command line that begins with `:` and ends with `#` is also accepted as a raw mount command,
even if it is not one of the daemon’s own command names. For example, `:Ginfo#` is equivalent to
`raw = Ginfo`.
### Stellarium socket ### Stellarium socket
Default address: `:10000` (all interfaces, port 10000). Protocol: **binary little-endian**, Default address: `:10000` (all interfaces, port 10000). Protocol: **binary little-endian**,
@@ -245,8 +254,8 @@ according to Stellarium's "Telescope Control" plugin specification.
Incoming (client → server) message, 20 bytes: Incoming (client → server) message, 20 bytes:
| Field | Type | Meaning | | Field | Type | Meaning |
|--------|-----------|--------------------------------------------------------| |--------|-----------|---------------------------------------------------------|
| `len` | `uint16` | Total message length (`20`). | | `len` | `uint16` | Total message length (`20`). |
| `type` | `uint16` | `0`. | | `type` | `uint16` | `0`. |
| `time` | `uint64` | µs since epoch (unused). | | `time` | `uint64` | µs since epoch (unused). |
@@ -256,9 +265,10 @@ Incoming (client → server) message, 20 bytes:
Outgoing (server → client) message, 24 bytes: same fields plus a trailing `int32 status` (0 = ok, Outgoing (server → client) message, 24 bytes: same fields plus a trailing `int32 status` (0 = ok,
other = error). other = error).
The daemon treats incoming messages as `tagra`/`tagdec` in the current epoch (which for Stellarium The daemon stores incoming RA/Dec as input target coordinates and sets the target epoch to J2000.
is normally J2000). It does **not** automatically start a slew — the client must send `gotord` on It does **not** automatically start a slew — the client must send `gotord` on the command socket.
the command socket. The outgoing telescope position is converted from the mount’s *JNow* coordinates to J2000 before
packing.
--- ---
@@ -276,7 +286,7 @@ setter commands require an argument of the indicated type.
| `tagha` | get/set| hours | Target hour angle (alternative to RA). | | `tagha` | get/set| hours | Target hour angle (alternative to RA). |
| `tagaz` | get/set| degrees (0…360) | Target azimuth (clock from North). | | `tagaz` | get/set| degrees (0…360) | Target azimuth (clock from North). |
| `tagzd` | get/set| degrees (0…90) | Target zenith distance. | | `tagzd` | get/set| degrees (0…90) | Target zenith distance. |
| `tagmjd` | get/set| MJD or `J<year>` | Epoch of the input coordinates. `J2050` = 2050.0, `51544.5` = J2000. | | `tagepoch`| get/set| decimal year | Epoch of the input RA/Dec, in the range 1950…2050. Default `2000.0`. |
### Pointing ### Pointing
@@ -291,6 +301,14 @@ setter commands require an argument of the indicated type.
| `park` | Slew to the parking position (see `parkaz`/`parkzd`). | | `park` | Slew to the parking position (see `parkaz`/`parkzd`). |
| `shutdown`| Power off the mount. Requires a numeric key to confirm (see below). | | `shutdown`| Power off the mount. Requires a numeric key to confirm (see below). |
### Corrections and housekeeping
| Command | Type | Units | Description |
|-----------|--------|---------|-----------------------------------------------------------------------------|
| `corra` | set | arcsec | Correct RA by the given angle. Positive = east, negative = west. |
| `cordec` | set | arcsec | Correct Dec by the given angle. Positive = north, negative = south. |
| `update` | action | — | Force the next time/weather correction to be sent to the mount, even while tracking. |
### State queries ### State queries
| Command | Units | Description | | Command | Units | Description |
@@ -307,6 +325,12 @@ setter commands require an argument of the indicated type.
`tel*` commands return `RESULT_FAIL` if the weather feed is lost or the mount is in `Error` state — `tel*` commands return `RESULT_FAIL` if the weather feed is lost or the mount is in `Error` state —
this prevents a client from acting on stale coordinates. this prevents a client from acting on stale coordinates.
### Output format
| Command | Type | Argument | Description |
|-----------|--------|----------|-----------------------------------------------------------------------------|
| `format` | get/set| `0`/`1` | Per-client angle output format. `0` (default) = decimal; `1` = sexagesimal. |
### Place and almanac data ### Place and almanac data
| Command | Type | Description | | Command | Type | Description |
@@ -327,9 +351,21 @@ Place data can only be set at start-up (via CLI/config).
### Sending custom command ### Sending custom command
The `raw` command allows to send any unsupported command string directly to mount. The `raw` command sends an arbitrary 10Micron command. The argument may be supplied either with or
E.g. to set lunar tracking rate send `raw = :TL#`. If mount gives no answer for command, you will without the protocol delimiters: the daemon prepends `:` and appends `#` if they are missing. The
get message "No answer", otherwise you'll get this answer. command body is limited to 29 characters before automatic wrapping.
All of the following are equivalent:
```
raw = Ginfo
raw = :Ginfo#
:Ginfo#
```
The last form works because an unknown command line that starts with `:` and ends with `#` is
passed to the mount as a raw command. If the mount gives no answer, the daemon reports that the raw
command received no answer or returned an error.
### Shutdown ### Shutdown
@@ -355,7 +391,6 @@ The following keywords are written (only if meaningful):
| Keyword | Comment | | Keyword | Comment |
|------------------|----------------------------------------------------------------------| |------------------|----------------------------------------------------------------------|
| `TIMESYS` | `'UTC'`. |
| `ORIGIN` | `'SAO RAS'`. | | `ORIGIN` | `'SAO RAS'`. |
| `MOUNTNAM` | Mount name (from `--mountname`). | | `MOUNTNAM` | Mount name (from `--mountname`). |
| `POLARX` | X pole coordinate, arcsec (if non-zero). | | `POLARX` | X pole coordinate, arcsec (if non-zero). |
@@ -366,11 +401,16 @@ The following keywords are written (only if meaningful):
| `TAGRA`,`TAGDEC` | Last **slewed-to** target, always celestial. | | `TAGRA`,`TAGDEC` | Last **slewed-to** target, always celestial. |
| `RA`,`HA`,`DEC` | Current telescope position in *Jnow*. | | `RA`,`HA`,`DEC` | Current telescope position in *Jnow*. |
| `AZ`,`ZD` | Current telescope position in the horizontal frame. | | `AZ`,`ZD` | Current telescope position in the horizontal frame. |
| `AZCALC`,`ZDCALC`| Current position recalculated from `RA` and `DEC`. |
| `AIRMASS` | Calculated air mass by current meteo data and position. |
| `ATMDENS` | Atmosphere column density. |
| `WVDENS` | Water vapour column density. |
| `WVAM` | Water vapour air mass. |
| `TELSTAT` | Human-readable mount status. | | `TELSTAT` | Human-readable mount status. |
| `INPEQUIN` | Epoch (year) of the input coordinates. | | `INPEQUIN` | Epoch (year) of the input coordinates. |
| `EQUINOX` | Epoch (year) of the current telescope coordinates. | | `EQUINOX` | Epoch (year) of the current telescope coordinates. |
| `MJD` | MJD of the header. | | `MJD` | MJD of the header. |
| `PIERSIDE` | Pier side of the mount (`'E'`/`'W'`). | | `PIERSIDE` | Pier side of the mount (`'East'`/`'West'`). |
| `ELEVAT` | Site altitude, m. | | `ELEVAT` | Site altitude, m. |
| `LONGITUD` | Site longitude, degrees east. | | `LONGITUD` | Site longitude, degrees east. |
| `LATITUDE` | Site latitude, degrees north. | | `LATITUDE` | Site latitude, degrees north. |
@@ -489,10 +529,9 @@ is a kinematic approximation suitable for client development.
- `mount_corrdata()` uses **local** time for the `:SLDT` command, which matches the 10Micron - `mount_corrdata()` uses **local** time for the `:SLDT` command, which matches the 10Micron
firmware convention; this is intentional and differs from the rest of the daemon, which works in firmware convention; this is intentional and differs from the rest of the daemon, which works in
UTC. UTC.
- The Stellarium protocol implementation uses JNow coordinates (the DAEMON does not perform the - The Stellarium protocol implementation assumes incoming coordinates are J2000 and converts the
JNow→J2000 conversion that some clients expect). Planetarium programs that assume J2000 output may outgoing telescope position from JNow to J2000. Clients that use another epoch must perform their
show a small offset; this is acceptable for visual pointing but should be considered if used for own conversion.
astrometric work.
--- ---

View File

@@ -0,0 +1,64 @@
#!/bin/bash
# mount_park - send park command and wait until the mount is parked
#
# Environment:
# MOUNT_HOST daemon hostname (default: localhost)
# MOUNT_PORT daemon command port (default: 10001)
# NC_TIMEOUT network timeout per command, seconds (default: 2)
# PARK_TIMEOUT overall wait for Parked, seconds (default: 60)
#
# Exit status: 0 = parked, 1 = error or timeout.
MOUNT_HOST="${MOUNT_HOST:-localhost}"
MOUNT_PORT="${MOUNT_PORT:-10001}"
NC_TIMEOUT="${NC_TIMEOUT:-2}"
PARK_TIMEOUT="${PARK_TIMEOUT:-60}"
send_cmd() {
printf '%s\n' "$1" | nc -N -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT"
}
reply=$(send_cmd "park")
# issue the park command
for attempt in 1 2 3; do
if [ -n "$reply" ] && [ "$reply" == "OK" ]; then
break
fi
echo "Attempt $attempt failed (reply: '${reply:-no reply}')" >&2
sleep 1
done
if [ -n "$reply" ] && [ "$reply" != "OK" ]; then
echo "Error: failed to park!" >&2; exit 1
fi
echo "Wait for parking"
sleep 2
# wait until the mount reach parking position
start=$(date +%s)
while :; do
reply=$(send_cmd "status")
if [ -z "$reply" ]; then
echo "Daemon not responding" >&2
exit 1
fi
st=$(printf '%s\n' "$reply" | sed -n 's/^status=//p' | tr -d "'")
case "$st" in
Stopped)
echo "OK: Parked"
exit 0
;;
Error|Off)
echo "Mount reported '$st' status while parking" >&2
exit 1
;;
esac
now=$(date +%s)
if [ $((now - start)) -ge "$PARK_TIMEOUT" ]; then
echo "Timeout waiting for Parked (last status: '${st:-no reply}')" >&2
exit 1
fi
echo "Status: $st"
sleep 2
done

View File

@@ -0,0 +1,37 @@
#!/bin/bash
# mount_refresh - force the daemon to refresh weather/time data on the mount
#
# The "update" command sets an internal "needcorr" flag; the main loop then
# calls mount_corrdata() on its next iteration (if the mount is not Off).
# If the mount is Off the daemon returns an error, so we check the status
# to distinguish success from failure.
#
# Up to 3 attempts are made.
#
# Environment:
# MOUNT_HOST daemon hostname (default: localhost)
# MOUNT_PORT daemon command port (default: 10001)
# NC_TIMEOUT network timeout per command, seconds (default: 2)
#
# Exit status: 0 = update queued, 1 = all attempts failed.
MOUNT_HOST="${MOUNT_HOST:-localhost}"
MOUNT_PORT="${MOUNT_PORT:-10001}"
NC_TIMEOUT="${NC_TIMEOUT:-2}"
send_cmd() {
printf '%s\n' "$1" | nc -N -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT"
}
for attempt in 1 2 3; do
reply=$(send_cmd "update")
if [ -n "$reply" ] && [ "$reply" == "OK" ]; then
echo "OK"
exit 0
fi
echo "Attempt $attempt failed (reply: '${reply:-no reply}')" >&2
sleep 1
done
echo "Failed to refresh mount data after 3 attempts" >&2
exit 1

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# mount_shutdown - power the mount off via a two-step handshake
#
# Step 1: send "shutdown" (no argument) -> daemon returns a key
# Step 2: send "shutdown = <key>" -> daemon sends the power-off command
# Step 3: poll status until the mount reports Off (or the daemon dies)
# Step 4: wait 45 s for the mount to fully discharge
#
# Environment:
# MOUNT_HOST daemon hostname (default: localhost)
# MOUNT_PORT daemon command port (default: 10001)
# NC_TIMEOUT network timeout per command, seconds (default: 2)
# SHUTDOWN_WAIT timeout for the mount to report Off, seconds (default: 60)
#
# Exit status: 0 = mount off, 1 = error or timeout.
MOUNT_HOST="${MOUNT_HOST:-localhost}"
MOUNT_PORT="${MOUNT_PORT:-10001}"
NC_TIMEOUT="${NC_TIMEOUT:-2}"
SHUTDOWN_WAIT="${SHUTDOWN_WAIT:-60}"
send_cmd() {
printf '%s\n' "$1" | nc -N -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT"
}
# step 1: request a shutdown key
reply=$(send_cmd "shutdown")
if [ -z "$reply" ]; then
echo "No response from daemon" >&2
exit 1
fi
key=$(printf '%s\n' "$reply" | sed -n 's/^shutdown=//p')
if [ -z "$key" ]; then
echo "Unexpected reply: $reply" >&2
exit 1
fi
# step 2: send the key back
send_cmd "shutdown = $key"
# step 3: wait until the mount reports Off (or the daemon goes away)
start=$(date +%s)
while :; do
reply=$(send_cmd "status")
if [ -z "$reply" ]; then
# daemon is gone: assume the mount has powered off
break
fi
st=$(printf '%s\n' "$reply" | sed -n 's/^status=//p' | tr -d "'")
if [ "$st" = "Off" ]; then
break
fi
now=$(date +%s)
if [ $((now - start)) -ge "$SHUTDOWN_WAIT" ]; then
echo "Timeout waiting for Off (last status: '${st:-no reply}')" >&2
exit 1
fi
sleep 2
done
echo "Wait until the computer turns off..."
# step 4: final settling delay
sleep 45

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# mount_status - print the current mount status as returned by the daemon
#
# Output: one line, the status string without surrounding quotes
# (e.g. Tracking, Slewing or going to stop, Parked, Off, ...)
#
# Environment:
# MOUNT_HOST daemon hostname (default: localhost)
# MOUNT_PORT daemon command port (default: 10001)
# NC_TIMEOUT network timeout, seconds (default: 2)
#
# Exit status: 0 = status printed, 1 = daemon not responding or bad reply.
MOUNT_HOST="${MOUNT_HOST:-localhost}"
MOUNT_PORT="${MOUNT_PORT:-10001}"
NC_TIMEOUT="${NC_TIMEOUT:-2}"
reply=$(printf 'status\n' | nc -N -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT" 2>/dev/null)
if [ -z "$reply" ]; then
echo "Mount daemon is not responding at $MOUNT_HOST:$MOUNT_PORT" >&2
exit 1
fi
st=$(printf '%s\n' "$reply" | sed -n 's/^status=//p' | tr -d "'")
if [ -z "$st" ]; then
echo "Unexpected reply from daemon: $reply" >&2
exit 1
fi
echo "$st"

View File

@@ -0,0 +1,124 @@
#!/bin/bash
# send_coords - command the mount to slew to given coordinates and track
#
# Usage:
# send_coords --ra <hours> --dec <degrees>
# send_coords --ra <hours> --ha <hours>
#
# Environment:
# MOUNT_HOST daemon hostname (default: localhost)
# MOUNT_PORT daemon command port (default: 10001)
# NC_TIMEOUT network timeout per command, seconds (default: 2)
# POLL_TIMEOUT overall wait for Tracking, seconds (default: 60)
#
# Exit status: 0 = tracking, 1 = error or timeout.
# For UNIX-sockets: nc -N -U -w ... <socket>
MOUNT_HOST="${MOUNT_HOST:-localhost}"
MOUNT_PORT="${MOUNT_PORT:-10001}"
NC_TIMEOUT="${NC_TIMEOUT:-2}"
POLL_TIMEOUT="${POLL_TIMEOUT:-60}"
send_cmd() {
printf '%s\n' "$1" | nc -N -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT"
}
usage() {
echo "Usage: $0 --dec <deg> (--ra <hours> | --ha <hours>)" >&2
exit 1
}
# --- no arguments: display current telescope coordinates -------------------
if [ $# -eq 0 ]; then
# Send three commands in one batch. Without -N the daemon never sees
# EOF until the -w timer expires, but that is fine: each line is
# processed and answered as it arrives, so the replies are collected
# long before the connection closes.
reply=$(printf 'format=1\ntelra\nteldec\n' \
| nc -w "$NC_TIMEOUT" "$MOUNT_HOST" "$MOUNT_PORT" 2>/dev/null)
if [ -z "$reply" ]; then
echo "Mount daemon is not responding at $MOUNT_HOST:$MOUNT_PORT" >&2
exit 1
fi
ra=$(printf '%s\n' "$reply" | sed -n 's/^telra=//p')
dec=$(printf '%s\n' "$reply" | sed -n 's/^teldec=//p')
if [ -z "$ra" ] || [ -z "$dec" ]; then
# The daemon suppresses telra/teldec when the mount is Off, in
# Error state, or the weather feed is lost.
echo "Telescope coordinates not available (mount Off or in Error state?)" >&2
exit 1
fi
printf 'RA: %s\n' "$ra"
printf 'Dec: %s\n' "$dec"
exit 0
fi
RA=""
DEC=""
HA=""
GOTO=""
while [ $# -gt 0 ]; do
case "$1" in
--ra) [ $# -ge 2 ] || usage; RA="$2"; shift 2 ;;
--dec) [ $# -ge 2 ] || usage; DEC="$2"; shift 2 ;;
--ha) [ $# -ge 2 ] || usage; HA="$2"; shift 2 ;;
-h|--help) usage ;;
*) echo "Unknown option: $1" >&2; usage ;;
esac
done
[ -n "$DEC" ] || { echo "Error: --dec is required" >&2; exit 1; }
if [ -z "$RA" ] && [ -z "$HA" ]; then
echo "Error: --ra or --ha is required" >&2; exit 1;
fi
if [ -n "$RA" ] && [ -n "$HA" ]; then
echo "Error: --ra and --ha are mutually exclusive" >&2; exit 1
fi
if [ -z "$DEC" ] && [ -z "$HA" ]; then
echo "Error: either --dec or --ha is required" >&2; exit 1
fi
# send coordinates
send_cmd "tagdec = $DEC"
if [ -n "$RA" ]; then
send_cmd "tagra = $RA"
GOTO="gotord"
else
send_cmd "tagha = $HA"
GOTO="gotorh"
fi
# trigger the goto
ans=$(send_cmd "$GOTO")
if [ -z $ans ] || [ "$ans" != "OK" ]; then
echo "Error: can't go to given position" >&2; exit 1
fi
echo "Wait for slewing"
sleep 3
# poll status until Tracking
start=$(date +%s)
while :; do
reply=$(send_cmd "status")
st=$(printf '%s\n' "$reply" | sed -n 's/^status=//p' | tr -d "'")
case "$st" in
Tracking)
echo "OK: Tracking"
exit 0
;;
Error|Off)
echo "Mount reported '$st' status" >&2
exit 1
;;
esac
now=$(date +%s)
if [ $((now - start)) -ge "$POLL_TIMEOUT" ]; then
echo "Timeout waiting for Tracking (last status: '${st:-no reply}')" >&2
exit 1
fi
echo "Status: $st"
sleep 2
done

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 20.0.1, 2026-10-18T02:07:13. --> <!-- Written by QtCreator 20.0.1, 2026-10-18T23:30:40. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>