How do I implement installation of the NI-DAQmx support package in a compiled application?

5 visualizaciones (últimos 30 días)
I am working in MATLAB 2022b and am trying to build an application that uses a USB-6501 National Instruments DAQ. As expected, everything worked on my development computer, but then didn't work on the deployment computer. I ended up just installing MATLAB on the deployment computer and installing the NI-DAQmx support package, but how would I install the support package through the compiled application?
Things that I've tried:
  • Selecting the support package in the Application Compiler - That support package isn't listed.
  • Attempted to add files per this answer - The "daq" folder is in the MATLAB root folder and can't be added, and there is no NI-DAQmx folder in the Add-Ons folder

Respuestas (1)

Steven Lord
Steven Lord el 11 de Jul. de 2023
Based on this page and given what you said in your first bullet, that the support package isn't listed in Application Compiler, I wonder if one of the criteria listed on that page is not satisfied.
  • the support package is installed
  • your code has a direct dependency on the support package
  • your code is dependent on the base product of the support package
  • your code is dependent on at least one of the files listed as a dependency in the mcc.xml file of the support package, and the base product of the support package is MATLAB
Are you trying to load an object that uses the support package in your application, without having any direct and obvious (to the dependency analyzer) calls to support package functionality? [That's the second bullet above.] If so I'd probably try to use one of the workarounds in the "Fixing Callback Problems: Missing Functions" section of this documentation page, as this workflow is described by the Tip in that section of that documentation page.
If that doesn't work, as a diagnostic step to try to determine if this is a problem with the dependency analysis or with the support package, can you try the command line compilation command (the last section on the page to which I linked in my first sentence) with the support package you're trying to include explicitly added using the -a option?
  2 comentarios
Brian
Brian el 11 de Jul. de 2023
I can definitely rule out your first bullet, and can likely rule out the second (since the application didn't work when it wasn't installed, but worked without changing anything once I installed the support package). I can also rule out bullet three based on the output of "matlab.codetools.requiredFilesAndProducts" including the Data Acquisition Toolbox.
As for the fourth bullet, where could I find the mcc.xml file of the support package? The functions I'm using (generally) are...
daqreset % Reset the DAQ Toolbox to account for recent connections
pause(1)
devList=daqlist;
myDAQ=daq("ni");
addoutput(myDAQ,devList.DeviceID(strcmp(devList.Model,'USB-6501')),'port0/line0',"Digital")
write(myDAQ,0)
Brian
Brian el 13 de Jul. de 2023
After some testing, it seems that the -a option works:
-a C:\ProgramData\MATLAB\SupportPackages\R2022b\toolbox\daq\supportpackages\nidaq
Note that this also requires installing the driver "separately". I added the ni-daqmx_21.3_online.exe in the "Files installed for your end user" section of the deploy tool, and then added the below block in my startup function.
verInfo=ver;
MatRelease=verInfo(strcmp({verInfo.Name},'MATLAB')).Release;
venList=daqvendorlist;
if ~any(strcmp(venList.ID,'ni'))
uialert(app.UIFigure,'NI Driver not installed.','','Icon','error')
end
niInfo=venList(strcmp(venList.ID,'ni'),:);
if ~contains(niInfo.DriverVersion,'21.3.0 NI-DAQmx')
pauseHere=uiconfirm(app.UIFigure,'Incorrect version of NI Driver installed. Closing app and installing driver. Please restart the computer when complete.','','Icon','warning'); %#ok<NASGU>
[~, result] = system('path');
p = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
system([fullfile(p,'ni-daqmx_21.3_online.exe') ' &'])
delete(app)
end
if ~contains(niInfo.AdaptorVersion,MatRelease)
uialert(app.UIFigure,'Outdated version of NI Adaptor installed.','','Icon','error')
end

Iniciar sesión para comentar.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by