Skip to content

Commit

Permalink
Devel2.2.4 (#82)
Browse files Browse the repository at this point in the history
intermediate merge, validation for all vendors X OS with stability tests is ongoing
----------------------------------------------------------------------------------------------------------------
- moved reconnection methods to superclass
- found and fixed a build chain bug in socketcan, corrected
- suppressed tag::docker in yaml to make new runners happy
-  cleanup as always, some improvements in Log TRC
  • Loading branch information
meeludwig authored Mar 6, 2024
1 parent 64128e3 commit e999a57
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 124 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

### 2.2.3
### 2.2.4 [6.march.2024, skip 2.2.3]
- suppressed the interactive message box in CanLibLoaderWin.ccp:61 https://its.cern.ch/jira/browse/ENS-27467
- made m_updateInitialError () ; public again and renamed it to updateInitialError() accordingly, OPCUA-2602.
also initialize it to 0 at init.
- fixed a silly bug in the build chain for socketcan: some sources were missing.
- code around reconnection behavior based on superclass methods everywhere now. Hope this works for windows
- jenkins seems to be gone


### 2.2.2
- minor cleanup of debugging
Expand Down
29 changes: 9 additions & 20 deletions CanInterface/include/CCanAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,28 +424,17 @@ class CCanAccess
* If a bridge is shared between multiple tasks, all channels across tasks are reset, affecting all tasks connected to
* that bridge. Evidently, a given channel must only be used by at most one task.
* */
virtual void setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action ) = 0;

/**
* set the timout interval for message reception, for the reconnection behaviour. Units is seconds, default is 120.
*/
virtual void setReconnectReceptionTimeout( unsigned int timeout ) = 0;

/**
* set the counter for failed consecutive sending attempts, for reconnection. default is 10.
*/
virtual void setReconnectFailedSendCount( unsigned int c ) = 0;

void setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action ){
std::cout <<__FUNCTION__ << " " << __FILE__ << " " << __LINE__ << std::endl;
m_reconnectCondition = cond;
m_reconnectAction = action;
};
void setReconnectReceptionTimeout( unsigned int timeout ){ m_timeoutOnReception = timeout; };
void setReconnectFailedSendCount( unsigned int c ){ m_maxFailedSendCount = m_failedSendCountdown = c; }
CanModule::ReconnectAutoCondition getReconnectCondition() { return m_reconnectCondition; };
CanModule::ReconnectAction getReconnectAction() { return m_reconnectAction; };

/**
* read back the r.condition
*/
virtual CanModule::ReconnectAutoCondition getReconnectCondition() = 0;

/**
* read back the r.action
*/
virtual CanModule::ReconnectAction getReconnectAction() = 0;

/**
* stop the bus.
Expand Down
14 changes: 7 additions & 7 deletions CanInterfaceImplementations/anagate/AnaCanScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,8 @@ void AnaCanScan::m_CanReconnectionThread()
waitForReconnectionThreadTrigger();
MLOGANA(TRC, this)
<< " reconnection thread tid= " << _tid
<< " condition "<< reconnectConditionString(getReconnectCondition() )
<< " action " << reconnectActionString(getReconnectAction())
<< " condition "<< CCanAccess::reconnectConditionString(getReconnectCondition() )
<< " action " << CCanAccess::reconnectActionString(getReconnectAction())
<< " is checked, m_failedSendCountdown= "
<< m_failedSendCountdown;

Expand Down Expand Up @@ -1252,8 +1252,8 @@ void AnaCanScan::m_CanReconnectionThread()
// to avoid lots of useless triggers at each send message.
switch ( getReconnectAction() ){
case CanModule::ReconnectAction::singleBus: {
MLOGANA(INF, this) << " reconnect condition " << reconnectConditionString(m_reconnectCondition)
<< " triggered action " << reconnectActionString(m_reconnectAction);
MLOGANA(INF, this) << " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);

AnaInt32 ret = m_reconnectThisPort();
MLOGANA(INF, this) << "reconnected one CAN port ip= " << m_canIPAddress << " ret= " << ret;
Expand All @@ -1268,16 +1268,16 @@ void AnaCanScan::m_CanReconnectionThread()
*/
case CanModule::ReconnectAction::allBusesOnBridge: {
std::string ip = m_ipAddress();
MLOGANA(INF, this) << " reconnect condition " << reconnectConditionString(m_reconnectCondition)
<< " triggered action " << reconnectActionString(m_reconnectAction);
MLOGANA(INF, this) << " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);
AnaCanScan::st_reconnectAllPorts( ip );
MLOGANA(TRC, this) << " reconnect all ports of ip= " << ip << this->getBusName();
break;
}
default: {
// we have a runtime bug
MLOGANA(ERR, this) << "reconnection action "
<< (int) m_reconnectAction << reconnectActionString( m_reconnectAction )
<< (int) m_reconnectAction << CCanAccess::reconnectActionString( m_reconnectAction )
<< " unknown. Check your config & see documentation. No action.";
break;
}
Expand Down
16 changes: 2 additions & 14 deletions CanInterfaceImplementations/anagate/AnaCanScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@

