Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
meeludwig committed Jul 12, 2022
2 parents b4d85df + 7354ffe commit a02de58
Show file tree
Hide file tree
Showing 1,739 changed files with 29,634 additions and 68,049 deletions.
9 changes: 6 additions & 3 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>




<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>




<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>




</pydev_project>
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).


<<<<<<< HEAD
### 2.0.21 [12.july.2022]
- version corrected
- found and suppreses another few nanosleeps, replace with chrono
=======
>>>>>>> 7354ffe454b67ca63b9737dda3c98290c0346d26
- OPCUA-2584: rx/tx counting in the handler, for now, to improve err reporting already, and port status:
- CanMessageError: send a boost signal with an error message to a subscibing error handler
- anagate: used in sendMessage() and sendRemoteMessage()
- peak: sendErrorCode() sends an error code (not a message) at sendMessage(), triggerReconnectionThread() and sendRemoteRequest()
- systec: sendErrorCode() sends an error code (not a message) at message reception with USB error AND the return code of sendMessage (also if it is OK)
- sock: no wrapper method (defined but not used), error messages are sent when: socket recovers, error reading from socket, a CAN error
was flagged from the socket (plus message and socket timestamp if possible), when opening a CAN port produces an error
<<<<<<< HEAD
- no functional changes
=======





### 2.0.21 (in progress devel)
- version corrected
- found and suppreses another few nanosleeps, replace with chrono


>>>>>>> 7354ffe454b67ca63b9737dda3c98290c0346d26
### 2.0.20 [20.april.2022]
- fix bugs found by QA: error message mem leak in anagate and systec
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
#
cmake_minimum_required(VERSION 3.0)
project( CanModule LANGUAGES C CXX VERSION 2.0.20 )
project( CanModule LANGUAGES C CXX VERSION 2.0.21 )
message(STATUS "[${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}]: CanModule version= ${PROJECT_VERSION}" )
set (CMAKE_CXX_STANDARD 11)

Expand Down
34 changes: 31 additions & 3 deletions CanInterface/include/CanStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,57 @@ class CanStatistics
void beginNewRun();
void computeDerived(unsigned int baudRate);

//! dataLength is the user data size (DLC field)
/**
* called when transmitting a message
* dataLength is the user data size (DLC field)
*/
void onTransmit(unsigned int dataLength);

//! dataLength is the user data size (DLC field)
/**
* called when receiving a message
* dataLength is the user data size (DLC field)
*/
void onReceive(unsigned int dataLength);

unsigned int totalTransmitted() { return m_totalTransmitted.load(); }
unsigned int totalReceived() { return m_totalReceived.load(); }

/**
* transmission rate bytes/s
*/
float txRate() { return m_internals.m_transmittedPerSec; }

/**
* reception rate bytes/s
*/
float rxRate() { return m_internals.m_receivedPerSec; }
float busLoad() { return m_internals.m_busLoad; }

/**
* bus load in 0...1 ( % * 100 ) of max bus speed (baudrate)
*/
float busLoad() { return m_internals.m_busLoad; }

/**
* time since the last message was received in microseconds
*/
double timeSinceReceived() {
m_hrnow = high_resolution_clock::now();
duration<double, micro> time_span = duration_cast<duration<double, micro>>(m_hrnow - m_hrreceived);
return ( time_span.count() / 1000 );
}

/**
* time since the last message was sent, in microseconds
*/
double timeSinceTransmitted() {
m_hrnow = high_resolution_clock::now();
duration<double, micro> time_span = duration_cast<duration<double, micro>>(m_hrnow - m_hrtransmitted);
return ( time_span.count() / 1000 );
}

