Skip to content

Commit

Permalink
Fix issue with remote FMs sending live data too often, still 3.5.0-rc.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Apr 9, 2024
1 parent 657b157 commit 079adb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/FilamentMonitors/FilamentMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static uint32_t checkCalls = 0, clearCalls = 0; //TEMP DEBUG
size_t slotIndex = 0;
size_t firstDriveNotSent = NumDirectDrivers;
Bitmap<uint32_t> driversReported;
bool forceSend = false;
bool forceSend = false, haveLiveData = false;
#endif

{
Expand Down Expand Up @@ -363,11 +363,15 @@ static uint32_t checkCalls = 0, clearCalls = 0; //TEMP DEBUG
auto& slot = msg->data[slotIndex];
slot.status = fst.ToBaseType();
fs.GetLiveData(slot);
if (fst != fs.lastStatus || slot.hasLiveData)
if (fst != fs.lastStatus)
{
forceSend = true;
fs.lastStatus = fst;
}
else if (slot.hasLiveData)
{
haveLiveData = true;
}
driversReported.SetBit(drv);
++slotIndex;
}
Expand Down Expand Up @@ -409,7 +413,14 @@ static uint32_t checkCalls = 0, clearCalls = 0; //TEMP DEBUG
#if SUPPORT_REMOTE_COMMANDS
if (CanInterface::InExpansionMode())
{
if (slotIndex != 0 && (forceSend || millis() - whenStatusLastSent >= StatusUpdateInterval))
uint32_t now;
if ( slotIndex != 0
&& ( forceSend
|| (now = millis()) - whenStatusLastSent >= StatusUpdateInterval
|| (haveLiveData && now - whenStatusLastSent >= LiveStatusUpdateInterval)

)
)
{
msg->SetStandardFields(driversReported);
buf.dataLength = msg->GetActualDataLength();
Expand Down
1 change: 1 addition & 0 deletions src/FilamentMonitors/FilamentMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class FilamentMonitor INHERIT_OBJECT_MODEL

#if SUPPORT_REMOTE_COMMANDS
static constexpr uint32_t StatusUpdateInterval = 2000; // how often we send status reports when there isn't a change
static constexpr uint32_t LiveStatusUpdateInterval = 250; // how often we report live status
static uint32_t whenStatusLastSent;
static size_t firstDriveToSend;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/RepRap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@ size_t RepRap::GetStatusIndex() const noexcept
: (gCodes->IsCancellingPrint()) ? 7 // Cancelling
: (printMonitor->IsPrinting())
? ((gCodes->IsSimulating()) ? 8 // Simulating
: 9 // Printing
: 9 // Printing
)
: (gCodes->IsDoingToolChange()) ? 10 // Changing tool
: (gCodes->DoingFileMacro() || !move->NoLiveMovement() ||
Expand Down

0 comments on commit 079adb7

Please sign in to comment.