#include <CanModuleUtils.h>
#include <CCanAccess.h>

#include "CanStatistics.h"
#include "CCanAccess.h"
#include "CanMessage.h"
#include <CanStatistics.h>
#include <CanMessage.h>
#include <Diag.h>

// specific vendor

#ifdef _WIN32
// #include <AnaGate.h>
#include <AnaGateDLL.h>
#include <AnaGateDllCan.h>
#else
Expand Down Expand Up @@ -112,15 +109,6 @@ class AnaCanScan: public CanModule::CCanAccess

uint32_t getPortStatus();
virtual uint32_t getPortBitrate(){ return m_CanParameters.m_lBaudRate; };

virtual void setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action ){
m_reconnectCondition = cond;
m_reconnectAction = action;
};
virtual void setReconnectReceptionTimeout( unsigned int timeout ){ m_timeoutOnReception = timeout; };
virtual void setReconnectFailedSendCount( unsigned int c ){ m_maxFailedSendCount = m_failedSendCountdown = c; }
virtual CanModule::ReconnectAutoCondition getReconnectCondition() { return m_reconnectCondition; };
virtual CanModule::ReconnectAction getReconnectAction() { return m_reconnectAction; };
virtual void stopBus( void );
virtual void fetchAndPublishCanPortState ();

Expand Down
14 changes: 7 additions & 7 deletions CanInterfaceImplementations/anagate2/AnaCanScan2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,8 @@ void AnaCanScan2::m_CanReconnectionThread()
waitForReconnectionThreadTrigger();
MLOGANA2(TRC, this)
<< " reconnection thread tid= " << _tid
<< " condition "<< reconnectConditionString(getReconnectCondition() )
<< " action " << reconnectActionString(getReconnectAction())
<< " condition "<< CCanAccess::reconnectConditionString(getReconnectCondition() )
<< " action " << CCanAccess::reconnectActionString(getReconnectAction())
<< " is checked, m_failedSendCountdown= "
<< m_failedSendCountdown;

