From 114c1e374cf818b9bf26cc4a603a66b2c8c54134 Mon Sep 17 00:00:00 2001
From: marcofilho <marco.filho@ess.eu>
Date: Fri, 15 Nov 2024 16:30:00 +0100
Subject: [PATCH] Add checking for ring integrity

If check is not made, ioc will try to write to register in the beginning and fail, crashing the application.
---
 vmmTblApp/src/vmm_tbl.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/vmmTblApp/src/vmm_tbl.cpp b/vmmTblApp/src/vmm_tbl.cpp
index e460bbf..1274a9a 100644
--- a/vmmTblApp/src/vmm_tbl.cpp
+++ b/vmmTblApp/src/vmm_tbl.cpp
@@ -20,12 +20,14 @@ VMMTbl::VMMTbl(RMM* rmm, const char *FENPortName, int ring, int node, int hybrid
   createEpicsParams();
   setInitialEpicsParams();
   rmm->updateTopologyPvs(ring, node, "vmmTbl");
-  for (int hyb = 0; hyb < number_hybrids; hyb++) {
-    pVmmTblAPI->enableHybrid(hyb, true);
-    setStringParam(vmmHybFwVersion_[hyb], pVmmTblAPI->readFwVersion(hyb).c_str());
-    setStringParam(vmmHybId_[hyb], pVmmTblAPI->readIDChip(hyb).c_str());
-    setStringParam(vmmHybGeoPos_[hyb], pVmmTblAPI->readGeoPos(hyb).c_str());
-    setIntegerParam(vmmHybLinkStatus_[hyb], std::stoi(pVmmTblAPI->checkLinkStatus(hyb)));
+  if (rmm->getRMMAPI()->checkRings() == rmmSuccess) {
+    for (int hyb = 0; hyb < number_hybrids; hyb++) {
+      pVmmTblAPI->enableHybrid(hyb, true);
+      setStringParam(vmmHybFwVersion_[hyb], pVmmTblAPI->readFwVersion(hyb).c_str());
+      setStringParam(vmmHybId_[hyb], pVmmTblAPI->readIDChip(hyb).c_str());
+      setStringParam(vmmHybGeoPos_[hyb], pVmmTblAPI->readGeoPos(hyb).c_str());
+      setIntegerParam(vmmHybLinkStatus_[hyb], std::stoi(pVmmTblAPI->checkLinkStatus(hyb)));
+  }
   }
 }
 
-- 
GitLab