Skip to content

Commit

Permalink
Fixed an error that sets NDDSHOME to an usupported version of Connext…
Browse files Browse the repository at this point in the history
… if a newer version was installed
  • Loading branch information
angelrti committed Apr 12, 2023
1 parent 717bef8 commit 9db43de
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions configure_nddshome.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ function configure_nddshome_w_version(version, supportedVersions)
connextPath = get_rti_connext_dds_path(version);

nddshomePath = string(getenv("NDDSHOME"));
printWarningSupportedVersion = false;

% Create string with supported versions of Connext.
productSupportedVersions = "";
for i = 1:length(supportedVersions)
productSupportedVersions = productSupportedVersions +...
" - RTI Connext DDS " + supportedVersions{i};
if i ~= length(supportedVersions)
productSupportedVersions =...
productSupportedVersions + newline;
end
end

% If NDDSHOME is already set, check it points to a supported version
if nddshomePath ~= ""
if is_rti_connext_dds_version_supported(nddshomePath,...
supportedVersions) == false
% NDDSHOME is not set to a supported version. In case it is set
% to a supported version, do not set it again to the RTI
% Connext for DDS Blockset toolbox
productSupportedVersions = "";
for i = 1:length(supportedVersions)
productSupportedVersions = productSupportedVersions +...
" - RTI Connext DDS " + supportedVersions{i};
if i ~= length(supportedVersions)
productSupportedVersions =...
productSupportedVersions + newline;
end
end

warning(['NDDSHOME environment variable is not set ',...
'to a supported version for MATLAB/DDS Blockset. ',...
'Supported Connext versions for MATLAB %s:\n',...
warning(['NDDSHOME environment variable is not set to a supported ' ...
'version for MATLAB/DDS Blockset. Supported Connext versions ' ...
'for MATLAB %s:' newline ...
'%s'],...
matlabRelease.Release,...
productSupportedVersions);
Expand All @@ -63,23 +63,34 @@ function configure_nddshome_w_version(version, supportedVersions)
% Set NDDSHOME to the latest installed RTI Connext for DDS Blockset
% toolbox
if exist(connextPath, "dir")
setenv("NDDSHOME", connextPath);
if is_rti_connext_dds_version_supported(connextPath,...
supportedVersions) == false
warning(['The Connext Toolbox for DDS Blockset version %s ' ...
'is not supported. Supported Connext versions ' ...
'for MATLAB %s:' newline ...
'%s'],...
version,...
matlabRelease.Release,...
productSupportedVersions);
else
setenv("NDDSHOME", connextPath);
end
else
error("Error setting NDDSHOME, the path <%s> doesn't exist",...
connextPath);
end
end
end

function ok = is_rti_connext_dds_version_supported(nddshome, supported_versions)
function ok = is_rti_connext_dds_version_supported(nddshome, supportedVersions)
% IS_RTI_CONNEXT_DDS_VERSION_SUPPORTED check whether the current
% nddshome is pointing to a supported version
% is_rti_connext_dds_version_supported() return true if that nddshome
% is supported

ok = false;
for i = 1:length(supported_versions)
if contains(nddshome, strcat('rti_connext_dds-',supported_versions{i}))
for i = 1:length(supportedVersions)
if contains(nddshome, strcat('rti_connext_dds-',supportedVersions{i}))
ok = true;
end
end
Expand All @@ -104,4 +115,4 @@ function configure_nddshome_w_version(version, supportedVersions)
else
error('Unsupported OS');
end
end
end

0 comments on commit 9db43de

Please sign in to comment.