Expand Down Expand Up @@ -1389,8 +1389,8 @@ void AnaCanScan2::m_CanReconnectionThread()
// to avoid lots of useless triggers at each send message.
switch ( getReconnectAction() ){
case CanModule::ReconnectAction::singleBus: {
MLOGANA2(INF, this) << " reconnect condition " << reconnectConditionString(m_reconnectCondition)
<< " triggered action " << reconnectActionString(m_reconnectAction);
MLOGANA2(INF, this) << " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);

AnaInt32 ret = m_reconnectThisPort();
MLOGANA2(INF, this) << "reconnected one CAN port ip= " << m_canIPAddress << " ret= " << ret;
Expand All @@ -1405,16 +1405,16 @@ void AnaCanScan2::m_CanReconnectionThread()
*/
case CanModule::ReconnectAction::allBusesOnBridge: {
std::string ip = m_ipAddress();
MLOGANA2(INF, this) << " reconnect condition " << reconnectConditionString(m_reconnectCondition)
<< " triggered action " << reconnectActionString(m_reconnectAction);
MLOGANA2(INF, this) << " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);
AnaCanScan2::st_reconnectAllPorts( ip );
MLOGANA2(TRC, this) << " reconnect all ports of ip= " << ip << this->getBusName();
break;
}
default: {
// we have a runtime bug
MLOGANA2(ERR, this) << "reconnection action "
<< (int) m_reconnectAction << reconnectActionString( m_reconnectAction )
<< (int) m_reconnectAction << CCanAccess::reconnectActionString( m_reconnectAction )
<< " unknown. Check your config & see documentation. No action.";
break;
}
Expand Down
15 changes: 2 additions & 13 deletions CanInterfaceImplementations/anagate2/AnaCanScan2.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@

#include <CanModuleUtils.h>
#include <CCanAccess.h>

#include "CanStatistics.h"
#include "CCanAccess.h"
#include "CanMessage.h"

#include <CanStatistics.h>
#include <CanMessage.h>
#include <Diag.h>

// specific vendor
Expand Down Expand Up @@ -114,14 +111,6 @@ class AnaCanScan2: public CanModule::CCanAccess
uint32_t getPortStatus();
virtual uint32_t getPortBitrate(){ return m_CanParameters.m_lBaudRate; };

virtual void setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action ){
m_reconnectCondition = cond;
m_reconnectAction = action;
};
virtual void setReconnectReceptionTimeout( unsigned int timeout ){ m_timeoutOnReception = timeout; };
virtual void setReconnectFailedSendCount( unsigned int c ){ m_maxFailedSendCount = m_failedSendCountdown = c; }
virtual CanModule::ReconnectAutoCondition getReconnectCondition() { return m_reconnectCondition; };
virtual CanModule::ReconnectAction getReconnectAction() { return m_reconnectAction; };
virtual void stopBus( void );
virtual void fetchAndPublishCanPortState ();

Expand Down
14 changes: 7 additions & 7 deletions CanInterfaceImplementations/pkcan/pkcan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ DWORD WINAPI PKCanScan::CanReconnectionThread(LPVOID pCanScan)
pkCanScanPointer->waitForReconnectionThreadTrigger();
MLOGPK(TRC, pkCanScanPointer)
<< " reconnection thread tid= " << _tid
<< " condition "<< reconnectConditionString(pkCanScanPointer->getReconnectCondition() )
<< " action " << reconnectActionString(pkCanScanPointer->getReconnectAction())
<< " condition "<< CCanAccess::reconnectConditionString(pkCanScanPointer->getReconnectCondition() )
<< " action " << CCanAccess::reconnectActionString(pkCanScanPointer->getReconnectAction())
<< " is checked, m_failedSendCountdown= "
<< pkCanScanPointer->getFailedSendCountdown();

Expand Down Expand Up @@ -706,8 +706,8 @@ DWORD WINAPI PKCanScan::CanReconnectionThread(LPVOID pCanScan)
// action
switch ( raction ){
case CanModule::ReconnectAction::singleBus: {
MLOGPK(INF, pkCanScanPointer) << " reconnect condition " << reconnectConditionString( rcondition )
<< " triggered action " << reconnectActionString( raction );
MLOGPK(INF, pkCanScanPointer) << " reconnect condition " << CCanAccess::reconnectConditionString( rcondition )
<< " triggered action " << CCanAccess::reconnectActionString( raction );


CAN_Initialize(pkCanScanPointer->getTPCANHandle(), pkCanScanPointer->getBaudRate() );
Expand All @@ -716,14 +716,14 @@ DWORD WINAPI PKCanScan::CanReconnectionThread(LPVOID pCanScan)
}

case CanModule::ReconnectAction::allBusesOnBridge: {
MLOGPK(INF, pkCanScanPointer) << " reconnect condition " << reconnectConditionString( rcondition )
<< " triggered action " << reconnectActionString( raction );
MLOGPK(INF, pkCanScanPointer) << " reconnect condition " << CCanAccess::reconnectConditionString( rcondition )
<< " triggered action " << CCanAccess::reconnectActionString( raction );
break;
}
default: {
// we have a runtime bug
MLOGPK(ERR, pkCanScanPointer) << "reconnection action "
<< (int) raction << reconnectActionString( raction )
<< (int) raction << CCanAccess::reconnectActionString( raction )
<< " unknown. Check your config & see documentation. No action.";
break;
}
Expand Down
9 changes: 7 additions & 2 deletions CanInterfaceImplementations/pkcan/pkcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
#include "windows.h"

#include <PCANBasic.h>
#include "CCanAccess.h"
#include "CanStatistics.h"

#include <CanModuleUtils.h>
#include <CCanAccess.h>
#include <CanStatistics.h>
// #include <CanMessage.h>
#include <Diag.h>



#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::posix_time;

Expand Down
12 changes: 6 additions & 6 deletions CanInterfaceImplementations/sockcan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ if( (NOT DEFINED SOCKETCAN_LIB_PATH) OR (NOT DEFINED SOCKETCAN_HEADERS) OR (NOT
message( STATUS "[${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}]: Required variable SOCKETCAN_HEADERS has not been defined. assuming ${SOCKETCAN_HEADERS} " )
message( STATUS "[${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}]: Required variable SOCKETCAN_LIB_FILE has not been defined. assuming ${SOCKETCAN_LIBS} " )
endif()
include_directories( ${SOCKETCAN_HEADERS} )
include_directories( ${SOCKETCAN_HEADERS} )
link_directories( ${SOCKETCAN_LIB_PATH} )


set(SOCKCAN_SOURCES
ExecCommand.cpp
ExecCommand.h
UdevAnalyserForPeak.cpp
UdevAnalyserForPeak.h
SockCanScan.cpp
SockCanScan.h
../../CanInterface/src/CanStatistics.cpp
../../CanInterface/include/CanStatistics.h
../../CanInterface/src/CanStatistics.cpp
../../CanInterface/src/CanModuleUtils.cpp
../../CanInterface/src/CCanAccess.cpp
../../Diagnostic/src/Diag.cpp
)

# you can either build the fully dynamic libs or the as-static-as-possible,
Expand Down
17 changes: 6 additions & 11 deletions CanInterfaceImplementations/sockcan/SockCanScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ CSockCanScan::CSockCanScan() :
return c;
}

/* virtual */ void CSockCanScan::setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action ){
m_reconnectCondition = cond;
m_reconnectAction = action;
};

/**
* (virtual) forced implementation. Generally: do whatever shenanigans you need on the vendor API and fill in the portState accordingly, stay
* close to the semantics of the enum.
Expand Down Expand Up @@ -423,9 +418,8 @@ void CSockCanScan::m_CanReconnectionThread()
MLOGSOCK(TRC, this) << "waiting reconnection thread tid= " << _tid;
waitForReconnectionThreadTrigger();
MLOGSOCK(TRC, this)
<< " reconnection thread tid= " << _tid
<< " condition "<< reconnectConditionString(rcond)
<< " action " << reconnectActionString(ract)
<< " condition "<< CCanAccess::reconnectConditionString(rcond)
<< " action " << CCanAccess::reconnectActionString(ract)
<< " is checked, m_failedSendCountdown= "
<< m_failedSendCountdown;

Expand Down Expand Up @@ -466,8 +460,9 @@ void CSockCanScan::m_CanReconnectionThread()
switch ( m_reconnectAction ){
case CanModule::ReconnectAction::singleBus: {

MLOGSOCK(INF, this) << " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);
MLOGSOCK(INF, this)
<< " reconnect condition " << CCanAccess::reconnectConditionString(m_reconnectCondition)
<< " triggered action " << CCanAccess::reconnectActionString(m_reconnectAction);
close( m_sock );
int return0 = m_openCanPort();
MLOGSOCK(TRC, this) << "reconnect openCanPort() ret= " << return0;
Expand All @@ -489,7 +484,7 @@ void CSockCanScan::m_CanReconnectionThread()
* CanModule::ReconnectAction::allBusesOnBridge is not implemented for sock
*/
MLOGSOCK(WRN, this) << "reconnection action "
<< (int) m_reconnectAction << reconnectActionString( m_reconnectAction )
<< (int) m_reconnectAction << CCanAccess::reconnectActionString( m_reconnectAction )
<< " is not available for the socketcan/linux implementation. Check your config & see documentation. No action.";
break;
}
Expand Down
14 changes: 6 additions & 8 deletions CanInterfaceImplementations/sockcan/SockCanScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
#include <sys/socket.h>
#include <linux/can.h>

#include "CCanAccess.h"
#include "CanStatistics.h"
#include "libsocketcan.h"
#include <libsocketcan.h>
#include <CCanAccess.h>
#include <CanStatistics.h>
#include <Diag.h>
// #include <CanModuleUtils.h>
// #include <CanMessage.h>


#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::posix_time;
Expand Down Expand Up @@ -65,11 +68,6 @@ class CSockCanScan : public CCanAccess
virtual void getStatistics( CanStatistics & result );
virtual uint32_t getPortStatus();
virtual uint32_t getPortBitrate(){ return m_CanParameters.m_lBaudRate; };
virtual void setReconnectBehavior( CanModule::ReconnectAutoCondition cond, CanModule::ReconnectAction action );
virtual void setReconnectReceptionTimeout( unsigned int timeout ){ m_timeoutOnReception = timeout; };
virtual void setReconnectFailedSendCount( unsigned int c ){ m_maxFailedSendCount = m_failedSendCountdown = c; }
virtual CanModule::ReconnectAutoCondition getReconnectCondition() { return m_reconnectCondition; };
virtual CanModule::ReconnectAction getReconnectAction() { return m_reconnectAction; };
virtual void stopBus ();
virtual void fetchAndPublishCanPortState ();

Expand Down
3 changes: 0 additions & 3 deletions CanInterfaceImplementations/sockcan/UdevAnalyserForPeak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ unsigned int UdevAnalyserForPeak::m_peakLocalCanPort( std::string s ){
size_t pos1 = s.find( "/can" ) - 4;
std::string sub1 = s.substr( pos1, std::string::npos );
std::cout << __FILE__ << " " << __LINE__ << " sub1= " << sub1 << std::endl;



size_t pos2 = sub1.find( "/" ) + 1;
std::string sub2 = sub1.substr( pos2, sub1.find(" ") - 2 );
std::string sub3 = sub2.substr( 3, std::string::npos );
Expand Down
Loading

0 comments on commit e999a57

Please sign in to comment.