From de487d18c5f02b32e570b17d3aff76e81fd1d16a Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 18 Jul 2024 19:42:47 -0700 Subject: [PATCH] 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. --- src/Config.zig | 2 ++ src/RotCtl.zig | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Config.zig b/src/Config.zig index 8d5ed1c..4652281 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -92,6 +92,7 @@ pub fn validate(self: Config, err_writer: anytype) !void { rotctl: RotControlConfig = .{ .listen_address = "127.0.0.1", .listen_port = 4533, + .autopark = false, }, labjack: LabjackConfig = .{ .device = .autodetect, @@ -151,6 +152,7 @@ pub const MinMax = struct { const RotControlConfig = struct { listen_address: []const u8, listen_port: u16, + autopark: bool, }; const LabjackConfig = struct { diff --git a/src/RotCtl.zig b/src/RotCtl.zig index b42073c..da019e8 100644 --- a/src/RotCtl.zig +++ b/src/RotCtl.zig @@ -37,7 +37,8 @@ pub fn run(allocator: std.mem.Allocator) !void { const client = try server.accept(); defer { log.info("disconnecting client", .{}); - interface.rotator.stop(); + if (!config.rotctl.autopark) + interface.rotator.stop(); client.stream.close(); } @@ -60,6 +61,10 @@ pub fn run(allocator: std.mem.Allocator) !void { std.mem.trim(u8, fbs.getWritten(), &std.ascii.whitespace), ) catch break; } + + // loop ended due to client disconnect + if (interface.running and config.rotctl.autopark) + interface.rotator.startPark(); } }