Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Acquire analog input

Applies to: xBud only. Anthriq headsets do not declare the analog_input feature; their acquisition path is Stream EXG.

Configure an acquisition task, then read from it — a one-shot sample, a fixed block, or a continuous stream.

The whole sequence as one runnable example is on the xBud page. This page covers each step in depth.

Connect

import { BxiClient } from "@anthriq_dev/bxi-interface";

const client = new BxiClient<"ni-usb-daq">({ deviceType: "ni-usb-daq" });

await client.initialize("localhost");
await client.connect();
from anthriq_bxi_interface import BxiClient

client = BxiClient(device_type="ni-usb-daq")

await client.initialize("localhost")
await client.connect()

Find attached hardware

scan_devices enumerates attached hardware. It is declared by xBud and not by anthriq-instinct.

const response = await client.features.executeOperation("system", "scan_devices", {});
response = await client.execute_operation("system", "scan_devices", {})

query returns detail for one device, or for one channel when channel is supplied:

import { parseQueryInfo } from "@anthriq_dev/bxi-interface";

const response = await client.features.executeOperation("analog_input", "query", {
  device_name: "Dev1",
});

const info = parseQueryInfo(response.data);
console.log(info.product_type, info.ai_max_multi_chan_rate_hz, info.ai_physical_chans);
from anthriq_bxi_interface import parse_query_info

response = await client.execute_operation("analog_input", "query", {
    "device_name": "Dev1",
})

info = parse_query_info(response.data)
print(info["product_type"], info["ai_max_multi_chan_rate_hz"], info["ai_physical_chans"])

Check ai_max_multi_chan_rate_hz against the rate you intend to configure: it is the aggregate across channels, so four channels at 20 kHz aggregate is 5 kHz each.

Query before configuring to learn the device's maximum rate and supported terminal configurations, rather than assuming them.

Configure a task

Field
Type
Required
Description

device_name

string

Yes

DAQmx device name

ai_channels

string

Yes

Physical channel list or range

sample_clock_rate_hz

number

Yes

Sample rate

voltage_range_min, voltage_range_max

number

No

Input range in volts

terminal_config

"RSE", "NRSE", "Differential", "PseudoDifferential"

No

Terminal wiring

sample_mode

"FINITE", "CONTINUOUS", "ON_DEMAND"

No

Acquisition mode

samples_per_channel

number

No

Buffer depth per channel

sample_clock_source

string

No

External clock terminal

sample_clock_active_edge

"RISING", "FALLING"

No

Clock edge

read_timeout_s

number

No

Per-read timeout

start_trigger_type

"NONE", "DIGITAL_EDGE", "ANALOG_EDGE"

No

Trigger source type

start_trigger_source

string

No

Trigger terminal

start_trigger_edge

"RISING", "FALLING"

No

Trigger edge

analog_trigger_level_v

number

No

Analog trigger level

delivery_model

"BLOCKING_READ", "EVERY_N_CALLBACK"

No

Read strategy

configure caches the task. start_stream, stop_stream, and read_finite operate on that cached configuration, so configure before calling them.

Read samples

Three ways, depending on what you need.

One shot, independent of any configuration:

A fixed block from the configured task:

Continuously:

Parse the wire format

The stub returns values in a flat string map, so arrays and objects arrive JSON-encoded. Use the exported helpers rather than reading fields directly.

Helper
Reads

parseSamples

read_single response into a number array

parseStreamFrame

read_finite response into a frame

parseSubscriptionFrame

A stream subscription update into a frame

parseQueryInfo

query response into device or channel info

Each accepts either the JSON string or an already-parsed value, so it works whichever form the transport delivered.

A frame carries samples channels-first:

Field
Type
Description

sequence_no

number

Frame counter

timestamp_ns

number

Frame timestamp

sample_count

number

Samples per channel

n_channels

number

Channel count

layout

"channels_first"

Array ordering

samples

number[][]

Shape (n_channels, sample_count)

samples[channel][index], not samples[index][channel]. Reading it the other way transposes the data silently and produces plausible-looking nonsense.

Stop and clean up

Stop the stream before unsubscribing, then shut the client down. The acquisition task lives in the bridge, so a stream left running keeps the device sampling after your process exits.

Drive several devices

Each device needs its own bridge process, because the stub holds one acquisition task per bridge. Give each client an instanceId and select the device through bridgeEnv:

Warning: Use bridgeEnv rather than process environment variables. The environment is shared, so on concurrent connects the second write reaches the bridge spawned for the first client and both end up on one device.

See Install and connect.

Next steps

Last updated

Was this helpful?