Compare commits
2 Commits
a3b4ffc76d
...
d4bc537cbd
Author | SHA1 | Date | |
---|---|---|---|
d4bc537cbd | |||
8037568f38 |
@ -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 {
|
||||
|
@ -33,7 +33,7 @@ pub fn run(allocator: std.mem.Allocator) !void {
|
||||
.rotator = try YaesuController.init(allocator),
|
||||
};
|
||||
|
||||
while (true) {
|
||||
while (interface.running) {
|
||||
const client = try server.accept();
|
||||
defer {
|
||||
log.info("disconnecting client", .{});
|
||||
@ -42,8 +42,6 @@ pub fn run(allocator: std.mem.Allocator) !void {
|
||||
}
|
||||
|
||||
interface.writer = .{ .unbuffered_writer = client.stream.writer() };
|
||||
interface.running = true;
|
||||
defer interface.running = false;
|
||||
|
||||
log.info("client connected from {}", .{client.address});
|
||||
|
||||
@ -60,6 +58,11 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user