Skip to content

Commit 599937a

Browse files
committed
feat: smarter rotator polling - interleaved timer, adaptive rate, tolerance
- Replace dual setInterval with single setTimeout chain alternating poll → track phases, avoiding back-to-back commands on serial links - Adaptive poll rate derived from rotator velocity (250ms at full slew, 3s when idle), no extra config needed - Skip redundant track commands when target hasn't moved >0.05° - Add configurable tolerance (GPredict-style): suppress position commands when rotator is already within threshold of target, reducing gear wear - Fix azimuth wraparound in velocity, slew detection, and skip checks - Map Hamlib RPRT error codes to human-readable messages - Default WebSocket URL to ws://localhost:4534 to match docs - Update network guide with clearer install/run steps for bridges
1 parent fcad2c9 commit 599937a

3 files changed

Lines changed: 220 additions & 110 deletions

File tree

src/rotator/rotctld.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class RotctldDriver implements RotatorDriver {
2727
}
2828

2929
async connect(options: RotatorConnectOptions): Promise<void> {
30-
const url = options.wsUrl ?? 'ws://localhost:4533';
30+
const url = options.wsUrl ?? 'ws://localhost:4534';
3131
return new Promise<void>((resolve, reject) => {
3232
const ws = new WebSocket(url, ['binary']);
3333
ws.binaryType = 'arraybuffer';
@@ -169,10 +169,33 @@ export class RotctldDriver implements RotatorDriver {
169169
}
170170
}
171171

172+
/**
173+
* Hamlib error codes → human-readable descriptions.
174+
* @see https://github.com/Hamlib/Hamlib/blob/master/include/hamlib/rig.h — rig_errcode_e
175+
*/
176+
const RPRT_ERRORS: Record<string, string> = {
177+
'-1': 'Invalid parameter (check az/el limits)',
178+
'-2': 'Invalid configuration',
179+
'-3': 'Out of memory',
180+
'-4': 'Not implemented',
181+
'-5': 'Communication timed out',
182+
'-6': 'I/O error',
183+
'-7': 'Internal error',
184+
'-8': 'Protocol error',
185+
'-9': 'Command rejected',
186+
'-10': 'Argument truncated',
187+
'-11': 'Not available',
188+
'-12': 'Target not available',
189+
'-13': 'Bus error',
190+
'-14': 'Bus busy / collision',
191+
'-17': 'Argument out of range',
192+
};
193+
172194
/** Throw if rotctld returned an error code (RPRT -N). */
173195
function checkRprt(response: string): void {
174196
const match = response.match(/RPRT\s+(-\d+)/);
175197
if (match) {
176-
throw new Error(`rotctld error: RPRT ${match[1]}`);
198+
const desc = RPRT_ERRORS[match[1]] ?? `unknown error ${match[1]}`;
199+
throw new Error(desc);
177200
}
178201
}

0 commit comments

Comments
 (0)