Matlab Call Nidaqmx
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Automation and integrations
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The matlab-call-nidaqmx skill provides a structured methodology for using the calldaqlib interface within MATLAB's Data Acquisition Toolbox. It enables users to access low-level NI-DAQmx functionality that is not natively exposed by the standard daq object, such as retriggerable acquisition, signal exporting, and advanced terminal routing. The skill covers essential projection rules, including handling implicit task handles, mapping output pointers to dictionary returns, and using string placeholders for buffer-based getters.
What it does
- Translates C-style NI-DAQmx function signatures into valid calldaqlib MATLAB syntax.
- Provides guidelines for handling string and array getters using appropriate buffer placeholders.
- Defines the use of empty daq objects for device-level API queries.
- Standardizes the use of string-based enum constants to prevent configuration errors.
- Offers a decision tree to determine when to use the daq object versus calldaqlib.
- Explains how to manage multi-task semantics and avoid start() clobbering.
When to use it
- When you need NI-DAQmx capabilities not covered by the standard daq object.
- When you are porting existing C or LabVIEW DAQmx code to MATLAB.
- When you need to perform driver-level diagnostics or terminal routing.
- When you must implement specific features like retriggerable acquisition or reference triggers.
Advantages
- Enables access to the full power of the NI-DAQmx driver within MATLAB.
- Reduces errors by enforcing string-based enum usage over raw integers.
- Provides clear patterns for complex C-to-MATLAB data type projections.
- Helps avoid common pitfalls like buffer size mismatches and task handle conflicts.
Usage examples
- “How do I set a retriggerable start trigger using calldaqlib?”
- Use calldaqlib(dq, 'DAQmxSetStartTrigRetriggerable', true) after configuring your trigger type.
- “How do I get the sample clock rate using calldaqlib?”
- Call result = calldaqlib(dq, 'DAQmxGetSampClkRate'); then access the value using result('Dev1_ai0').
- “How do I query if a device is simulated?”
- Create an empty daq object with dEmpty = daq('ni') and call calldaqlib(dEmpty, 'DAQmxGetDevIsSimulated', 'Dev1').
- “How do I read a string attribute like the sample clock source?”
- Use calldaqlib(dq, 'DAQmxGetSampClkSrc', '', 256) to pass the required empty string placeholder and buffer size.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/matlab/matlab-call-nidaqmx/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-call-nidaqmx.zip -d .agents/skills
Documentation by MathWorks
matlab-call-nidaqmx
Translate NI-DAQmx C signatures into correct calldaqlib MATLAB calls on
Data Acquisition Toolbox R2026a+.
When to Use
User explicitly mentions
calldaqlibor a specificDAQmx*C functionUser needs NI-DAQmx capability the daq object doesn't expose (retriggerable, export signal, reference triggers, enhanced alias rejection, digital filters)
User is debugging at the driver level (reading back what the NI driver holds)
User is translating existing C/LabVIEW code to MATLAB
When NOT to Use
User describes a capability achievable with the daq object alone (
dq.Rate,addtrigger,addclock,addinput,read,write,start,stop)User asks about the Session-based (legacy) DAQ interface
User needs
DAQmxCreateTaskorDAQmxLoadTask(these cannot work through calldaqlib — it owns task creation internally)
Decision Tree
Step 0 — Read the user's intent
Did the user explicitly mention calldaqlib or a specific DAQmx C function?
Yes — Write the calldaqlib call they asked for. Do NOT redirect to the daq object. They have a reason (driver debugging, matching C code, capability gap, learning). Skip to Step 2.
No — They described a capability without naming calldaqlib. Go to Step 1.
Step 1 — Pick the right tool
Can the daq object property/method do this? (dq.Rate, addtrigger,
addclock, addinput, dq.NumScansAvailable, etc.)
Yes — Recommend the daq object. Mention calldaqlib only if the user needs driver-level diagnostics or a capability outside daq object coverage.
No — Proceed to Step 2.
Step 2 — Device-level check
Does the C function lack a taskHandle parameter (device-level API)?
Functions like
DAQmxGetDevIsSimulated,DAQmxGetDevAISupportedMeasTypes: Use an empty daq object (no channels added). Pass the device name as an argument. Returns a plain scalar or array, not a dictionary.Functions like
DAQmxCreateTask,DAQmxLoadTask: These do not work through calldaqlib at all (calldaqlib owns task creation internally).Functions like
DAQmxConnectTerms,DAQmxDisconnectTerms: Use an empty daq object (same as device-level queries). These work on X-series devices.
Step 3 — Multi-task check
Does the daq object have multiple internal task handles (e.g., AI + DIO)?
Getters with a channel arg: The call runs on both tasks. The irrelevant task warns. Read the dictionary key you care about. Acceptable.
Setters targeting one measurement type: No scoping mechanism. Split into separate daq objects (loses synchronized start/stop).
Step 4 — Buffer placeholder check
Is this a getter returning a string or array?
String getter (
char *data, uInt32 bufferSizein C): Pass""thenbufferSize. Example:calldaqlib(dq, "DAQmxGetSampClkSrc", "", 256)Array getter (
int32 data[], uInt32 arraySizein C): Passzeros(1,N,'type')thenN. Example:calldaqlib(dq, "DAQmxGetDevAISupportedMeasTypes", "Dev1", zeros(1,32,'int32'), 32)
Step 5 — Enum check
Does any argument correspond to a C int32 enum slot?
Always use the string form:
"DAQmx_Val_RisingSlope"notint32(10280). Both work, but strings are self-documenting and prevent silent wrong-enum bugs.See
references/enum-constants.mdfor the 15 most-used enum names.
Call Forms
Six distinct patterns cover all calldaqlib usage:
1. Config (DAQmxCfg*)
dq = daq("ni");
addinput(dq, "Dev1", "ai0", "Voltage");
calldaqlib(dq, "DAQmxCfgSampClkTiming", "/Dev1/PFI0", 5000, ...
"DAQmx_Val_Rising", "DAQmx_Val_FiniteSamps", uint64(1000));2. Setter (DAQmxSet*)
calldaqlib(dq, "DAQmxSetStartTrigRetriggerable", true);3. Getter — scalar (DAQmxGet* returning numeric)
result = calldaqlib(dq, "DAQmxGetSampClkRate");
rate = result("Dev1_ai0");Returns a dictionary keyed by channel name — even on single-channel objects.
4. Getter — string (DAQmxGet* with char output)
result = calldaqlib(dq, "DAQmxGetSampClkSrc", "", 256);
source = result("Dev1_ai0");The "" is required as a placeholder for the char *data output slot.
bufferSize follows immediately. Use 256 for short names, 1024 for long paths.
5. Getter — array (DAQmxGet* with typed array output)
dEmpty = daq("ni");
result = calldaqlib(dEmpty, "DAQmxGetDevAISupportedMeasTypes", ...
"Dev1", zeros(1, 32, "int32"), 32);
measTypes = result(result ~= 0);Pre-allocate a typed buffer (zeros(1,N,'int32')) matching the C signature's
array type. Filter unused slots with result(result ~= 0).
6. Device-level (no taskHandle in C signature)
dEmpty = daq("ni");
isSim = calldaqlib(dEmpty, "DAQmxGetDevIsSimulated", "Dev1");Use an empty daq (no channels added). Pass device name as argument. Returns a plain scalar (not a dictionary).
Also works for terminal routing on X-series devices:
dEmpty = daq("ni");
calldaqlib(dEmpty, "DAQmxConnectTerms", "/Dev1/PFI0", "/Dev1/PFI1", "DAQmx_Val_DoNotInvertPolarity");
calldaqlib(dEmpty, "DAQmxDisconnectTerms", "/Dev1/PFI0", "/Dev1/PFI1");C-to-calldaqlib Translation
| C argument | calldaqlib equivalent |
|---|---|
TaskHandle taskHandle | Omit — daq object owns it |
const char source[] | MATLAB string "/Dev1/PFI0" |
float64 rate | MATLAB double |
int32 activeEdge (enum) | Enum name string "DAQmx_Val_Rising" |
uInt64 sampsPerChan | uint64(1000) |
bool32 data (input) | true / false |
float64 *data (output scalar) | Becomes return value (dictionary) |
int32 *data (output scalar) | Becomes return value (dictionary) |
char *data, uInt32 bufferSize (output pair) | Pass "" + bufferSize |
int32 data[], uInt32 arraySize (output array) | Pass zeros(1,N,'int32') + N |
| Any getter return | Always a dictionary keyed by DevN_chanName |
Hard Rules
taskHandle is implicit. The daq object owns it. Never pass it.
calldaqlib loops over every internal task. A daq with AI + DIO has 2 NI tasks; both get the call. For getters with a channel arg, ignore the warning from the irrelevant task and read the dictionary key you want. For setters targeting one measurement type, split into separate daq objects.
Output-pointer args still need a placeholder + bufferSize. String getters: pass
""before bufferSize. Array getters: passzeros(1,N,'type')before arraySize.start() clobbers calldaqlib-set rate and clock source.
start()reappliesdq.Rateto the driver. If you set rate viaDAQmxCfgSampClkTimingthen callstart(), it snaps back todq.Rate. Fix: setdq.Ratefirst, use calldaqlib only for parameters the daq object does not track. Alternative: useDAQmxStartTask/DAQmxStopTaskvia calldaqlib to bypass the daq object's commit pass entirely.Enum constants: use the string form.
"DAQmx_Val_RisingSlope"notint32(10280). Strings are readable and prevent wrong-enum bugs. The error on a bad string is misleading ("Value must be of type int32") — it means the string wasn't recognized, not that you should pass an int.Device-level APIs need an empty daq. Functions whose C signature has no
taskHandle(likeDAQmxGetDevIsSimulated,DAQmxGetDevAISupportedMeasTypes) work only when the daq object has no channels. CreatedEmpty = daq("ni")and pass the device name as an arg.DAQmxCreateTaskandDAQmxLoadTaskcannot work through calldaqlib. These functions create a new task — calldaqlib already owns task creation internally.DAQmxConnectTerms/DAQmxDisconnectTermsDO work via an empty daq object on X-series devices (same pattern as device-level queries).Property values are scalar. Passing a vector where a scalar is expected errors. To set the same property on multiple channels, loop.
Channel/device paths are not validated client-side. A bad path produces no error until
start().Trigger support is per-device. Not all devices support all trigger types. Error -200077 lists the supported enum values — read it.
All task-level getter results return a
dictionary. Keyed byDevN_chanName. Never expect a bare scalar. Useresult("Dev1_ai0")or iteratekeys(result).Buffer-size too small returns NI Error -200228. The error message includes "Required Buffer Size in Bytes: N" — parse it and retry with N. Heuristic: 256 for short names, 1024 for long paths/channel lists.
Array getters return a fixed-size buffer. Filter unused trailing zeros with
result(result ~= 0).
Conventions
Always set
dq.Ratebefore using calldaqlib for timing configAlways use enum name strings, never raw integers
Always expect a dictionary return from task-level getters
Always pass
""before bufferSize for string gettersAlways pre-allocate typed buffer for array getters
Use empty daq (no channels) for device-level queries
Warn about multi-task semantics in prose before the code block
Configure trigger type before enabling retriggerable mode
Retriggerable mode requires
DAQmx_Val_FiniteSamps— it does not work withContSampsUse specific getter function names (
DAQmxGetSampClkRate) not generic attribute getters (DAQmxGetTimingAttribute)
References
references/hot-signatures.md— 20 most-used calldaqlib signatures by categoryreferences/enum-constants.md— 15 DAQmx_Val_* enum name stringsreferences/common-mistakes.md— Mistakes from discovery trials and customer usage
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md10.5 KiB
- manifest.yaml428 B
- references/common-mistakes.md3.2 KiB
- references/enum-constants.md2.1 KiB
- references/hot-signatures.md3.2 KiB
ATTRIBUTION.md
Attribution
This folder is an unmodified copy of the Agent Skill "matlab-call-nidaqmx", distributed by AutoGineer (https://autogineer.com/agent-skills).
Commit: 2a7f215e965597acf6ed495beb9e7b8aff45a3be
Created by: MathWorks (https://github.com/matlab/matlab-agentic-toolkit/tree/2a7f215e965597acf6ed495beb9e7b8aff45a3be/skills-catalog/test-and-measurement/matlab-call-nidaqmx)
Publisher: MathWorks (https://github.com/matlab)
Licence: BSD 2-Clause License (https://github.com/matlab/matlab-agentic-toolkit/blob/2a7f215e965597acf6ed495beb9e7b8aff45a3be/LICENSE.md)
Licence evidence: repository licence LICENSE.md
Retrieved: 2026-11-07
The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.
Files added by AutoGineer
ATTRIBUTION.md: this file, written by AutoGineer
LICENSE: copied from LICENSE.md
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
The author says: >=R2026a
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/test-and-measurement/matlab-call-nidaqmx · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-call-nidaqmx.zip