Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Log.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ duration: f32,
/// Items to be logged on every selected axis.
config: Config,
/// Axes to be logged.
axes: [3]bool,
axes: Axes,
/// Command run by the driver while logging.
command: Command,

pub const Axes = struct {
axis1: bool,
axis2: bool,
axis3: bool,
};

pub const Command = union(Kind) {
// TODO: Support the remaining commands SHDrv provide:
// - Offline commands with applied voltage (V) and applied angle (turn):
Expand Down
7 changes: 4 additions & 3 deletions src/Message.zig
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ pub const Request = union(Kind) {
// f32 samples, then ETX and BCC. The sample count is truncated
// like SHDrv's `(int)(m_Sec * 15000)`.
const config_count = @popCount(@as(u32, @bitCast(log.config)));
const axis_count: u32 =
@intCast(std.mem.countScalar(bool, &log.axes, true));
const axis_names = @typeInfo(Log.Axes).@"struct".field_names;
const axis_count: u32 = axis_names.len;
const sample_count: u32 =
@trunc(@as(f32, @floatFromInt(Log.FREQUENCY)) * log.duration);
const response_size: u32 = @sizeOf(Header) +
Expand All @@ -468,7 +468,8 @@ pub const Request = union(Kind) {
result.profile_acceleration = profile.acceleration;
},
}
for (&result.config, log.axes) |*axis_config, is_logged| {
inline for (&result.config, axis_names) |*axis_config, axis_name| {
const is_logged = @field(log.axes, axis_name);
const names = @typeInfo(Log.Config).@"struct".field_names;
inline for (names) |name| {
@field(axis_config.*, name) = AxisConfig.fromBool(
Expand Down
Loading