Skip to content

Commit

Permalink
Fixed a bug when comparing saved VT version with reported versions
Browse files Browse the repository at this point in the history
Fixed an incorrect warning that clients are not supported which arose from
incorrectly casting the stored version to report.
  • Loading branch information
ad3154 committed Dec 7, 2023
1 parent 6cf4ee8 commit 246d58b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/ServerMainComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class ServerMainComponent : public juce::Component
};
friend class LanguageCommandConfigClosed;

static VTVersion get_version_from_setting(std::uint8_t aVersion);

std::size_t number_of_iop_files_in_directory(std::filesystem::path path);

void on_change_active_mask_callback(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> affectedWorkingSet, std::uint16_t workingSet, std::uint16_t newMask);
Expand Down
38 changes: 37 additions & 1 deletion src/ServerMainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,42 @@ void ServerMainComponent::LanguageCommandConfigClosed::operator()(int result) co
mParent.popupMenu.reset();
}

ServerMainComponent::VTVersion ServerMainComponent::get_version_from_setting(std::uint8_t aVersion)
{
VTVersion retVal = VTVersion::Version2OrOlder;

switch (aVersion)
{
case 3:
{
retVal = VTVersion::Version3;
}
break;

case 4:
{
retVal = VTVersion::Version4;
}
break;

case 5:
{
retVal = VTVersion::Version5;
}
break;

case 6:
{
retVal = VTVersion::Version6;
}
break;

default:
break;
}
return retVal;
}

std::size_t ServerMainComponent::number_of_iop_files_in_directory(std::filesystem::path path)
{
std::size_t retVal = 0;
Expand Down Expand Up @@ -855,7 +891,7 @@ void ServerMainComponent::check_load_settings()
languageCommandInterface.set_commanded_volume_units(static_cast<isobus::LanguageCommandInterface::VolumeUnits>(int(firstChild.getProperty("VolumeUnits"))));
languageCommandInterface.set_country_code(String(firstChild.getProperty("CountryCode").toString()).toStdString());
languageCommandInterface.set_language_code(String(firstChild.getProperty("LanguageCode").toString()).toStdString());
versionToReport = static_cast<VTVersion>(int(secondChild.getProperty("Version")));
versionToReport = get_version_from_setting(static_cast<std::uint8_t>(static_cast<int>(secondChild.getProperty("Version"))));
}
}
}
Expand Down

0 comments on commit 246d58b

Please sign in to comment.