/**
* time since that bus was opened, in microseconds
*/
double timeSinceOpened() {
m_hrnow = high_resolution_clock::now();
duration<double, micro> time_span = duration_cast<duration<double, micro>>(m_hrnow - m_hropen);
Expand Down
18 changes: 18 additions & 0 deletions CanInterfaceImplementations/sockcan/SockCanScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void CSockCanScan::CanScanControlThread()
if ( selectResult < 0 ){
MLOGSOCK(ERR,p_sockCanScan) << "select() failed: " << CanModuleerrnoToString()
<< " tid= " << _tid;
#if 0
{
struct timespec tim, tim2;
tim.tv_sec = 1;
Expand All @@ -176,6 +177,8 @@ void CSockCanScan::CanScanControlThread()
MLOGSOCK(ERR,p_sockCanScan) << "Waiting 1s failed (nanosleep) tid= " << _tid;
}
}
#endif
CanModule::ms_sleep( 1000 );
continue;
}

Expand Down Expand Up @@ -221,6 +224,7 @@ void CSockCanScan::CanScanControlThread()
// try close/opening on faults while port is active. This was a system error
do {
MLOGSOCK(INF,p_sockCanScan) << "Waiting 10000ms."<< " tid= " << _tid;
#if 0
{
struct timespec tim, tim2;
tim.tv_sec = 10;
Expand All @@ -229,6 +233,9 @@ void CSockCanScan::CanScanControlThread()
MLOG(ERR,p_sockCanScan) << "Waiting 10000ms failed (nanosleep)"<< " tid= " << _tid;
}
}
#endif
CanModule::ms_sleep( 10000 );

if ( sock > 0 ) {
// try closing the socket
MLOGSOCK(INF,p_sockCanScan) << "Closing socket."<< " tid= " << _tid;
Expand Down Expand Up @@ -666,6 +673,7 @@ bool CSockCanScan::sendMessage(short cobID, unsigned char len, unsigned char *me
if ( errno == ENOBUFS ) {
// std::cerr << "ENOBUFS; waiting a jiffy [100ms]..." << std::endl;
MLOGSOCK(ERR,this) << "write error ENOBUFS: waiting a jiffy [100ms]...";
#if 0
{
struct timespec tim, tim2;
tim.tv_sec = 0;
Expand All @@ -674,6 +682,9 @@ bool CSockCanScan::sendMessage(short cobID, unsigned char len, unsigned char *me
MLOGSOCK(ERR,this) << "Waiting 100ms failed (nanosleep)";
}
}
#endif
CanModule::ms_sleep( 100 );

ret = false;
}
if ( numberOfWrittenBytes < (int)sizeof(struct can_frame)){
Expand Down Expand Up @@ -725,6 +736,7 @@ bool CSockCanScan::sendRemoteRequest(short cobID)
if (errno == ENOBUFS)
{
MLOGSOCK(ERR,this) << "ENOBUFS; waiting a jiffy [100ms]...";
#if 0
{
struct timespec tim, tim2;
tim.tv_sec = 0;
Expand All @@ -733,6 +745,9 @@ bool CSockCanScan::sendRemoteRequest(short cobID)
MLOGSOCK(ERR,this) << "Waiting 100ms failed (nanosleep)";
}
}
#endif
CanModule::ms_sleep( 100 );

continue;//If this happens we sleep and start from the beggining of the loop
}
}
Expand Down Expand Up @@ -933,6 +948,8 @@ void CSockCanScan::clearErrorMessage()
canMessageError(0, errorMessage.c_str(), c_time);
}

#if 0
// this method is not used, instead, code is implemented directly everywhere
/**
* send a timestamped error message, get time from the socket or from chrono
*/
Expand All @@ -950,6 +967,7 @@ void CSockCanScan::sendErrorMessage(const char *mess)
MLOGSOCK(TRC,this) << "ioctlReturn= " << ioctlReturn;
canMessageError(-1,mess,c_time);
}
#endif

/**
* notify the main thread to finish and delete the bus from the map of connections
Expand Down
2 changes: 1 addition & 1 deletion CanInterfaceImplementations/sockcan/SockCanScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class CSockCanScan : public CCanAccess
void updateInitialError () ;
static std::string errorFrameToString (const struct can_frame &f);

void sendErrorMessage(const char *);
// void sendErrorMessage(const char *);
void clearErrorMessage();
int configureCanBoard(const string name,const string parameters);
// void updateBusStatus();
Expand Down
Loading

0 comments on commit a02de58

Please sign in to comment.