Browse Source

Sensor behind a network gateway: wait 3 s per attempt instead of 1 s

A 2D sensor waited 10 x 100 ms (LGS_DEFAULT_TO_COUNTER) for each reply,
which is a local serial-line value. Through an Ethernet to serial gateway
on a mobile link the round trip is longer at times.

- basicTransport::isNetworkLink() (false by default). deviceETH2UART
  returns true.
- deviceNodeSensor::m_nTOCounterBase is the wait per attempt.
  device2DSensor sets it when it binds to its port:
  LGS_NETWORK_TO_COUNTER (30 = 3 s) for a network link,
  LGS_DEFAULT_TO_COUNTER (1 s) for a local serial port, which is unchanged.
  All 2D waits use it, including the longer x4 / x16 waits of the
  detection profile and mask commands. waitStateFunction() re-arms the
  retry with it.
- E2UART_REPLY_TIMEOUT_MS 800 -> 2500 ms, below the sensor's 3 s, so the
  gateway's I/O thread waits for the reply before sending the next request.

Tested with the fake device: replies after 300 ms (split), 1200 ms and
2000 ms (split) all reach their own request within the 3 s wait (ASan clean).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/24/head
Claude 5 hours ago
parent
commit
85ca06a8a2
Failed to extract signature
  1. 127
      lib/App/common/deviceNode2D.cpp
  2. 6
      lib/App/common/deviceNodeEthernet2Serial.h
  3. 4
      lib/App/common/deviceNodeSensor.cpp
  4. 6
      lib/App/common/deviceNodeSensor.h
  5. 6
      lib/components/base/basicTransport.h

127
lib/App/common/deviceNode2D.cpp

