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(); } }