Skip to content

Commit 08aa8cf

Browse files
committed
Fixed various start/stop issues
Fixed frame handlers being removed and not re-added after the hardware interface was stopped. Changed the order of how we manage working set activation to avoid a possible deadlock between the Juce message thread and the callback mutex. Fixed issue with windows executable not being packaged into installer. Fixed accidentally drawing timed-out working set icons. Clarified start instructions.
1 parent e49bb07 commit 08aa8cf

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,22 @@ if(MSVC)
117117
)
118118
endif()
119119

120+
if(APPLE)
120121
install(
121122
TARGETS AgISOVirtualTerminal
122123
RUNTIME
123124
DESTINATION bin
124125
BUNDLE DESTINATION .
125126
COMPONENT applications
126127
)
128+
else()
129+
install(
130+
TARGETS AgISOVirtualTerminal
131+
RUNTIME
132+
DESTINATION bin
133+
COMPONENT applications
134+
)
135+
endif()
127136

128137
if(MSVC)
129138
install(FILES ${CMAKE_CURRENT_LIST_DIR}/lib/Usbcan64.dll DESTINATION bin COMPONENT applications)

src/DataMaskRenderAreaComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void DataMaskRenderAreaComponent::paint(Graphics &g)
5757

5858
if (!hasStarted)
5959
{
60-
g.drawFittedText("To start the VT server, select \"start\" from the file menu in the top left.", 0, 440, 400, 40, Justification::centredTop, 2);
60+
g.drawFittedText("To start the VT server, select \"Start/Stop\" from the control menu in the top left.", 0, 440, 400, 40, Justification::centredTop, 2);
6161
}
6262
}
6363
}

src/ServerMainComponent.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,6 @@ void ServerMainComponent::timerCallback()
406406
{
407407
ws->join_parsing_thread();
408408

409-
if (ws->get_was_object_pool_loaded_from_non_volatile_memory())
410-
{
411-
send_load_version_response(0, ws->get_control_function());
412-
}
413-
else
414-
{
415-
send_end_of_object_pool_response(true, isobus::NULL_OBJECT_ID, isobus::NULL_OBJECT_ID, 0, ws->get_control_function());
416-
}
417409
workingSetSelector.update_drawn_working_sets(managedWorkingSetList);
418410

419411
auto workingSetObject = std::static_pointer_cast<isobus::WorkingSet>(ws->get_working_set_object());
@@ -424,6 +416,15 @@ void ServerMainComponent::timerCallback()
424416
ws->set_working_set_maintenance_message_timestamp_ms(isobus::SystemTiming::get_timestamp_ms());
425417
change_selected_working_set(0);
426418
}
419+
420+
if (ws->get_was_object_pool_loaded_from_non_volatile_memory())
421+
{
422+
send_load_version_response(0, ws->get_control_function());
423+
}
424+
else
425+
{
426+
send_end_of_object_pool_response(true, isobus::NULL_OBJECT_ID, isobus::NULL_OBJECT_ID, 0, ws->get_control_function());
427+
}
427428
}
428429
else if (isobus::VirtualTerminalServerManagedWorkingSet::ObjectPoolProcessingThreadState::Fail == ws->get_object_pool_processing_state())
429430
{
@@ -787,7 +788,29 @@ bool ServerMainComponent::perform(const InvocationInfo &info)
787788
if (hasStartBeenCalled)
788789
{
789790
isobus::CANStackLogger::info("Stopping CAN interface");
791+
792+
// Save the frame handlers so we can re-add them after stopping the interface
793+
#ifdef JUCE_WINDOWS
794+
auto canDriver0 = isobus::CANHardwareInterface::get_assigned_can_channel_frame_handler(0);
795+
auto canDriver1 = isobus::CANHardwareInterface::get_assigned_can_channel_frame_handler(1);
796+
auto canDriver2 = isobus::CANHardwareInterface::get_assigned_can_channel_frame_handler(2);
797+
auto canDriver3 = isobus::CANHardwareInterface::get_assigned_can_channel_frame_handler(3);
798+
#else
799+
auto canDriver = isobus::CANHardwareInterface::get_assigned_can_channel_frame_handler(0);
800+
#endif
801+
790802
isobus::CANHardwareInterface::stop();
803+
804+
// Since "Stop" clears all frame handlers, we need to re-add the ones we saved
805+
#ifdef JUCE_WINDOWS
806+
isobus::CANHardwareInterface::assign_can_channel_frame_handler(0, canDriver0);
807+
isobus::CANHardwareInterface::assign_can_channel_frame_handler(1, canDriver1);
808+
isobus::CANHardwareInterface::assign_can_channel_frame_handler(2, canDriver2);
809+
isobus::CANHardwareInterface::assign_can_channel_frame_handler(3, canDriver3);
810+
#else
811+
isobus::CANHardwareInterface::assign_can_channel_frame_handler(0, canDriver);
812+
#endif
813+
791814
dataMaskRenderer.set_has_started(false);
792815
hasStartBeenCalled = false;
793816
}

src/WorkingSetSelectorComponent.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "WorkingSetSelectorComponent.hpp"
77
#include "JuceManagedWorkingSetCache.hpp"
88
#include "ServerMainComponent.hpp"
9+
#include "isobus/utility/system_timing.hpp"
910

1011
WorkingSetSelectorComponent::WorkingSetSelectorComponent(ServerMainComponent &server) :
1112
parentServer(server)
@@ -22,7 +23,8 @@ void WorkingSetSelectorComponent::update_drawn_working_sets(std::vector<std::sha
2223
{
2324
children.push_back({ managedWorkingSetList.at(i) });
2425

25-
if (isobus::VirtualTerminalServerManagedWorkingSet::ObjectPoolProcessingThreadState::Joined == managedWorkingSetList.at(i)->get_object_pool_processing_state())
26+
if ((isobus::VirtualTerminalServerManagedWorkingSet::ObjectPoolProcessingThreadState::Joined == managedWorkingSetList.at(i)->get_object_pool_processing_state()) &&
27+
(!isobus::SystemTiming::time_expired_ms(managedWorkingSetList.at(i)->get_working_set_maintenance_message_timestamp_ms(), 3000)))
2628
{
2729
auto workingSetObject = managedWorkingSetList.at(i)->get_working_set_object();
2830

0 commit comments

Comments
 (0)