From 6c83b7ed2097ded689edb4e676b82e9397339012 Mon Sep 17 00:00:00 2001 From: Tyler Kron Date: Sun, 29 Mar 2026 10:03:16 -0600 Subject: [PATCH] fix: send decimal channel mask instead of binary string The firmware's SCPI_ParamInt32 parses ENAble:VOLTage:DC as a decimal integer, but the example app was treating --channels as a binary string and generating binary masks internally. Changes: - IsValidChannelMask: now validates decimal integers instead of 0/1 strings - Auto-generated all-channel mask: uses (1 << count) - 1 instead of new string('1', count) which produced the wrong decimal value - Help text: updated to show decimal bitmask examples Tested on real hardware (Nq1 at /dev/cu.usbmodem101): --channels 7 correctly logged only channels 0,1,2 (3 analog values per sample). Co-Authored-By: Claude Opus 4.6 --- Program.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Program.cs b/Program.cs index cd55f2c..9f951a3 100644 --- a/Program.cs +++ b/Program.cs @@ -725,7 +725,7 @@ private static async Task RunSdCardOperationAsync(CliOptions options) var adcCount = streamingDevice.Metadata.Capabilities.AnalogInputChannels; if (adcCount > 0) { - channelMask = new string('1', adcCount); + channelMask = ((1u << adcCount) - 1).ToString(); } } @@ -1289,15 +1289,7 @@ private static string GetLogFormatLabel(string fileName) private static bool IsValidChannelMask(string channelMask) { - foreach (var value in channelMask) - { - if (value != '0' && value != '1') - { - return false; - } - } - - return true; + return uint.TryParse(channelMask, out _); } private static void PrintHelp() @@ -1322,7 +1314,7 @@ private static void PrintHelp() Console.WriteLine("Streaming Options:"); Console.WriteLine($" --rate Streaming rate in Hz (default: {DefaultRate})."); Console.WriteLine($" --duration Duration to stream (default: {DefaultDurationSeconds})."); - Console.WriteLine(" --channels Enable ADC channels with a 0/1 mask."); + Console.WriteLine(" --channels Enable ADC channels with a decimal bitmask (e.g. 7 = ch 0,1,2)."); Console.WriteLine(" --limit Stop after N stream messages."); Console.WriteLine(" --min-samples Require at least N stream messages (exit code 2 on failure)."); Console.WriteLine();