rotctl: add autopark functionality

Since gpredict doesn't have a park button or anything, this will just
automatically park the antenna when the gpredict rotator controller
disconnects. This may or may not actually be a good idea. We will see.
This commit is contained in:
torque 2024-07-18 19:42:47 -07:00
parent 61c10df63d
commit de487d18c5
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
2 changed files with 8 additions and 1 deletions

View File

@ -92,6 +92,7 @@ pub fn validate(self: Config, err_writer: anytype) !void {
rotctl: RotControlConfig = .{ rotctl: RotControlConfig = .{
.listen_address = "127.0.0.1", .listen_address = "127.0.0.1",
.listen_port = 4533, .listen_port = 4533,
.autopark = false,
}, },
labjack: LabjackConfig = .{ labjack: LabjackConfig = .{
.device = .autodetect, .device = .autodetect,
@ -151,6 +152,7 @@ pub const MinMax = struct {
const RotControlConfig = struct { const RotControlConfig = struct {
listen_address: []const u8, listen_address: []const u8,
listen_port: u16, listen_port: u16,
autopark: bool,
}; };
const LabjackConfig = struct { const LabjackConfig = struct {

View File

@ -37,7 +37,8 @@ pub fn run(allocator: std.mem.Allocator) !void {
const client = try server.accept(); const client = try server.accept();
defer { defer {
log.info("disconnecting client", .{}); log.info("disconnecting client", .{});
interface.rotator.stop(); if (!config.rotctl.autopark)
interface.rotator.stop();
client.stream.close(); client.stream.close();
} }
@ -60,6 +61,10 @@ pub fn run(allocator: std.mem.Allocator) !void {
std.mem.trim(u8, fbs.getWritten(), &std.ascii.whitespace), std.mem.trim(u8, fbs.getWritten(), &std.ascii.whitespace),
) catch break; ) catch break;
} }
// loop ended due to client disconnect
if (interface.running and config.rotctl.autopark)
interface.rotator.startPark();
} }
} }