Compare commits

..

2 Commits

Author SHA1 Message Date
d4bc537cbd
rotctl: actually quit when receiving the quit message 2024-07-18 21:47:50 -07:00
8037568f38
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.
2024-07-18 21:47:50 -07:00

View File

@ -37,8 +37,7 @@ pub fn run(allocator: std.mem.Allocator) !void {
const client = try server.accept();
defer {
log.info("disconnecting client", .{});
if (!config.rotctl.autopark)
interface.rotator.stop();
interface.rotator.stop();
client.stream.close();
}
@ -61,11 +60,10 @@ pub fn run(allocator: std.mem.Allocator) !void {
}
// loop ended due to client disconnect
if (interface.running and config.rotctl.autopark)
if (interface.running and config.rotctl.autopark) {
interface.rotator.startPark();
}
}
interface.rotator.control_thread.join();
}
fn write(self: *RotCtl, buf: []const u8) !void {
@ -177,6 +175,7 @@ fn handleHamlibCommand(
if (first.len == 1 or first[0] == '\\') {
switch (first[0]) {
// NOTE: this is not technically supported by rotctld.
'q', 'Q' => try self.quit(first, &tokens),
'S' => try self.stop(first, &tokens),
'K' => try self.park(first, &tokens),
'p' => try self.getPosition(first, &tokens),
@ -247,8 +246,8 @@ const HamlibCommand = struct {
};
const rotctl_commands = [_]HamlibCommand{
.{ .long = "quit", .callback = quit },
.{ .long = "exit", .callback = quit },
.{ .short = 'q', .callback = quit }, // quit
.{ .short = 'Q', .callback = quit }, // quit
.{ .long = "AOS", .callback = blindAck },
.{ .long = "LOS", .callback = blindAck },
.{ .short = 'P', .long = "set_pos", .callback = setPosition }, // azimuth: f64, elevation: f64