Skip to content

Commit 3dfe93f

Browse files
tylerkronclaude
andauthored
fix: correct EnableAdcChannels docs from binary to decimal bitmask (#160)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b9c6589 commit 3dfe93f

9 files changed

Lines changed: 31 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ device.MessageReceived += (sender, e) =>
4545
};
4646

4747
// Configure channels and start streaming
48-
device.Send(ScpiMessageProducer.EnableAdcChannels("0000000011")); // Enable first 2 channels
48+
device.Send(ScpiMessageProducer.EnableAdcChannels("3")); // Enable first 2 channels (bitmask 0b11 = 3)
4949
device.Send(ScpiMessageProducer.StartStreaming(100)); // 100 Hz sample rate
5050
5151
await Task.Delay(TimeSpan.FromSeconds(10)); // Stream for 10 seconds

docs/DEVICE_INTERFACES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ device.MessageReceived += (sender, e) =>
2828
};
2929

3030
// Configure channels and start streaming
31-
device.Send(ScpiMessageProducer.EnableAdcChannels("0000000011")); // Enable first 2 channels
31+
device.Send(ScpiMessageProducer.EnableAdcChannels("3")); // Enable first 2 channels (bitmask 0b11 = 3)
3232
device.Send(ScpiMessageProducer.StartStreaming(100)); // 100 Hz sample rate
3333
3434
await Task.Delay(TimeSpan.FromSeconds(10)); // Stream for 10 seconds
@@ -226,8 +226,8 @@ device.MessageReceived += (sender, e) =>
226226
}
227227
};
228228

229-
// Enable channels (binary mask: 1 = enabled)
230-
device.Send(ScpiMessageProducer.EnableAdcChannels("0000000011")); // Channels 0 and 1
229+
// Enable channels (decimal bitmask: each bit enables a channel)
230+
device.Send(ScpiMessageProducer.EnableAdcChannels("3")); // Channels 0 and 1 (bitmask 0b11 = 3)
231231
232232
// Start streaming at 100 Hz
233233
device.Send(ScpiMessageProducer.StartStreaming(100));
@@ -255,7 +255,7 @@ device.Send(ScpiMessageProducer.StartStreaming(1000)); // Start at 1000 Hz
255255
device.Send(ScpiMessageProducer.StopStreaming);
256256

257257
// Channel configuration
258-
device.Send(ScpiMessageProducer.EnableAdcChannels("11111111")); // Enable 8 channels
258+
device.Send(ScpiMessageProducer.EnableAdcChannels("255")); // Enable 8 channels (bitmask 0xFF = 255)
259259
device.Send(ScpiMessageProducer.DisableDeviceEcho);
260260
device.Send(ScpiMessageProducer.SetProtobufStreamFormat);
261261
```

docs/simulator/GITHUB_ISSUES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Implement TCP server for data connections and SCPI command processing, enabling
261261
- `SYSTem:ECHO <-1|1>`
262262
- `SYSTem:StartStreamData <freq>`
263263
- `SYSTem:StopStreamData`
264-
- `ENAble:VOLTage:DC <binary_string>`
264+
- `ENAble:VOLTage:DC <decimal_bitmask>`
265265
- [ ] Integrate TCP server with `DeviceSimulator.StartAsync()`
266266
- [ ] Write integration tests with `DaqifiDevice` and `TcpStreamTransport`
267267

@@ -279,7 +279,7 @@ Implement TCP server for data connections and SCPI command processing, enabling
279279

280280
**Example**:
281281
```
282-
Client: "ENAble:VOLTage:DC 0000000011\r\n"
282+
Client: "ENAble:VOLTage:DC 3\r\n"
283283
Server: (no response)
284284
285285
Client: "SYSTem:SYSInfoPB?\r\n"

docs/simulator/SIMULATOR_DESIGN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ SYSTem:STReam:FORmat <0|1|2>
151151
SYSTem:STReam:FORmat?
152152
153153
# Configuration
154-
ENAble:VOLTage:DC <binary_string>
154+
ENAble:VOLTage:DC <decimal_bitmask>
155155
156156
# Digital I/O
157157
DIO:PORt:DIRection <ch>,<dir>
@@ -282,7 +282,7 @@ Length-delimited DaqifiOutMessage containing:
282282

