Compare commits
2 Commits
dbbb5c1748
...
e639a17424
Author | SHA1 | Date | |
---|---|---|---|
e639a17424 | |||
10c40d7d50 |
@ -45,6 +45,9 @@
|
|||||||
#define MIN_U6_FIRMWARE_MAJOR 0
|
#define MIN_U6_FIRMWARE_MAJOR 0
|
||||||
#define MIN_U6_FIRMWARE_MINOR 81
|
#define MIN_U6_FIRMWARE_MINOR 81
|
||||||
|
|
||||||
|
// Set to 0 for no debug logging or 1 for logging.
|
||||||
|
#define LJ_DEBUG 0
|
||||||
|
|
||||||
static bool gIsLibUSBInitialized = false;
|
static bool gIsLibUSBInitialized = false;
|
||||||
static struct libusb_context *gLJContext = NULL;
|
static struct libusb_context *gLJContext = NULL;
|
||||||
|
|
||||||
@ -502,7 +505,7 @@ static HANDLE LJUSB_OpenSpecificDevice(libusb_device *dev, const struct libusb_d
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// Test if the kernel driver has the U12.
|
// Test if the kernel driver has the U12.
|
||||||
if (desc->idProduct == U12_PRODUCT_ID && libusb_kernel_driver_active(devh, 0)) {
|
if (desc->idProduct == U12_PRODUCT_ID && libusb_kernel_driver_active(devh, 0)) {
|
||||||
#if LJ_DEBUG
|
#if LJ_DEBUG
|
||||||
|
@ -55,7 +55,6 @@ controller: ControllerConfig = .{
|
|||||||
.loop_interval_ns = 50_000_000,
|
.loop_interval_ns = 50_000_000,
|
||||||
.parking_posture = .{ .azimuth = 180, .elevation = 90 },
|
.parking_posture = .{ .azimuth = 180, .elevation = 90 },
|
||||||
.angle_tolerance = .{ .azimuth = 1, .elevation = 1 },
|
.angle_tolerance = .{ .azimuth = 1, .elevation = 1 },
|
||||||
.angle_offset = .{ .azimuth = 0, .elevation = 0 },
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pub const VoltAngle = struct { voltage: f64, angle: f64 };
|
pub const VoltAngle = struct { voltage: f64, angle: f64 };
|
||||||
@ -105,7 +104,6 @@ const ControllerConfig = struct {
|
|||||||
loop_interval_ns: u64,
|
loop_interval_ns: u64,
|
||||||
parking_posture: AzEl,
|
parking_posture: AzEl,
|
||||||
angle_tolerance: AzEl,
|
angle_tolerance: AzEl,
|
||||||
angle_offset: AzEl,
|
|
||||||
|
|
||||||
const OutPair = struct {
|
const OutPair = struct {
|
||||||
increase: lj.DigitalOutputChannel,
|
increase: lj.DigitalOutputChannel,
|
||||||
|
@ -44,13 +44,6 @@ pub fn setTarget(self: LabjackYaesu, target: AzEl) void {
|
|||||||
controller.requested_state = .running;
|
controller.requested_state = .running;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(self: LabjackYaesu) AzEl {
|
|
||||||
self.lock.lock();
|
|
||||||
defer self.lock.unlock();
|
|
||||||
|
|
||||||
return self.controller.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn startCalibration(self: LabjackYaesu) void {
|
pub fn startCalibration(self: LabjackYaesu) void {
|
||||||
// there are two different types of calibration:
|
// there are two different types of calibration:
|
||||||
// 1. feedback calibration, running to the extents of the rotator
|
// 1. feedback calibration, running to the extents of the rotator
|
||||||
|
@ -51,9 +51,7 @@ pub fn run(allocator: std.mem.Allocator) !void {
|
|||||||
|
|
||||||
while (interface.running) : (fbs.reset()) {
|
while (interface.running) : (fbs.reset()) {
|
||||||
reader.streamUntilDelimiter(fbs.writer(), '\n', readbuffer.len) catch break;
|
reader.streamUntilDelimiter(fbs.writer(), '\n', readbuffer.len) catch break;
|
||||||
try interface.handleHamlibCommand(
|
try interface.handleHamlibCommand(fbs.getWritten());
|
||||||
std.mem.trim(u8, fbs.getWritten(), &std.ascii.whitespace),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,11 +65,6 @@ fn replyStatus(self: *RotCtl, comptime status: HamlibErrorCode) !void {
|
|||||||
try self.write(comptime status.replyFrame() ++ "\n");
|
try self.write(comptime status.replyFrame() ++ "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn printReply(self: *RotCtl, comptime fmt: []const u8, args: anytype) !void {
|
|
||||||
try self.writer.writer().print(fmt ++ "\n", args);
|
|
||||||
try self.writer.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handleHamlibCommand(
|
fn handleHamlibCommand(
|
||||||
self: *RotCtl,
|
self: *RotCtl,
|
||||||
command: []const u8,
|
command: []const u8,
|
||||||
@ -81,26 +74,25 @@ fn handleHamlibCommand(
|
|||||||
const first = tokens.next().?;
|
const first = tokens.next().?;
|
||||||
if (first.len == 1 or first[0] == '\\') {
|
if (first.len == 1 or first[0] == '\\') {
|
||||||
switch (first[0]) {
|
switch (first[0]) {
|
||||||
'q', 'Q' => {
|
'q' => {
|
||||||
self.running = false;
|
self.running = false;
|
||||||
self.replyStatus(.okay) catch {};
|
self.replyStatus(.okay) catch return;
|
||||||
self.rotator.stop();
|
|
||||||
},
|
|
||||||
'P' => {
|
|
||||||
const pos = self.rotator.position();
|
|
||||||
try self.printReply("{d:.1} {d:.1}", .{ pos.azimuth, pos.elevation });
|
|
||||||
},
|
},
|
||||||
'\\' => {
|
'\\' => {
|
||||||
try self.parseLongCommand(first[1..], &tokens);
|
return try self.parseLongCommand(first[1..], &tokens);
|
||||||
},
|
},
|
||||||
else => {
|
else => |cmd| {
|
||||||
log.err("unknown short command '{s}'", .{command});
|
log.err("unknown command {}", .{cmd});
|
||||||
try self.replyStatus(.not_implemented);
|
try self.replyStatus(.not_implemented);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else if (std.mem.eql(u8, first, "AOS")) {
|
||||||
try self.parseLongCommand(first, &tokens);
|
// gpredict just kind of shoves this message in on top of the HamLib
|
||||||
}
|
// protocol.
|
||||||
|
try self.replyStatus(.okay);
|
||||||
|
} else if (std.mem.eql(u8, first, "LOS")) {
|
||||||
|
try self.replyStatus(.okay);
|
||||||
|
} else try self.replyStatus(.not_supported);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseLongCommand(
|
fn parseLongCommand(
|
||||||
@ -113,12 +105,12 @@ fn parseLongCommand(
|
|||||||
for (rotctl_commands) |check| {
|
for (rotctl_commands) |check| {
|
||||||
if (check.long) |long| {
|
if (check.long) |long| {
|
||||||
if (command.len >= long.len and std.mem.eql(u8, long, command)) {
|
if (command.len >= long.len and std.mem.eql(u8, long, command)) {
|
||||||
log.warn("Unsupported long command {s}", .{command});
|
log.warn("Unsupported command {s}", .{command});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Unknown long command '{s}'", .{command});
|
log.warn("Unknown command {s}", .{command});
|
||||||
}
|
}
|
||||||
return self.replyStatus(.not_supported);
|
return self.replyStatus(.not_supported);
|
||||||
}
|
}
|
||||||
@ -162,8 +154,6 @@ const HamlibCommand = struct {
|
|||||||
const rotctl_commands = [_]HamlibCommand{
|
const rotctl_commands = [_]HamlibCommand{
|
||||||
.{ .short = 'q' }, // quit
|
.{ .short = 'q' }, // quit
|
||||||
.{ .short = 'Q' }, // quit
|
.{ .short = 'Q' }, // quit
|
||||||
.{ .long = "AOS" },
|
|
||||||
.{ .long = "LOS" },
|
|
||||||
.{ .short = 'P', .long = "set_pos" }, // azimuth: f64, elevation: f64
|
.{ .short = 'P', .long = "set_pos" }, // azimuth: f64, elevation: f64
|
||||||
.{ .short = 'p', .long = "get_pos" }, // return az: f64, el: f64
|
.{ .short = 'p', .long = "get_pos" }, // return az: f64, el: f64
|
||||||
.{ .short = 'M', .long = "move" }, // direction: enum { up=2, down=4, left=8, right=16 }, speed: i8 (0-100 or -1)
|
.{ .short = 'M', .long = "move" }, // direction: enum { up=2, down=4, left=8, right=16 }, speed: i8 (0-100 or -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user