@ -76,7 +76,7 @@ void device2DSensor::cleanupDeviceStructures(void)
LOG("Clean Basic Structures!"); LOG("Clean Basic Structures!");
#endif #endif
// m_eCurrentSequence = NO_SEQUENCE; // m_eCurrentSequence = NO_SEQUENCE;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bInitialFlips = LGS_INITIAL_FLIPS; m_bInitialFlips = LGS_INITIAL_FLIPS;
m_nCurrentAngle = 0; m_nCurrentAngle = 0;
m_bDrawType = 0; m_bDrawType = 0;
@ -287,6 +287,9 @@ void device2DSensor::connectMode()
sprintf(tB, "PortOBJ: %p", m_pPort); sprintf(tB, "PortOBJ: %p", m_pPort);
LOG(tB); LOG(tB);
#endif #endif
// Through a network gateway the replies take longer: wait longer per attempt
m_nTOCounterBase = (m_pPort != NULL && m_pPort->isNetworkLink()) ? LGS_NETWORK_TO_COUNTER : LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (m_pPort == NULL || ! setTransport(m_pPort, false)) if (m_pPort == NULL || ! setTransport(m_pPort, false))
{ {
LOG_ERROR("Binding Port Failure!"); LOG_ERROR("Binding Port Failure!");
@ -329,7 +332,7 @@ void device2DSensor::connectMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
cleanupDeviceStructures(); cleanupDeviceStructures();
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
@ -375,7 +378,7 @@ void device2DSensor::handshakeMode()
{ {
if (m_bActualDeviceWM != MODE_DETECTOR) if (m_bActualDeviceWM != MODE_DETECTOR)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
{ {
@ -396,7 +399,7 @@ void device2DSensor::handshakeMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getSerialNumber()) if (! getSerialNumber())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -410,7 +413,7 @@ void device2DSensor::handshakeMode()
}; };
case LRF_WS_STAGE_2: case LRF_WS_STAGE_2:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getVersionString()) if (! getVersionString())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -461,7 +464,7 @@ void device2DSensor::readMode()
case LRF_WS_INIT: case LRF_WS_INIT:
{ {
LOG("TryProfiles"); LOG("TryProfiles");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getDetectionProfile()) if (! getDetectionProfile())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -476,7 +479,7 @@ void device2DSensor::readMode()
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
LOG("Get ParamMaster"); LOG("Get ParamMaster");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getParameters(true)) if (! getParameters(true))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -493,7 +496,7 @@ void device2DSensor::readMode()
LOG("Get ParamSlave"); LOG("Get ParamSlave");
if (m_sNodeData.type == ARGUS_ALS_SENSOR) if (m_sNodeData.type == ARGUS_ALS_SENSOR)
{ // Read Slave Just for ALS series { // Read Slave Just for ALS series
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getParameters(false)) if (! getParameters(false))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -513,7 +516,7 @@ void device2DSensor::readMode()
case LRF_WS_STAGE_3: case LRF_WS_STAGE_3:
{ {
LOG("Get RELAY"); LOG("Get RELAY");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getRelayParameters()) if (! getRelayParameters())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -528,7 +531,7 @@ void device2DSensor::readMode()
case LRF_WS_STAGE_4: case LRF_WS_STAGE_4:
{ {
LOG("Get WidthTable"); LOG("Get WidthTable");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getWidthTable()) if (! getWidthTable())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -543,7 +546,7 @@ void device2DSensor::readMode()
case LRF_WS_STAGE_5: case LRF_WS_STAGE_5:
{ {
LOG("Get ShadowInfo"); LOG("Get ShadowInfo");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getShadowInfo(m_sShadowHelper.m_bSequence)) if (! getShadowInfo(m_sShadowHelper.m_bSequence))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -561,7 +564,7 @@ void device2DSensor::readMode()
// Have Info -> If No Poly - Skeep to go get DC // Have Info -> If No Poly - Skeep to go get DC
if (m_sShadow.pPolygones) if (m_sShadow.pPolygones)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getShadowPoly(m_sShadowHelper.m_bSequence, m_sShadowHelper.m_nCurrentPolygon)) if (! getShadowPoly(m_sShadowHelper.m_bSequence, m_sShadowHelper.m_nCurrentPolygon))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -585,7 +588,7 @@ void device2DSensor::readMode()
{ {
if (m_sShadowHelper.m_nCurrentPoint < m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount) if (m_sShadowHelper.m_nCurrentPoint < m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getShadowPolyPoint(m_sShadowHelper.m_bSequence, m_sShadowHelper.m_nCurrentPolygon, m_sShadowHelper.m_nCurrentPoint)) if (! getShadowPolyPoint(m_sShadowHelper.m_bSequence, m_sShadowHelper.m_nCurrentPolygon, m_sShadowHelper.m_nCurrentPoint))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -650,7 +653,7 @@ bool device2DSensor::reset(){
setWM(LRF_WM_CONNECTION); setWM(LRF_WM_CONNECTION);
return false; return false;
} else { } else {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
updateDataStatus(ARGUS_DS_BUSY); updateDataStatus(ARGUS_DS_BUSY);
DELAY_10MS(1); // 10 ms DELAY_10MS(1); // 10 ms
}; };
@ -817,7 +820,7 @@ void device2DSensor::syncMode()
if (m_bActualDeviceWM != MODE_MASK) if (m_bActualDeviceWM != MODE_MASK)
{ {
LOG("Set Mask Mode"); LOG("Set Mask Mode");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_MASK; m_bRequestedDeviceWM = MODE_MASK;
if (! setMode(MODE_MASK)) if (! setMode(MODE_MASK))
{ {
@ -849,10 +852,10 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (m_bActualDeviceWM != MODE_MASK) if (m_bActualDeviceWM != MODE_MASK)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_MASK; m_bRequestedDeviceWM = MODE_MASK;
if (! setMode(MODE_MASK)) if (! setMode(MODE_MASK))
{ {
@ -872,7 +875,7 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_2: case LRF_WS_STAGE_2:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setShadowInfo(m_sShadowHelper.m_bSequence, m_sShadow)) if (! setShadowInfo(m_sShadowHelper.m_bSequence, m_sShadow))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -889,7 +892,7 @@ void device2DSensor::syncMode()
if (m_sShadowHelper.m_nCurrentPolygon < m_sShadow.m_nPolygonCount) if (m_sShadowHelper.m_nCurrentPolygon < m_sShadow.m_nPolygonCount)
{ {
m_sShadowHelper.m_nCurrentPoint = 0; m_sShadowHelper.m_nCurrentPoint = 0;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setShadowPoly(m_sShadowHelper.m_bSequence, m_sShadow, m_sShadowHelper.m_nCurrentPolygon)) if (! setShadowPoly(m_sShadowHelper.m_bSequence, m_sShadow, m_sShadowHelper.m_nCurrentPolygon))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -924,7 +927,7 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_4: case LRF_WS_STAGE_4:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Point %d of %d", m_sShadowHelper.m_nCurrentPoint + 1, m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount); sprintf(tBuff, "Send Point %d of %d", m_sShadowHelper.m_nCurrentPoint + 1, m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount);
@ -933,7 +936,7 @@ void device2DSensor::syncMode()
if (m_sShadowHelper.m_nCurrentPoint < m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount) if (m_sShadowHelper.m_nCurrentPoint < m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount)
{ {
LOG("Senfing Point"); LOG("Senfing Point");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setShadowPolyPoint(m_sShadowHelper.m_bSequence, m_sShadow, m_sShadowHelper.m_nCurrentPolygon, m_sShadowHelper.m_nCurrentPoint)) if (! setShadowPolyPoint(m_sShadowHelper.m_bSequence, m_sShadow, m_sShadowHelper.m_nCurrentPolygon, m_sShadowHelper.m_nCurrentPoint))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -954,7 +957,7 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_5: case LRF_WS_STAGE_5:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Shadow for angle %d [%d rays]", m_sShadowHelper.m_nCurrentRayLine, m_sShadow.ray_lines[m_sShadowHelper.m_nCurrentRayLine].nCount); sprintf(tBuff, "Send Shadow for angle %d [%d rays]", m_sShadowHelper.m_nCurrentRayLine, m_sShadow.ray_lines[m_sShadowHelper.m_nCurrentRayLine].nCount);
@ -973,7 +976,7 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_6: case LRF_WS_STAGE_6:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Shadow RayLine %d for angle %d", m_sShadowHelper.m_nCurrentRay, m_sShadowHelper.m_nCurrentRayLine); sprintf(tBuff, "Send Shadow RayLine %d for angle %d", m_sShadowHelper.m_nCurrentRay, m_sShadowHelper.m_nCurrentRayLine);
@ -1012,7 +1015,7 @@ void device2DSensor::syncMode()
}; };
case LRF_WS_STAGE_7: case LRF_WS_STAGE_7:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setShadowDone(m_sShadowHelper.m_bSequence)) if (! setShadowDone(m_sShadowHelper.m_bSequence))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1050,7 +1053,7 @@ void device2DSensor::syncMode()
PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, true); PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, true);
if (tData) if (tData)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER << 2;
m_bTimeOutCounter = m_nTOCounterBase << 2;
if (! setParameters(tData, true, m_nActiveDetectionProfile)) if (! setParameters(tData, true, m_nActiveDetectionProfile))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1075,7 +1078,7 @@ void device2DSensor::syncMode()
PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, false); PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, false);
if (tData) if (tData)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER << 2;
m_bTimeOutCounter = m_nTOCounterBase << 2;
if (! setParameters(tData, false, m_nActiveDetectionProfile)) if (! setParameters(tData, false, m_nActiveDetectionProfile))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1253,7 +1256,7 @@ void device2DSensor::save_ini()
// ANODE_WM_2D_SET_GETFILE_MODE // ANODE_WM_2D_SET_GETFILE_MODE
if (m_bActualDeviceWM != MODE_GETFILE) if (m_bActualDeviceWM != MODE_GETFILE)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_GETFILE; m_bRequestedDeviceWM = MODE_GETFILE;
if (! setMode(MODE_GETFILE)) if (! setMode(MODE_GETFILE))
{ {
@ -1385,7 +1388,7 @@ void device2DSensor::save_ini()
break; break;
}; };
}; };
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! sendGF_package(m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state | m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index, m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data_size, if (! sendGF_package(m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state | m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index, m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data_size,
m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data)) m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data))
{ {
@ -1424,7 +1427,7 @@ void device2DSensor::save_ini()
case LRF_WS_STAGE_4: case LRF_WS_STAGE_4:
{ {
// Issue Full Reset // Issue Full Reset
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! doFullReset()) if (! doFullReset())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1520,7 +1523,7 @@ void device2DSensor::save_detection()
PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, true); PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, true);
if (tData) if (tData)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setParameters(tData, true, m_nActiveDetectionProfile)) if (! setParameters(tData, true, m_nActiveDetectionProfile))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1546,7 +1549,7 @@ void device2DSensor::save_detection()
PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, false); PLGS_2D_PARAMETERS tData = m_pDBC->getLRFDetectionProfile(m_sNodeData.aux_id, m_nActiveDetectionProfile, false);
if (tData) if (tData)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setParameters(tData, false, m_nActiveDetectionProfile)) if (! setParameters(tData, false, m_nActiveDetectionProfile))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1605,7 +1608,7 @@ void device2DSensor::wait_device()
{ {
case LRF_WS_INIT: case LRF_WS_INIT:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getState()) if (! getState())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -1760,10 +1763,10 @@ void device2DSensor::save_masks()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (m_bActualDeviceWM != MODE_MASK) if (m_bActualDeviceWM != MODE_MASK)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_MASK; m_bRequestedDeviceWM = MODE_MASK;
if (! setMode(MODE_MASK)) if (! setMode(MODE_MASK))
{ {
@ -1783,7 +1786,7 @@ void device2DSensor::save_masks()
}; };
case LRF_WS_STAGE_2: case LRF_WS_STAGE_2:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
char tB[129]; char tB[129];
sprintf(tB, "Masks Status: 0x%08X", m_sShadow.m_nEnabled); sprintf(tB, "Masks Status: 0x%08X", m_sShadow.m_nEnabled);
@ -1803,7 +1806,7 @@ void device2DSensor::save_masks()
// V 3 4 ... B 5 6 .. E 7 // V 3 4 ... B 5 6 .. E 7
case LRF_WS_STAGE_5: case LRF_WS_STAGE_5:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (m_sShadowHelper.m_nCurrentPolygon < m_sShadow.m_nPolygonCount) if (m_sShadowHelper.m_nCurrentPolygon < m_sShadow.m_nPolygonCount)
{ {
m_sShadowHelper.m_nCurrentPoint = 0; m_sShadowHelper.m_nCurrentPoint = 0;
@ -1846,7 +1849,7 @@ void device2DSensor::save_masks()
}; };
case LRF_WS_STAGE_6: case LRF_WS_STAGE_6:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Point %d of %d", m_sShadowHelper.m_nCurrentPoint + 1, m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount); sprintf(tBuff, "Send Point %d of %d", m_sShadowHelper.m_nCurrentPoint + 1, m_sShadow.pPolygones[m_sShadowHelper.m_nCurrentPolygon].wCount);
@ -1874,7 +1877,7 @@ void device2DSensor::save_masks()
case LRF_WS_STAGE_3: case LRF_WS_STAGE_3:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Shadow for angle %d [%d rays]", m_sShadowHelper.m_nCurrentRayLine, m_sShadow.ray_lines[m_sShadowHelper.m_nCurrentRayLine].nCount); sprintf(tBuff, "Send Shadow for angle %d [%d rays]", m_sShadowHelper.m_nCurrentRayLine, m_sShadow.ray_lines[m_sShadowHelper.m_nCurrentRayLine].nCount);
@ -1893,7 +1896,7 @@ void device2DSensor::save_masks()
}; };
case LRF_WS_STAGE_4: case LRF_WS_STAGE_4:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tBuff[128]; char tBuff[128];
sprintf(tBuff, "Send Shadow RayLine %d for andle %d", m_sShadowHelper.m_nCurrentRay, m_sShadowHelper.m_nCurrentRayLine); sprintf(tBuff, "Send Shadow RayLine %d for andle %d", m_sShadowHelper.m_nCurrentRay, m_sShadowHelper.m_nCurrentRayLine);
@ -1933,7 +1936,7 @@ void device2DSensor::save_masks()
}; };
case LRF_WS_STAGE_7: case LRF_WS_STAGE_7:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! setShadowDone(m_sShadowHelper.m_bSequence)) if (! setShadowDone(m_sShadowHelper.m_bSequence))
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -2033,7 +2036,7 @@ void device2DSensor::fileTransferSpecialWait()
LOG("ATTEMPT RECOVER"); LOG("ATTEMPT RECOVER");
#endif #endif
m_bOpRetryCnt--; m_bOpRetryCnt--;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
registerCommError(false); registerCommError(false);
m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state |= GF_ERRORMODE; m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state |= GF_ERRORMODE;
} }
@ -2081,7 +2084,7 @@ void device2DSensor::fileTransferMode()
{ {
if (m_bActualDeviceWM != MODE_GETFILE) if (m_bActualDeviceWM != MODE_GETFILE)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_GETFILE; m_bRequestedDeviceWM = MODE_GETFILE;
if (! setMode(MODE_GETFILE)) if (! setMode(MODE_GETFILE))
{ {
@ -2211,7 +2214,7 @@ void device2DSensor::fileTransferMode()
{ {
m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state &= (~GF_ERRORMODE); m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state &= (~GF_ERRORMODE);
}; };
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
char tB[256]; char tB[256];
sprintf(tB, "Current Index: %d", m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index); sprintf(tB, "Current Index: %d", m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index);
LOG(tB); LOG(tB);
@ -2256,7 +2259,7 @@ void device2DSensor::fileTransferMode()
if (m_sGetFileTransfers.transfer_ending_mode == GF_EM_ISSUE_RESET) if (m_sGetFileTransfers.transfer_ending_mode == GF_EM_ISSUE_RESET)
{ {
LOG("Must Issue Reset"); LOG("Must Issue Reset");
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! doFullReset()) if (! doFullReset())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -2307,7 +2310,7 @@ void device2DSensor::getfileMode()
case LRF_WS_INIT:{ case LRF_WS_INIT:{
m_nCurrentAngle = 0; m_nCurrentAngle = 0;
if ( m_bActualDeviceWM != MODE_GETFILE ) { if ( m_bActualDeviceWM != MODE_GETFILE ) {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_GETFILE; m_bRequestedDeviceWM = MODE_GETFILE;
if( !setMode( MODE_GETFILE ) ) { if( !setMode( MODE_GETFILE ) ) {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -2428,7 +2431,7 @@ void device2DSensor::getfileMode()
break; break;
}; };
}; };
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if( !sendGF_package( if( !sendGF_package(
( m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state | m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index ), ( m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->state | m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->index ),
m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data_size, m_sGetFileTransfers.helpers[m_sGetFileTransfers.current]->data_size,
@ -2459,7 +2462,7 @@ void device2DSensor::getfileMode()
if( m_bOpRetryCnt ){ if( m_bOpRetryCnt ){
m_bOpRetryCnt--; m_bOpRetryCnt--;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
registerCommError( false ); registerCommError( false );
LRF_WORK_STAGE pS = getPrevStage(); LRF_WORK_STAGE pS = getPrevStage();
@ -2517,7 +2520,7 @@ void device2DSensor::drawMode()
{ {
if (m_bActualDeviceWM != MODE_BORDER) if (m_bActualDeviceWM != MODE_BORDER)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_BORDER; m_bRequestedDeviceWM = MODE_BORDER;
if (! setMode(MODE_BORDER)) if (! setMode(MODE_BORDER))
{ {
@ -2546,7 +2549,7 @@ void device2DSensor::drawMode()
}; };
case LRF_WS_STAGE_2: case LRF_WS_STAGE_2:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER << 4;
m_bTimeOutCounter = m_nTOCounterBase << 4;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
LOG("DRAW GET ANGLE"); LOG("DRAW GET ANGLE");
#endif #endif
@ -2575,7 +2578,7 @@ void device2DSensor::drawMode()
AK->releaseExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id ); AK->releaseExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id );
} }
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
{ {
@ -2629,7 +2632,7 @@ void device2DSensor::fullDrawMode()
#ifdef DEBUG #ifdef DEBUG
LOG("SET MODE BORDER!"); LOG("SET MODE BORDER!");
#endif #endif
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_BORDER; m_bRequestedDeviceWM = MODE_BORDER;
if (! setMode(MODE_BORDER)) if (! setMode(MODE_BORDER))
{ {
@ -2649,7 +2652,7 @@ void device2DSensor::fullDrawMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER << 4;
m_bTimeOutCounter = m_nTOCounterBase << 4;
#ifdef DEBUG #ifdef DEBUG
LOG("FULL DRAW GET ANGLE"); LOG("FULL DRAW GET ANGLE");
#endif #endif
@ -2669,7 +2672,7 @@ void device2DSensor::fullDrawMode()
#ifdef DEBUG #ifdef DEBUG
LOG("FULL DRAW FINISHING"); LOG("FULL DRAW FINISHING");
#endif #endif
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
{ {
@ -2743,7 +2746,7 @@ void device2DSensor::maskMode()
{ {
case LRF_WS_INIT: case LRF_WS_INIT:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
uint8_t cm = m_pDBC->getLRFMasksStatus(m_sLRF_DATA.id); uint8_t cm = m_pDBC->getLRFMasksStatus(m_sLRF_DATA.id);
EVENT_CONTAINER * bEVT = NULL; EVENT_CONTAINER * bEVT = NULL;
TARGET_DATA * tData = prepareTargetData(0, 0, 0, 0); TARGET_DATA * tData = prepareTargetData(0, 0, 0, 0);
@ -2838,7 +2841,7 @@ void device2DSensor::alarmMode()
{ {
if (m_bActualDeviceWM != MODE_DETECTOR) if (m_bActualDeviceWM != MODE_DETECTOR)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
{ {
@ -2858,7 +2861,7 @@ void device2DSensor::alarmMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getState2()) if (! getState2())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -2933,7 +2936,7 @@ void device2DSensor::idleMode()
{ {
if (m_bActualDeviceWM != MODE_DETECTOR) if (m_bActualDeviceWM != MODE_DETECTOR)
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
m_bRequestedDeviceWM = MODE_DETECTOR; m_bRequestedDeviceWM = MODE_DETECTOR;
if (! setMode(MODE_DETECTOR)) if (! setMode(MODE_DETECTOR))
{ {
@ -2953,7 +2956,7 @@ void device2DSensor::idleMode()
}; };
case LRF_WS_STAGE_1: case LRF_WS_STAGE_1:
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
if (! getState2()) if (! getState2())
{ {
LOG_ERROR("Fall Back to Disconnected!"); LOG_ERROR("Fall Back to Disconnected!");
@ -2998,7 +3001,7 @@ void device2DSensor::proceedDBCommands()
} }
else else
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
updateDataStatus(ARGUS_DS_BUSY); updateDataStatus(ARGUS_DS_BUSY);
// transactionWaitResult(); // transactionWaitResult();
DELAY_10MS(10); // 100 ms DELAY_10MS(10); // 100 ms
@ -3024,7 +3027,7 @@ void device2DSensor::proceedDBCommands()
} }
else else
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
updateDataStatus(ARGUS_DS_STUDY); updateDataStatus(ARGUS_DS_STUDY);
// transactionWaitResult(); // transactionWaitResult();
DELAY_10MS(10); // 100 ms DELAY_10MS(10); // 100 ms
@ -3352,7 +3355,7 @@ bool device2DSensor::packetHandler(protocolPackage * Package)
#endif #endif
// Have Some Replay from device -> Reset Timeouts // Have Some Replay from device -> Reset Timeouts
m_bOpRetryCnt = LGS_CMD_RETRY_COUNT; m_bOpRetryCnt = LGS_CMD_RETRY_COUNT;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
switch (Package->m_pData[CMD_IDX]) switch (Package->m_pData[CMD_IDX])
{ {
case CMD_STATE: transactionSetResult(TRANSACTION_RESULT_OK); break; case CMD_STATE: transactionSetResult(TRANSACTION_RESULT_OK); break;
@ -3835,7 +3838,7 @@ bool device2DSensor::packetHandler(protocolPackage * Package)
// setStage( LRF_WS_STAGE_2 ); // setStage( LRF_WS_STAGE_2 );
while (Package->m_nSize > (cIDX + 2)) while (Package->m_nSize > (cIDX + 2))
{ {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
switch (Package->m_pData[cIDX + 1]) switch (Package->m_pData[cIDX + 1])
{ {
case 0x00: case 0x00:

6
lib/App/common/deviceNodeEthernet2Serial.h

@ -25,7 +25,7 @@
// serial line were too short over the Internet: a later reply was read only with the NEXT request // serial line were too short over the Internet: a later reply was read only with the NEXT request
// and given to that request's parser (one reply behind -> retries -> "Communication Wait State TO!") // and given to that request's parser (one reply behind -> retries -> "Communication Wait State TO!")
#ifndef E2UART_REPLY_TIMEOUT_MS #ifndef E2UART_REPLY_TIMEOUT_MS
#define E2UART_REPLY_TIMEOUT_MS 800 // first byte of the reply (below the sensor's 1 s per attempt)
#define E2UART_REPLY_TIMEOUT_MS 2500 // first byte of the reply (below the sensor's LGS_NETWORK_TO_COUNTER, 3 s)
#endif #endif
#ifndef E2UART_REPLY_GAP_MS #ifndef E2UART_REPLY_GAP_MS
#define E2UART_REPLY_GAP_MS 150 // a started but incomplete reply: wait this long for the rest #define E2UART_REPLY_GAP_MS 150 // a started but incomplete reply: wait this long for the rest
@ -100,6 +100,10 @@
virtual bool sendData(uint8_t * Data, int DataSize); virtual bool sendData(uint8_t * Data, int DataSize);
#endif #endif
virtual bool reconnect(void); virtual bool reconnect(void);
virtual bool isNetworkLink(void)
{
return true;
}
}; };
#endif #endif

4
lib/App/common/deviceNodeSensor.cpp

@ -169,6 +169,7 @@ deviceNodeSensor::deviceNodeSensor(uint32_t id) :
{ {
m_nCommErrorsCounter = 0; m_nCommErrorsCounter = 0;
m_nTOCounterBase = LGS_DEFAULT_TO_COUNTER;
m_ePPMODE = STG_INIT; m_ePPMODE = STG_INIT;
m_bValidationSkipCounter = DAFAULT_VALIDATION_SKIP_COUNTER; m_bValidationSkipCounter = DAFAULT_VALIDATION_SKIP_COUNTER;
m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS; m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS;
@ -252,6 +253,7 @@ deviceNodeSensor::deviceNodeSensor(DBC_NODE_DATA * Data) :
m_oPosition() m_oPosition()
{ {
m_nCommErrorsCounter = 0; m_nCommErrorsCounter = 0;
m_nTOCounterBase = LGS_DEFAULT_TO_COUNTER;
m_ePPMODE = STG_INIT; m_ePPMODE = STG_INIT;
m_bValidationSkipCounter = DAFAULT_VALIDATION_SKIP_COUNTER; m_bValidationSkipCounter = DAFAULT_VALIDATION_SKIP_COUNTER;
m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS; m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS;
@ -1189,7 +1191,7 @@ void deviceNodeSensor::waitStateFunction(LRF_WORK_STAGE boboStage)
LOG("ATTEMPT RECOVER"); LOG("ATTEMPT RECOVER");
#endif #endif
m_bOpRetryCnt--; m_bOpRetryCnt--;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
m_bTimeOutCounter = m_nTOCounterBase;
registerCommError(false); registerCommError(false);
LRF_WORK_STAGE pS = getPrevStage(); LRF_WORK_STAGE pS = getPrevStage();

6
lib/App/common/deviceNodeSensor.h

@ -11,6 +11,11 @@
#define LGS_DEFAULT_SLEEP_TIME 100 #define LGS_DEFAULT_SLEEP_TIME 100
#define LGS_ALERT_SLEEP_TIME 10 #define LGS_ALERT_SLEEP_TIME 10
#define LGS_DEFAULT_TO_COUNTER 10 // 100ms #define LGS_DEFAULT_TO_COUNTER 10 // 100ms
// Sensor behind a network link (Ethernet to serial gateway over the Internet): 3 s per attempt.
// The 1 s of a local serial line was shorter than the round trip of a mobile link at times.
#ifndef LGS_NETWORK_TO_COUNTER
#define LGS_NETWORK_TO_COUNTER 30
#endif
#define LGS_DEFAULT_WS_TIME 10 // 100ms #define LGS_DEFAULT_WS_TIME 10 // 100ms
#define LGS_INITIAL_FLIPS 8 #define LGS_INITIAL_FLIPS 8
#define LGS_CMD_RETRY_COUNT 16 #define LGS_CMD_RETRY_COUNT 16
@ -176,6 +181,7 @@ class deviceNodeSensor : public deviceNode, public basicThread
targetPipeLine * m_pTargetPipeLine; targetPipeLine * m_pTargetPipeLine;
uint8_t m_bOpRetryCnt; uint8_t m_bOpRetryCnt;
uint16_t m_bTimeOutCounter; uint16_t m_bTimeOutCounter;
uint16_t m_nTOCounterBase; // wait per attempt (x 100 ms): LGS_DEFAULT_TO_COUNTER or LGS_NETWORK_TO_COUNTER
E_MODES m_bActualDeviceWM; E_MODES m_bActualDeviceWM;
E_MODES m_bRequestedDeviceWM; E_MODES m_bRequestedDeviceWM;
uint32_t m_nChannelTO; uint32_t m_nChannelTO;

6
lib/components/base/basicTransport.h

@ -77,6 +77,12 @@ class basicTransport
{ {
return false; return false;
} }
// The device is reached over a network (e.g. an Ethernet to serial gateway on the Internet):
// replies take longer than on a local serial line
virtual bool isNetworkLink(void)
{
return false;
}
bool addRecipient(protocolParser * ProtoParser); bool addRecipient(protocolParser * ProtoParser);
bool removeRecipient(protocolParser * ProtoParser); bool removeRecipient(protocolParser * ProtoParser);

Loading…
Cancel
Save