283283
**Example Exchange**:
284284
```
285-
Client -> Server: "ENAble:VOLTage:DC 0000000011\r\n"
285+
Client -> Server: "ENAble:VOLTage:DC 3\r\n"
286286
Server -> Client: (no response)
287287
288288
Client -> Server: "SYSTem:StartStreamData 100\r\n"
@@ -412,7 +412,7 @@ public async Task CanConnectAndStreamData()
412412
device.Connect();
413413

414414
// Configure channels
415-
device.Send(ScpiMessageProducer.EnableAnalogChannels("0000000011"));
415+
device.Send(ScpiMessageProducer.EnableAdcChannels("3")); // 0b11 = channels 0,1
416416
417417
// Start streaming
418418
var messagesReceived = new List<DaqifiOutMessage>();

docs/simulator/SIMULATOR_IMPLEMENTATION_PLAN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ internal class ScpiCommandProcessor
583583
// Channel configuration
584584
else if (command.StartsWith("enable:voltage:dc "))
585585
{
586-
var binaryString = command.Split(' ')[1];
587-
var mask = Convert.ToUInt32(binaryString, 2);
586+
var maskString = command.Split(' ')[1];
587+
var mask = Convert.ToUInt32(maskString);
588588
_device.SetChannelMask(mask);
589589
return null;
590590
}

src/Daqifi.Core.Tests/Communication/Producers/ScpiMessageProducerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ public void GetStreamFormat_ReturnsCorrectCommand()
151151
[Fact]
152152
public void EnableAdcChannels_ReturnsCorrectCommand()
153153
{
154-
var message = ScpiMessageProducer.EnableAdcChannels("0001010100");
155-
Assert.Equal("ENAble:VOLTage:DC 0001010100", message.Data);
154+
var message = ScpiMessageProducer.EnableAdcChannels("84");
155+
Assert.Equal("ENAble:VOLTage:DC 84", message.Data);
156156
AssertMessageFormat(message);
157157
}
158158

src/Daqifi.Core/Communication/Producers/ScpiMessageProducer.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -316,24 +316,23 @@ public static IOutboundMessage<string> StartStreaming(int frequency)
316316
public static IOutboundMessage<string> GetStreamFormat => new ScpiMessage("SYSTem:STReam:FORmat?");
317317

318318
/// <summary>
319-
/// Creates a command message to enable ADC channels using a binary string.
319+
/// Creates a command message to enable ADC channels using a decimal bitmask.
320320
/// </summary>
321-
/// <param name="channelSetString">A binary string where each character represents a channel (0 = disabled, 1 = enabled), right-to-left. For example, "0001010100" enables channels 2, 4, and 6.</param>
321+
/// <param name="channelSetString">A decimal integer string representing a bitmask where each bit enables a channel. For example, "84" (0b1010100) enables channels 2, 4, and 6.</param>
322322
/// <remarks>
323-
/// The binary string is read from right to left, where position 0 is the rightmost bit:
324-
/// - Position 0: Channel 0
325-
/// - Position 1: Channel 1
326-
/// - Position 2: Channel 2
323+
/// The firmware parses this value as a decimal integer and interprets it as a bitmask:
324+
/// - Bit 0 (value 1): Channel 0
325+
/// - Bit 1 (value 2): Channel 1
326+
/// - Bit 2 (value 4): Channel 2
327327
/// etc.
328-
///
329-
/// Command: ENAble:VOLTage:DC binaryString
330-
/// Example:
328+
///
329+
/// Command: ENAble:VOLTage:DC decimalMask
331330
/// <code>
332-
/// // Enable channels 2, 4, and 6
333-
/// messageProducer.Send(ScpiMessageProducer.EnableAdcChannels("0001010100"));
334-
///
335-
/// // Enable channels 0 and 1
336-
/// messageProducer.Send(ScpiMessageProducer.EnableAdcChannels("0000000011"));
331+
/// // Enable channels 2, 4, and 6 (bitmask = 4 + 16 + 64 = 84)
332+
/// device.Send(ScpiMessageProducer.EnableAdcChannels("84"));
333+
///
334+
/// // Enable channels 0 and 1 (bitmask = 1 + 2 = 3)
335+
/// device.Send(ScpiMessageProducer.EnableAdcChannels("3"));
337336
/// </code>
338337
/// </remarks>
339338
public static IOutboundMessage<string> EnableAdcChannels(string channelSetString)

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ public async Task<IReadOnlyList<SdCardFileInfo>> GetSdCardFilesAsync(Cancellatio
366366
/// (.bin for Protobuf, .json for JSON, .dat for TestData).
367367
/// </param>
368368
/// <param name="channelMask">
369-
/// Optional binary string mask to enable specific ADC channels (e.g. "0000000011" enables channels 0 and 1).
369+
/// Optional decimal bitmask string to enable specific ADC channels (e.g. "3" enables channels 0 and 1).
370+
/// The firmware parses this as a decimal integer where each bit enables a channel.
370371
/// If null or empty, the current device channel configuration is used.
371372
/// </param>
372373
/// <param name="format">The logging format to use. Defaults to <see cref="SdCardLogFormat.Protobuf"/>.</param>

src/Daqifi.Core/Device/SdCard/ISdCardOperations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public interface ISdCardOperations
4040
/// (.bin for Protobuf, .json for JSON, .dat for TestData).
4141
/// </param>
4242
/// <param name="channelMask">
43-
/// Optional binary string mask to enable specific ADC channels (e.g. "0000000011" enables channels 0 and 1).
43+
/// Optional decimal bitmask string to enable specific ADC channels (e.g. "3" enables channels 0 and 1).
44+
/// The firmware parses this as a decimal integer where each bit enables a channel.
4445
/// If null or empty, the current device channel configuration is used.
4546
/// </param>
4647
/// <param name="format">The logging format to use. Defaults to <see cref="SdCardLogFormat.Protobuf"/>.</param>

0 commit comments

Comments
 (0)